Interrupt and resume
interrupt() pauses the graph and exposes a JSON-serializable request to the caller. Resume the same checkpoint with Command(resume=...) and the same thread_id.1
Tiny example
Section titled “Tiny example”from langgraph.checkpoint.memory import InMemorySaverfrom langgraph.types import Command, interrupt
def approve_refund(state: RefundState) -> dict: approved = interrupt({"question": "Approve £450 refund?"}) return {"approved": bool(approved)}
graph = builder.compile(checkpointer=InMemorySaver())config = {"configurable": {"thread_id": "refund-104"}}
paused = graph.invoke({"amount": 450}, config)finished = graph.invoke(Command(resume=True), config)- Node calls
interrupt(). - LangGraph saves the pause through the checkpointer.
- The application shows the request to a reviewer.
- The application resumes the same thread.
- The resume value becomes the return value of
interrupt().
Failure note
Section titled “Failure note”On resume, LangGraph restarts the node from its beginning. Code before interrupt() runs again. Put side effects after approval, move them to another node, or make them idempotent. Do not wrap interrupt() in a broad try/except; it uses a special exception to reach the runtime.
Related
Section titled “Related”Footnotes
Section titled “Footnotes”-
LangChain, Interrupts. ↩