By Abhijith N M · Reviewed 24 October 2026 · Editorial standards
Some decisions should not be automated. A refund, a replacement, an address change — the model may propose them, but a person should approve them. LangGraph makes that a first-class control-flow feature instead of a polling loop around the agent.
interrupt(payload) is called inside a node. The runtime stops the run, saves a checkpoint and surfaces payload to the caller: invoke() returns with an __interrupt__ entry, get_state(config) shows the paused node in next, and nothing continues until the same thread is resumed with Command(resume=value). The human's answer becomes the return value of interrupt() on the re-run. This requires a checkpointer — a pause without saved state is just a crash.
The pattern is: a node proposes a write, the interrupt payload carries the exact action name and arguments, a human approves, edits or rejects it, and only then does an execution node run. The model never holds the trigger, and the approval record is written to the checkpoint history — which is exactly what an audit needs.
from typing import TypedDict
from langgraph.checkpoint.memory import InMemorySaver
from langgraph.graph import END, START, StateGraph
from langgraph.types import Command, interrupt
class RefundState(TypedDict):
order_id: str
amount: float
decision: str | None
refund_id: str | None
def approve_refund(state: RefundState) -> dict:
decision = interrupt(
{
"action": "issue_refund",
"order_id": state["order_id"],
"amount": state["amount"],
"question": "Approve this refund?",
}
)
return {"decision": decision}
def execute_refund(state: RefundState) -> dict:
if state["decision"] != "approved":
return {"refund_id": None}
return {"refund_id": f"RF-{state['order_id']}"}
builder = StateGraph(RefundState)
builder.add_node("approve_refund", approve_refund)
builder.add_node("execute_refund", execute_refund)
builder.add_edge(START, "approve_refund")
builder.add_edge("approve_refund", "execute_refund")
builder.add_edge("execute_refund", END)
graph = builder.compile(checkpointer=InMemorySaver())
config = {"configurable": {"thread_id": "ticket-4521"}}
paused = graph.invoke(
{"order_id": "4521", "amount": 84.0, "decision": None, "refund_id": None},
config,
)
print("__interrupt__" in paused)
print(graph.get_state(config).next)
resumed = graph.invoke(Command(resume="approved"), config)
print(resumed["decision"], resumed["refund_id"])graph.invoke(Command(resume=value), config) with the same thread_id.interrupt() returns the resume value instead of pausing.The fourth point is the one that bites. A node body before the interrupt runs twice: once before the pause and once on resume. Any side effect there — charging a card, sending an email, appending an audit row — must be idempotent or must happen after the interrupt. The clean shape is: interrupt first, then act on the answer.
Key takeaways
interrupt(payload) pauses a node, checkpoints the state and returns the payload to the caller.
Resume with Command(resume=value) on the same thread_id; the resume value becomes interrupt()'s return value.
Put side effects after the interrupt or make them idempotent — the node body before it runs again.
Approval needs validate-able payloads, idempotency keys, an expiry policy and an audit trail.
Written and edited by the nexGenCoders team. Spotted a mistake? Tell us and we will fix it.
Don't lose this lesson
Create a free account to save your progress, keep your streak, and work toward a shareable certificate.