Multi-agent system that autonomously responds to production incidents — detects alerts, triages severity, investigates root cause, applies remediation, and generates post-mortems. Built with LangGraph.js and the DeepSeek V4 Flash LLM.
POST /api/incidents (or Kafka event)
│
▼
┌────────────────────────────┐
│ Inngest │
│ Durable execution pipeline │
│ │
│ step.run("triage") │
│ step.run("investigate") │
│ step.waitForEvent(approve) │
│ step.run("remediate") │
│ step.run("postmortem") │
└──────────┬─────────────────┘
│
▼
┌──────────────────────────┐
│ LangGraph.js Workflow │
│ (agent state machine) │
│ │
│ ┌────────┐ ┌──────────┐ │
│ │ Triage │▶│Investigate│ │
│ └───┬────┘ └────┬─────┘ │
│ │ │ │
│ ┌───▼────┐ ┌────▼─────┐ │
│ │ Human │ │ Remediate │ │
│ │ Esc. │ │ │ │
│ └────────┘ └────┬─────┘ │
│ │ │
│ ┌──────▼──────┐│
│ │ Post-Mortem ││
│ └─────────────┘│
└──────────────────────────┘
│
└──────────┬──────────┐
▼ ▼
┌────────┐ ┌──────────┐
│ Slack │ │Dashboard │
│ Alerts │ │(Next.js) │
└────────┘ └──────────┘
Incidents flow through an Inngest durable execution pipeline with 5 stages, each wrapping the corresponding LangGraph node:
| Stage | Engine | What it does |
|---|---|---|
| Triage | Inngest step.run() |
Classifies severity (P0-P4), extracts service/error type. Routes to escalation if critical. |
| Investigate | Inngest step.run() |
Uses tool-calling LLM to query Prometheus metrics and GitHub git history. Returns root cause with evidence. |
| Human Approval | Inngest step.waitForEvent() |
Pauses pipeline — waits for an incident/human-approved event with a 10-minute timeout before proceeding to remediation. |
| Remediate | Inngest step.run() |
Takes investigation results and applies fixes — rollback Vercel deployments, revert commits, create PRs, merge fixes. |
| Post-Mortem | Inngest step.run() |
Generates a structured post-mortem report via LLM and sends a Slack summary. |
If any step.run() fails, Inngest retries from that step — no re-execution of
prior stages. See apps/nextjs/inngest/processEvent.ts.
incident-agent/
├── apps/
│ ├── agents/ # LangGraph agent definitions
│ │ └── src/
│ │ ├── index.ts # Package exports
│ │ ├── workflow.ts # StateGraph assembly + edges
│ │ ├── state.ts # Annotation.Root state definition
│ │ ├── llm.ts # DeepSeek V4 Flash client
│ │ └── nodes/
│ │ ├── triage.ts
│ │ ├── investigate.ts
│ │ ├── remediate.ts
│ │ ├── postmortem.ts
│ │ └── human_escalation.ts
│ └── nextjs/ # Dashboard + API + Inngest
│ ├── app/
│ │ └── api/
│ │ ├── incidents/route.ts # POST — sends Inngest event
│ │ └── inngest/route.ts # Inngest serve handler
│ └── inngest/
│ ├── client.ts # Inngest client + event schemas
│ └── processEvent.ts # Durable pipeline definition
├── packages/
│ ├── shared/ # Types, schemas, constants
│ │ └── src/types.ts # Enums, interfaces, shared types
│ ├── integrations/ # External service clients
│ │ └── src/
│ │ ├── slack.ts # Slack webhook notifications
│ │ ├── github.ts # Octokit GitHub client
│ │ ├── vercel.ts # Vercel deployment API
│ │ ├── upstash.ts # Kafka producer/consumer
│ │ └── prometheus.ts # Prometheus query client
│ └── memory/ # Qdrant vector storage
├── docker-compose.yml
├── package.json # pnpm workspace root
└── pnpm-workspace.yaml
| Layer | Tool |
|---|---|
| LLM | DeepSeek V4 Flash (via OpenAI-compatible API) |
| Agents | LangGraph.js with checkpointer |
| Workflow | Inngest (serverless background jobs) |
| Backend | Next.js API routes |
| Database | Neon (serverless Postgres) |
| Vector Store | Qdrant Cloud |
| Event Bus | Upstash Kafka |
| Cache | Upstash Redis |
| Monitoring | Prometheus + Grafana |
| Notifications | Slack webhooks |
| Infra | Vercel (serverless deploy) |
| Package | pnpm workspaces |
- Node.js 18+
- pnpm
- Docker (for local Kafka/Redis)
pnpm installCreate .env in each app package:
# LLM
DEEPSEEK_API_KEY=
# Slack
SLACK_WEBHOOK_URL=
SLACK_ESCALATION_WEBHOOK_URL=
# GitHub
GITHUB_TOKEN=
GITHUB_OWNER=
GITHUB_REPO=
# Vercel
VERCEL_TOKEN=
VERCEL_TEAM_ID=
# Kafka
UPSTASH_KAFKA_URL=
UPSTASH_KAFKA_USERNAME=
UPSTASH_KAFKA_PASSWORD=
# Prometheus
PROMETHEUS_HOST=
# Qdrant
QDRANT_URL=
QDRANT_API_KEY=pnpm buildTerminal 1 — Next.js dev server:
pnpm devTerminal 2 — Inngest dev server (dashboard at localhost:8288):
npx inngest-cli@latest dev -u http://localhost:3000/api/inngestSend a test incident:
curl -X POST http://localhost:3000/api/incidents \
-H "Content-Type: application/json" \
-d '{"source":"test","title":"High latency","message":"p99 > 500ms","service":"api-gateway"}'The LangGraph state machine uses Annotation.Root with these channels:
{
incident: Incident, // Alert details, timeline, severity
status: IncidentStatus, // detected → triaged → investigating → remediated → resolved
investigationResult?: InvestigationResult, // Root cause, evidence, confidence
remediationResult?: RemediationResult, // Action taken, status
postMortem?: PostMortem, // Final report
}getRecentCommits(service, since)— List recent commits affecting a service pathgetCommitDiff(sha)— Get files changed in a commitcreateBranch(name, fromSha?)— Create a new branchcreatePR(head, base, title, body)— Open a pull requestmergePR(number, method)— Merge a PRcreateRevertPR(commitSha, baseBranch)— Create a revert PR for a bad commit
listDeployments(project)— List recent deploymentsrollbackDeployment(id)— Rollback to a previous deploymentcreateDeployment(project, ref)— Trigger a new deploy
sendAlert(incident)— Notify channel about new incidentsendEscalation(incident)— @here alert for P0/P1sendSummary(incident, postMortem)— Post resolution summary
query(promql)— Run a PromQL instant queryqueryRange(promql, start, end, step)— Range query
publish(event)— Publish an incident event to the alerts topic