Checkpoints & human approval
A graph that saves its state after every step can stop, wait for a person, and carry on later exactly where it left off.
Checkpoints and threads
Compile a graph with a checkpointer and LangGraph saves the state after every step. Each conversation or job is a thread, named by the thread_id in the config: invoking again with the same ID continues that thread, a new ID starts fresh. The saved checkpoints also let you inspect, replay or branch from any earlier step.
Human in the loop
Inside a node, interrupt(value) stops the run and hands value to whoever called the graph: a question, a draft, a proposed tool call. Nothing is lost while a person thinks. Invoking the graph with Command(resume=answer) and the same thread ID restarts that node, and this time interrupt returns the answer.
from langgraph.types import interrupt, Command
from langgraph.checkpoint.memory import InMemorySaver
def approve(state: State) -> dict:
decision = interrupt({"draft": state["draft"], "question": "Send this email?"})
return {"approved": decision == "yes"}
graph = builder.compile(checkpointer=InMemorySaver())
config = {"configurable": {"thread_id": "ticket-7731"}}
graph.invoke({"request": "Reply to Lan about her refund"}, config) # pauses at approve
graph.invoke(Command(resume="yes"), config) # continues from thereA worked example
A support graph drafts a refund email for ticket 7731 and pauses. The operator sees the draft hours later, edits the amount and resumes with the edited text; the graph sends the corrected email. If the server restarts in between, a database-backed checkpointer still holds the paused state, so nothing has to be redone.
Easy to confuse
- Checkpoints are short-term memory for one thread; facts meant for every future conversation belong in a separate long-term store.
- The interrupted node runs again from its start when resumed, so put side effects after the interrupt, not before.
What does a checkpointer save?
After every step the state is written as a checkpoint under the thread ID, which is what makes pausing, resuming and inspecting past states possible.
A node calls interrupt("Send this email?"). What happens next?
interrupt pauses the run and surfaces its value. You resume by invoking the graph again with Command(resume=...) and the same thread_id.
When the run resumes, what runs again?
The node restarts from the top, and this time interrupt() returns the resume value. Code before the interrupt runs twice, so keep it free of side effects.
Read more in the books
- LangChain and LangGraph documentation, LangChain: LangGraph: Persistence and Interrupts.
- Learning LangChain, Mayo Oshin, Nuno Campos: the chapters on memory and human-in-the-loop.