LangGraph: State Graphs, Checkpoints and Interrupts
Understanding what problem a framework solves matters more than knowing its API. A common interview question: "What's the difference between a hand-written loop and LangGraph?"
Core concepts
| Concept | Meaning |
|---|---|
| State | The shared state flowing through the graph (usually a TypedDict / Pydantic model) |
| Node | A function that reads state and returns an update to it |
| Edge / conditional edge | Determines the next node; a conditional edge picks a branch based on state and can form a loop (the agent loop) |
| Checkpointer | Persists state after every step, keyed by thread_id per conversation |
interrupt() | Pauses graph execution inside a node and waits for external input (human approval) |
Command(resume=...) | Resumes execution; the resume value becomes the return value of interrupt() |
How it works: which pain points of a hand-written loop it solves
- Resuming after failure: every step is checkpointed, so after a process restart it can continue from the last state.
- Human intervention:
interrupt()saves the current state and suspends; after a human acts, resume with the samethread_id. - Observability: every change to state is recorded, which makes replay easy.
The official docs stress that interrupt requires a checkpointer, and that production should use a persistent checkpointer (such as Postgres) rather than the in-memory one.
One semantic to watch out for
When execution resumes, the interrupted node re-runs from the beginning, so the code before interrupt() runs again. Don't put side effects (sending email, writing to external systems) before interrupt(), or make sure they are idempotent.
In practice: an approval node
python
from typing import TypedDict
from langgraph.graph import StateGraph, START, END
from langgraph.types import interrupt, Command
from langgraph.checkpoint.memory import InMemorySaver # use a Postgres checkpointer in production
class S(TypedDict):
draft: dict
approved: bool
def extract(state: S):
return {"draft": {"amount": 120000, "payment_days": 120}}
def human_review(state: S):
decision = interrupt({"question": "Payment term > 90 days. Approve?", "draft": state["draft"]})
return {"approved": decision["approved"], "draft": decision.get("draft", state["draft"])}
g = StateGraph(S)
g.add_node("extract", extract)
g.add_node("human_review", human_review)
g.add_edge(START, "extract")
g.add_edge("extract", "human_review")
g.add_edge("human_review", END)
app = g.compile(checkpointer=InMemorySaver())
cfg = {"configurable": {"thread_id": "task-42"}}
app.invoke({"draft": {}, "approved": False}, cfg) # runs until it pauses at interrupt
# ... after the reviewer acts in the frontend:
app.invoke(Command(resume={"approved": True}), cfg) # resumes from where it pausedCommon pitfalls
- Shipping the in-memory checkpointer to production: every suspended task is lost when the process restarts.
- Side effects before interrupt: they run again on resume.
- Poor thread_id design: it should map to a business entity (such as a task ID), so the frontend can find tasks awaiting approval.
- The API changes fast: LangGraph iterates frequently, so follow the current official docs for example code.
Common interview questions
- What problem does LangGraph's checkpoint mechanism solve?
- When
interrupt()resumes, where does the node start executing? What does that require of your code? - What are the trade-offs between a hand-written agent loop and LangGraph?
- Both LangGraph and Temporal can "pause and wait for a human". What's the difference? (See Temporal)
How it relates to my projects
- Browser Automation Agent: uses interrupt to wait for human confirmation before high-risk actions.
To be verified / may go stale
- The import paths above (
langgraph.types,langgraph.checkpoint.memory) follow the official docs as of 2026-11. LangGraph releases often, so check against the current docs before use.
Sources
- LangGraph Docs: Interrupts —
interrupt(),Command(resume=...), checkpointer required, thread_id - LangGraph Docs: Persistence — checkpointers and threads
- LangGraph Docs: Graph API — State, Node, Edge
