Personal project
Incident Commander
A production alert comes in. Four specialist agents look into it at the same time. A planner writes a diagnosis and a ranked list of fixes. Before any risky step, the workflow pauses and waits for an engineer. Once they approve, it picks up exactly where it stopped. Built on LangGraph 1.0 from start to finish.
The problem
On-call work means making decisions with half the facts. An AI agent that can roll back production without asking a human is a risk, not a feature.
When a critical alert fires, an engineer has to pull together logs, metrics, recent deploys and runbooks, fast. A simple "one LLM call" assistant either guesses the cause, or worse, gets tools that can change production with no safe way to stop. Calling an LLM is the easy part. The real problem is coordinating several specialist agents, combining what they find, and stopping before anything risky, in a way that survives restarts and leaves an audit trail.
I wanted to use the parts of LangGraph that matter in production (subgraphs, custom reducers, pause and resume, saved checkpoints for each incident, streaming) in one real incident workflow, not a toy chat loop.
The approach
Incident Commander uses a supervisor and workers design. An alert arrives through the FastAPI API or a PagerDuty or Datadog webhook. The supervisor hands it to a group of agents that investigate in parallel. A planner then writes a diagnosis and ranked fixes. If the top fix is risky, an engineer has to approve it before anything runs.
- Parallel investigation. Four agents check logs, metrics, recent changes and runbooks at the same time. A custom reducer merges their findings, so no result overwrites another.
- Plan first, then ask. The planner returns a diagnosis, a confidence score and ranked fixes. If the top fix is risky (a rollback or a restart), the graph stops at
interrupt_beforeonhuman_approvaland waits. - Resume, don't start over.
PATCH /approve(or edit-plan) saves the approved fix withupdate_stateand runs the graph again. The checkpointer brings it back to exactly where it stopped. - Two ways in. People using the UI see live progress over SSE (
astream). Webhooks run in the background withainvoke, because no browser is watching. - Easy to swap tools. Logs, metrics, changes, runbooks and rollback all sit behind interfaces, with predictable fakes for tests. Datadog, Prometheus, ArgoCD or kubectl can plug in without changing any agent code.
Architecture
Key decisions
Ask before changing anything
Risky tools never run until an engineer says yes. The graph is built with interrupt_before=["human_approval"]. It saves its full state to the checkpointer and hands control back to the API. That is what separates a demo chatbot from something you could trust near production.
Safe merging when agents run in parallel
Four agents write their findings at the same moment. A typed state with an explicit merge function keeps every result, instead of letting the last write win. Any LangGraph graph needs this when subgraphs write to shared lists.
Checkpoints that survive restarts
Development uses MemorySaver. Production uses AsyncPostgresSaver through the same factory. Every run is tied to a thread_id, so an approval that comes after a restart still resumes the right incident.
Live updates for people, background runs for machines
The UI and the interactive API stream each step over SSE, so the on-call engineer can watch the investigation as it happens. Webhooks start ainvoke as a background task, so no connection is left waiting.
Agents never talk to vendors directly
Agents call LangChain tools that use interfaces, not vendor SDKs. Fakes keep unit and approval tests fast and fully offline. Moving to real infrastructure means changing one lookup, not rewriting prompts or the graph.
Engineering
The code is split into layers for the same reason the graph is. A shared core handles config, typed errors and logging with structlog. Agent nodes share prompt loading and JSON parsing. Graphs only connect nodes and edges. A FastAPI layer handles CRUD, approve, edit-plan, the SSE stream and webhooks. Unit tests cover supervisor routing, the planner and the executor with a mocked LLM, plus the fakes. Integration tests run the whole graph, including the pause, update_state and the resume. Pre-commit runs Ruff, and Docker Compose starts the API with Postgres checkpoints so you can test restarts.
Outcome
In 10 simulated incidents, it found the root cause in 8, with a first diagnosis in about 2 minutes.
- 4specialist agents investigating at the same time
- Humanapproval before every risky action
- 0steps repeated after approval: it resumes from the checkpoint
Stack
LangGraph 1.0LangChainFastAPISSEPostgres checkpointsLangSmithPydanticstructlogDocker ComposepytestRuff