FastAPI service for incident response demos. It handles incident intake, evidence retrieval from fixtures, KB search, Slack-triggered workflows, and an OpenAI-powered agent that uses internal tools.
- Incident lifecycle endpoints: create, assign, evidence, notes.
- KB search with SQLite FTS5 chunks.
- Slack alert posting and interactive approvals.
- OpenAI agent loop that calls local tools (create incident, fetch evidence, KB search, notes).
- Create a virtual environment and install dependencies.
- Configure env vars (see
.env.example). - Run the API.
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
uvicorn app.main:app --reloadRequired for OpenAI agent:
OPENAI_API_KEY
Optional OpenAI settings:
OPENAI_MODEL(defaultgpt-4o-mini)OPENAI_TIMEOUT(seconds, default20)OPENAI_BASE_URL(defaulthttps://api.openai.com/v1)
Required for Slack:
SLACK_BOT_TOKENSLACK_SIGNING_SECRETSLACK_CHANNEL_ID
Notes:
.envis loaded automatically byapp/main.py.- Never commit secrets; use
.env.exampleas a template.
Core endpoints:
POST /incidentsPOST /incidents/{incident_id}/assignGET /incidents/{incident_id}/evidencePOST /incidents/{incident_id}/notesGET /kb/searchPOST /incident/startPOST /approvalsGET /approvals/nextPOST /slack/alertPOST /slack/actions
OpenAPI specs:
openapi.jsonopenapiv2.json
The OpenAI agent in app/agent.py:
- Receives the alert payload.
- Calls internal tools via function calls:
- create incident
- assign owners
- fetch evidence
- search KB
- add notes
- Returns a structured JSON response for Slack.
Slack flow:
/slack/alertposts the interactive alert message./slack/actionsruns the agent and posts the incident summary to the thread.
If OPENAI_API_KEY is not set, Slack actions fall back to fixture-only behavior.
- SQLite DB at
app/incidents.db - KB chunks stored in SQLite FTS5 (
kb_chunkstable)
- Fixtures live in
app/fixtures/payments_failing. - Only
payments_failingfixtures exist by default; other incident types will return missing-fixture errors.