Back to Learning Hub
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.

How do I build a LangGraph agent that resumes after a crash? architecture flow diagram

Packages

@langchain/langgraph@langchain/langgraph-checkpoint-postgrespg
Checkpoint & 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

ApproachStrengthsTradeoffs
LangGraph + PostgresSaverResumes mid-workflow after crashes, supports human approval interrupts, avoids duplicate writesRequires schema-typed state and checkpointer tables in PostgreSQL
In-Memory ReAct LoopMinimal boilerplate for prototypesProcess 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

Official Sources

Next Lesson
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.

Mugesh Rao
AI Engineer & Full Stack Engineer