Reliable AI agentsbuild Last tested 2026-11-27
How do I build a LangGraph agent that resumes after a crash?
Worked Answer
Attach a persistent checkpointer (PostgresSaver) with a deterministic thread_id, pause before side effects using interrupt(), and guard the final write with an idempotency key stored in graph state so retries never duplicate records.
Step through a document-review workflow, interrupt it for human approval, simulate a worker crash, and resume from a PostgreSQL checkpoint without duplicating the final write.
Prerequisites
Packages
@langchain/langgraph@langchain/langgraph-checkpoint-postgrespgCheckpoint & Crash-Recovery Simulator
Interactive Checkpoint & Crash-Recovery Simulator
Agent parses the document and saves checkpoint #1 to PostgreSQL.
{
"thread_id": "doc-review-4821",
"idempotencyKey": "write-contract-4821-v1",
"step": 1,
"status": "draft_ready",
"approved": false,
"writtenToDb": false
}Stateful Checkpointed Graph vs. Stateless ReAct Loop
| Approach | Strengths | Tradeoffs |
|---|---|---|
| LangGraph + PostgresSaver | Resumes mid-workflow after crashes, supports human approval interrupts, avoids duplicate writes | Requires schema-typed state and checkpointer tables in PostgreSQL |
| In-Memory ReAct Loop | Minimal boilerplate for prototypes | Process crash loses all intermediate work and risks repeating side-effecting tool calls |
Checkpoint
Your agent crashes right after sending an approved invoice API call, before saving the final step. What prevents a duplicate invoice when the worker resumes?
Production Evidence & Architecture Guides
Case Study
Grovio: Enterprise AI Marketing OS & Workflow Automation Platform
Read Case Study Case StudyJobXpert: Autonomous Lead Generation Agent That Works 24/7
Read Case Study Architecture ArticleThe 2026 Guide to Building Autonomous Agentic Applications with LangGraph
Read Article Architecture ArticleContext Engineering for AI Agents: Dynamic Memory, LangGraph State & Guardrails
Read ArticleOfficial Sources
When does hybrid search beat vector search for document Q&A?
Want this architecture built for your team?
Fixed-scope engineering sprints for databases, AI agents, and production retrieval.