Human review
Pause a workflow for a person to approve, reject, or edit proposed output before downstream nodes continue.
AI Agents · Const
interrupt pauses a graph node and exposes a value to the caller. Re-invoking the graph with Command and a resume value makes that value available as interrupt's result.
Call interrupt inside a graph node to suspend execution and expose a payload to the caller. With persistence and a thread ID, re-invoke the graph using Command({ resume }); that resume value becomes the return value of interrupt. Avoid catching the interruption unless the special graph interruption is rethrown.
interrupt<R>(value: R): R| Name | Type | Description |
|---|---|---|
value | R | The value supplied to the caller when execution pauses; it must be JSON-serializable. |
The resume value provided when the graph is re-invoked with a Command.
import { Command, interrupt, MemorySaver, StateGraph, Annotation } from "@langchain/langgraph";
const State = Annotation.Root({ approved: Annotation<boolean | undefined>() });
const checkpointer = new MemorySaver();
const graph = new StateGraph(State)
.addNode("review", () => ({ approved: interrupt({ question: "Approve?" }) }))
.addEdge("__start__", "review")
.addEdge("review", "__end__")
.compile({ checkpointer });
const config = { configurable: { thread_id: "review-1" } };
await graph.invoke({}, config);
const result = await graph.invoke(new Command({ resume: true }), config);
console.log(result.approved);The node pauses with a JSON-serializable review payload, then resumes on the same thread when invoked with a Command containing the resume value.
Pause a workflow for a person to approve, reject, or edit proposed output before downstream nodes continue.
Stop execution while waiting for external information, then continue the same persisted run when the information arrives.
Insert several approval or input checkpoints into one node and handle each response in order.
interrupt pauses the current node by raising a special graph interruption when no resume value is available. The payload is surfaced to the caller, and a later Command resume value is returned from the interrupt call.
Follow-up: What happens if a resume value is already available? The function returns that value instead of raising a new interruption, allowing the node to continue.
The graph needs persistence through a checkpointer and a thread ID in its configuration. Resume by invoking the graph again with Command containing the resume value.
Follow-up: Why is the thread ID necessary? It identifies the persisted execution whose state should be continued.
Multiple interrupts may occur in one node, and LangGraph handles them sequentially. Each call can pause and later receive its corresponding resume value.
Follow-up: What design constraint follows from sequential handling? The node must preserve a stable interrupt call order across executions.
CommandGraphInterruptMemorySavercheckpointerthread_id