An AI-assisted, multi-agent Site Reliability Engineering (SRE) platform that triages incidents, verifies root-cause hypotheses with tools, executes remediation (when safe), escalates to humans when required, and generates a post-mortem report.
The system combines:
- FastAPI backend for streaming incident execution
- LangGraph workflow orchestration for autonomous decision loops
- Streamlit operations dashboard for real-time observability and Human-in-the-Loop (HITL)
- SQLite + ChromaDB memory layers for operational history and retrieval-augmented context
- n8n + Telegram bot integration for external automation, alert intake, and incident notifications
- Why This Project
- Core Capabilities
- System Architecture
- Workflow Lifecycle
- Tech Stack
- Project Structure
- Getting Started
- Configuration
- Running the System
- Telegram Integration
- API Reference
- Human-in-the-Loop Flow
- Data and Memory Model
- Screenshot Placeholders
- Troubleshooting
- Security Notes
- Roadmap Ideas
- License
Modern incidents are noisy, high-pressure, and expensive when triage is slow. This platform provides a practical blueprint for autonomous incident handling with built-in guardrails:
- Rapid intake and classification of raw alerts
- Tool-backed verification instead of guess-only reasoning
- Escalation and pause/resume for human approval
- Execution trace streaming for operator visibility
- Persistent incident memory to improve future responses
-
Autonomous incident triage
- Classifies incoming incidents by component and severity (
P0-P3) - Generates structured hypotheses for investigation
- Classifies incoming incidents by component and severity (
-
RAG-assisted historical memory lookup
- Searches prior incident reports from ChromaDB before deciding next steps
- Encourages reuse of known-good fixes
-
Verification loop with live tools
- Chooses diagnostic tools dynamically (e.g., DB pool checks, payment latency checks)
- Iterates across hypotheses until one is verified or all are rejected
-
Automated remediation actions
- Selects and invokes remediation tools (e.g., scale DB connections, rollback deployment, clear cache)
- Captures execution details for post-mortem traceability
-
Human-in-the-Loop (HITL) escalation
- Interrupts graph execution when confidence is low, hypotheses are exhausted, or incident severity warrants approval
- Supports resume flow with human override decisions
-
Real-time operator UI
- Streamed event updates and logs in Streamlit
- Live status card, node progress, interrupt payload rendering, final report view
-
Incident reporting and long-term memory
- Auto-generates markdown post-mortem report
- Persists incidents, hypotheses, actions, traces to SQLite
- Stores report embeddings in ChromaDB for future retrieval
-
External automation hooks
- Sends interrupt/report payloads to n8n via webhook for notifications/workflows
-
Telegram group operations
- Supports incident intake from Telegram using
/alert <incident details>in a group - Automatically posts generated incident reports back to the Telegram group via bot workflow
- Supports HITL approvals in Telegram where responders approve/reject fixes and resume workflow execution
- Supports incident intake from Telegram using
UI/API Alert or Telegram /alert -> FastAPI /investigate -> LangGraph Workflow
-> Triage
-> Verifier (loop)
-> Action (if verified)
-> Escalation (if needed)
-> Report
-> Stream events to UI + webhook
-> Persist to SQLite + ChromaDB
Report/Interrupt Webhook -> n8n -> Telegram Bot -> Telegram Group
Telegram Approve/Reject Action -> n8n -> POST /api/v1/resume/{thread_id}
Graph rendering is available in graph.png.
- Incident Intake
- Client sends
raw_incidenttoPOST /api/v1/investigatedirectly (UI/API) or through Telegram/alertflow bridged by n8n.
- Client sends
- Triage
- Classifies component and severity; queries historical memory; emits hypotheses.
- Verification Loop
- Tests each hypothesis with selected diagnostic tools.
- Decision Branch
- Verified hypothesis -> remediation action.
- No verified hypothesis / low confidence / guardrail -> escalation.
- HITL (if interrupted)
- Human reviews payload in UI or Telegram and resumes via
POST /api/v1/resume/{thread_id}.
- Human reviews payload in UI or Telegram and resumes via
- Reporting + Persistence
- Generates final markdown report, stores full incident lifecycle, and can auto-send report content to Telegram group via webhook automation.
- Backend: FastAPI, Pydantic, LangGraph, LangChain
- Frontend: Streamlit
- LLM Integrations: OpenAI-compatible endpoint + Ollama models
- Memory:
- Relational: SQLite (
sre_memory.db) via SQLAlchemy - Vector: ChromaDB (
chroma_data/) using Ollama embeddings
- Relational: SQLite (
- Automation: n8n webhook callbacks
- Messaging: Telegram Bot API (typically orchestrated via n8n workflows)
- Containerization: Docker, Docker Compose
- Package/Runtime Tooling:
uv(Python dependency/runtime manager)
backend/
api/main.py # FastAPI app, streaming endpoints, webhook dispatch
graph/graph.py # LangGraph construction and routing
graph/state.py # Shared workflow state schema
graph/nodes/ # Triage, Verify, Action, Escalation, Report nodes
tools/sre_tools.py # Diagnostic/action tools + RAG search tool
core/models.py # SQLAlchemy data model
core/schema.py # Pydantic schemas (hypothesis/action)
utils/database.py # SQLite initialization/session management
frontend/
app.py # Streamlit control panel with live stream handling
docker-compose.yml # n8n + backend + frontend orchestration
bot_test.py # Test webhook payload sender (useful for n8n/Telegram flow testing)
graph.png # Workflow graph artifact
sre_memory.db # SQLite memory store
chroma_data/ # Chroma vector store persistence
- Python 3.13+
- Docker + Docker Compose (for containerized run)
- Ollama endpoint accessible by backend/reporting tools
- n8n (if using webhook automation path)
cd "C:\Users\asus\PycharmProjects\Autonomous-Incident-Response-System"
docker compose up --buildServices exposed:
- Frontend:
http://localhost:8501 - Backend API:
http://localhost:8000 - n8n:
http://localhost:5678
cd "C:\Users\asus\PycharmProjects\Autonomous-Incident-Response-System"
uv sync
uv run fastapi run backend/api/main.pyIn a separate terminal:
cd "C:\Users\asus\PycharmProjects\Autonomous-Incident-Response-System"
uv run streamlit run frontend/app.pyCreate a .env file in the project root. Example variable names used by the app:
OLLAMA_API_KEY=
N8N_WEBHOOK_URL=| Variable | Purpose |
|---|---|
OLLAMA_API_KEY |
API key for OpenAI-compatible calls used by graph nodes |
N8N_WEBHOOK_URL |
Endpoint for async interrupt/report webhook payloads |
If you route events to Telegram through n8n, bot-specific values (for example, bot token and target group/chat ID) are typically configured inside n8n credentials/workflow variables rather than this backend.
- Start backend and frontend (Docker or local).
- Open
http://localhost:8501. - Paste a raw incident alert into the input area.
- Click Start Investigation.
- Observe live node logs and status updates.
- If interrupted, submit human decision and resume.
- Review generated post-mortem report.
Alternative intake path:
- Send
/alert <incident details>in your configured Telegram group to trigger the same investigation flow via n8n.
Automated messaging path:
- Interrupt events and final reports can be forwarded by n8n to your Telegram group through the bot.
The project supports Telegram-assisted operations through webhook automation:
-
Inbound (Telegram -> System)
- In a Telegram group, operators send
/alert <incident details>. - Your n8n Telegram trigger parses the message and calls
POST /api/v1/investigatewithraw_incident.
- In a Telegram group, operators send
-
Outbound (System -> Telegram)
- Backend emits
interruptandreportwebhook payloads toN8N_WEBHOOK_URL. - n8n forwards these payloads to Telegram so the group receives real-time updates and final reports.
- Backend emits
-
HITL approvals from Telegram
- Interrupt payload includes the investigation context and
thread_id. - In Telegram, responders can choose Approve or Reject on the proposed fix.
- n8n maps the choice to API semantics and calls
POST /api/v1/resume/{thread_id}:Approve->decision: "override"Reject->decision: "ignore"
- Interrupt payload includes the investigation context and
-
Recommended n8n mapping
/alerttext ->raw_incidentreport.content-> formatted Telegram messageinterrupt.payload-> approval prompt message for responders- Telegram action callback ->
decision+thread_idfor resume API call
Starts a new incident workflow and streams Server-Sent Events.
Request body:
{
"raw_incident": "DATADOG ALERT: Database connection pool exhausted..."
}Response:
text/event-stream- header
X-Thread-ID: INC-XXXXXXXX
Resumes a paused investigation after human decision.
This endpoint can be invoked from the Streamlit UI or by an n8n Telegram action workflow when a group responder approves/rejects a fix.
Request body:
{
"decision": "override",
"action_type": "restart_service",
"target": "api-server"
}Basic health-style root response.
Escalation is triggered when:
- No hypotheses are verified
- Confidence/verification path suggests low trust
- Severity guardrail requires explicit approval (e.g.,
P0)
During escalation:
- Backend emits interrupt event to frontend
- Backend can forward interrupt payload (including
thread_id) to n8n webhook - Operator submits override/ignore decision
- Graph resumes from interruption point
Telegram-assisted HITL option:
- n8n posts an approval message in Telegram group with action buttons
- Approve/Reject action triggers
POST /api/v1/resume/{thread_id} - n8n maps Telegram action to
override/ignoredecision payload
The platform persists incident context in two layers:
-
SQLite (
sre_memory.db)incidentshypothesesactionstracespast_incidents
-
ChromaDB (
chroma_data/)- Embeds final reports into
sre_runbookscollection - Enables semantic similarity retrieval in future triage
- Embeds final reports into
- Backend cannot reach model endpoint
- Verify Ollama/OpenAI-compatible URL accessibility and credentials.
- Frontend cannot connect to backend
- Ensure
API_URLpoints to backend and port8000is reachable.
- Ensure
- No webhook events in n8n
- Check
N8N_WEBHOOK_URL, tunnel visibility (if using ngrok), and n8n workflow state.
- Check
- Telegram group does not receive report messages
- Validate n8n Telegram node credentials, bot membership/admin rights in the group, and the correct group/chat ID mapping.
- Graph image not visible in UI sidebar
- Confirm
graph.pngexists and is mounted in Docker (/app/graph.png).
- Confirm
- Memory retrieval seems empty
- Verify
chroma_data/persistence and that reports are being generated/embedded.
- Verify
- Store secrets only in
.envor a secure secret manager; never hardcode credentials. - If any secrets were committed previously, rotate them immediately.
- Restrict CORS origins and harden webhook exposure before production deployment.
- Treat mock remediation tools as placeholders before connecting to real infrastructure actions.
- Add authentication and role-based approvals for HITL actions
- Replace mock tools with production-safe, audited integrations
- Add incident timeline view and search in frontend
- Introduce automated tests for node behavior and API streaming
- Add CI checks for linting, type checks, and security scanning
This project is licensed under the MIT License. See LICENSE for details.




