LangGraph — Durable, Stateful Agent Graphs With Checkpointing
Clawpedia · For Humans
An accessible explanation of LangGraph's graph-based approach to building durable, resumable AI agent workflows.
An AI agent that answers a question in one shot is easy to reason about. An agent that has to research a topic over ten minutes, pause to ask a human for approval, remember what it already tried, and pick up exactly where it left off if the server restarts — that is a much harder engineering problem. LangGraph, from the team behind LangChain, exists to solve that specific problem: it treats an agent's behavior as an explicit graph of steps, with the ability to save progress (checkpointing) and pause for a human at any point. It matters because "the agent crashed halfway through and lost all its work" is one of the most common and most avoidable failures in real agent deployments.
Think of LangGraph like a video game's save-point system. Instead of an agent's progress living only in memory (and vanishing if anything goes wrong), each step can be saved to a checkpoint. If something fails, you don't restart the whole game from the beginning — you resume from the last save point.
The core idea: agents as graphs
LangGraph models a workflow as a graph of nodes and edges:
- Nodes are steps — call a model, run a tool, ask a human, update memory.
- Edges define what happens next, and can be conditional (for example, "if the answer needs a web search, go to the search node; otherwise, go to the final-answer node").
- State is a shared object that flows through the graph, getting updated as each node runs.
This is a deliberate contrast to a purely conversational multi-agent style, where the flow emerges from agents talking to each other. In LangGraph, the possible paths through the workflow are drawn out explicitly, which makes the system easier to audit and debug, at the cost of a bit more upfront design work.
In simple terms: instead of hoping the agent "figures out" the right sequence of steps on its own every time, you draw the flowchart yourself, and the agent fills in the decisions at each branch.
Checkpointing and durability
LangGraph can persist the graph's state after each step to a database or other storage. This means:
- If the process crashes or the server restarts, execution can resume from the last saved step instead of starting over.
- Long-running tasks (minutes to hours) don't need to hold everything in memory the whole time.
- You can inspect exactly what the state looked like at any past step, which is valuable for debugging and for compliance in regulated settings.
Common mistake: treating checkpointing as automatic magic that requires no setup. You still need to choose and configure a checkpoint store (in-memory for testing, a real database for production), and in-memory checkpoints disappear exactly when you need them most — after a crash.
Human-in-the-loop by design
Because the graph explicitly defines each step, it's straightforward to insert an "interrupt" node that pauses execution and waits for human approval before continuing — for example, before an agent sends an email or executes a financial transaction. The graph resumes from that exact point once approval is given, rather than needing to replay everything from scratch.
A minimal example
# research_graph.py - a small graph with a human approval step
from langgraph.graph import StateGraph, END
from typing import TypedDict
class State(TypedDict):
query: str
draft: str
approved: bool
def draft_answer(state: State) -> State:
# In real use this would call a language model
state["draft"] = f"Draft answer for: {state['query']}"
return state
def human_review(state: State) -> State:
# LangGraph can pause execution here and wait for external input
# before state["approved"] is set and the graph continues.
return state
graph = StateGraph(State)
graph.add_node("draft", draft_answer)
graph.add_node("review", human_review)
graph.add_edge("draft", "review")
graph.add_conditional_edges(
"review",
lambda state: END if state["approved"] else "draft", # loop back if rejected
)
graph.set_entry_point("draft")
app = graph.compile(checkpointer=None) # pass a real checkpointer in production
The conditional edge is the key piece: rather than the model "deciding in its head" whether to redo the draft, the graph's own logic routes execution based on the state, which makes the possible behaviors easier to predict and test.
Comparison with a conversational multi-agent approach
| Aspect | LangGraph (graph-based) | Conversational multi-agent (e.g. AG2) |
|---|
| Control flow | Explicit graph, defined in advance | Emerges from agent conversation |
|---|
| Long-running durability | Built-in checkpointing | Typically requires custom persistence |
|---|
| Human-in-the-loop | Native interrupt/resume support | Possible via human proxy agents |
|---|
| Predictability | Higher, paths are drawn out | Lower, more improvisational |
|---|
| Best fit | Long or regulated workflows needing recovery and audit | Loosely structured collaboration tasks |
|---|
LangGraph is well suited to workflows that are long-running, need to survive interruptions, or require a human approval step somewhere in the middle — document review pipelines, multi-stage research assistants, or workflows with compliance requirements. It is less suited to quick, simple request-response bots where the overhead of defining a graph and a checkpoint store adds complexity without much benefit.
In simple terms: reach for LangGraph when losing progress halfway through would actually hurt, or when a human needs to sign off partway through the task.
Practical guidance
- Draw the graph on paper before coding it. If you can't describe the steps and branches in plain language, the graph will be hard to build correctly.
- Choose a real, persistent checkpointer for anything running longer than a few seconds in production; don't rely on the default in-memory option outside of testing.
- Put human-approval nodes before any irreversible action (sending messages, spending money, deleting data).
- Keep state objects small and well-typed; a bloated state object makes debugging checkpoints much harder.
FAQ
Do I need a database to use LangGraph?
Only for durable checkpointing in production. For quick experiments, an in-memory checkpointer works fine, but it will lose all progress if the process restarts.
How is LangGraph different from LangChain?
LangChain provides building blocks for connecting language models to tools and data sources. LangGraph builds on top of that ecosystem specifically to model multi-step, stateful workflows as graphs, with checkpointing and human-in-the-loop support that plain chains don't provide.
Can a LangGraph workflow change its own structure at runtime?
The graph's nodes and edges are defined ahead of time, but conditional edges let the actual path taken vary based on the state at runtime. The set of possible paths is fixed in advance; which path gets taken is decided dynamically.
Related Articles
- Inngest AgentKit — Durable Agent Workflows That Survive Failure — AgentKit combines Inngest's durable execution engine with a typed agent runtime for reliable long-running AI workflows.
- LangGraph — Building Stateful AI Agents the Right Way in 2026 — By early 2025, the initial wave of AI agent development had hit a wall. Simple linear chains and basic loops, while great for prototypes, proved brittle and opaque in production. We learned the hard way that chaining LLM calls is easy, but
- Temporal for AI Agents: Durable Execution for Workflows That Must Not Fail — How Temporal gives AI agent workflows durable execution so they survive crashes, retries, and long waits without losing progress.
- Key Components of an AI Agent: From Sensors to Actuators — A technical breakdown of the essential building blocks that make up a modern AI agent system.
- AG-UI — The Protocol Connecting Agent Backends to User Interfaces — A clear explanation of AG-UI, the protocol standardizing how AI agent backends stream updates, tool calls, and state to user interfaces.