AI Hints
Home›LangGraph Tutorial›Human in the Loop
LangGraph · Lesson 56 of 120

interrupt

Pausing a graph.

⏱ 2 min read▶ Video at 59:21🎓 Free
Watch this lesson in the LangGraph courseWatch on YouTube ↗Full LangGraph course

To pause a graph, call interrupt inside a node. The graph stops right there, and saves its state. Whatever you pass to interrupt is shown to the person, so they know what they're deciding.

interrupt
From the video: interrupt
  • Call interrupt in a node
  • The graph stops
  • Show what to decide

Pausing for a refund

The refund node calls interrupt, with the details a manager needs. The graph is compiled with a checkpointer, which interrupts require. Run it. Invoke returns early, and the result has an interrupt key holding our question. Get state shows the refund node is still waiting to finish.

interrupt.pypython
from typing import TypedDict
from langgraph.checkpoint.memory import InMemorySaver
from langgraph.graph import StateGraph, START
from langgraph.types import interrupt

class State(TypedDict):
    amount: float
    status: str

def refund(s):
    decision = interrupt({"question": f"Approve a refund of £{s['amount']}?"})
    return {"status": "refunded" if decision == "approve" else "declined"}

b = StateGraph(State); b.add_node(refund); b.add_edge(START, "refund")
graph = b.compile(checkpointer=InMemorySaver())
config = {"configurable": {"thread_id": "refund-1"}}
out = graph.invoke({"amount": 45.0}, config)
print(out["__interrupt__"][0].value)
print("waiting at:", graph.get_state(config).next)
Output
{'question': 'Approve a refund of £45.0?'}
waiting at: ('refund',)

About interrupt

Interrupt needs a checkpointer, and a thread ID. The value you pass should give the reviewer everything they need. When the graph resumes, the node runs again from the start, so keep work before the interrupt cheap, and safe to repeat.

keyvalue
Needscheckpointer + thread
Valuewhat to show
On resumenode reruns
Sokeep earlier work cheap

Summary

Interrupt pauses a node, saves the state, and shows a value to the reviewer. Next, resuming with their decision.

Key takeaways
  • interrupt(value)
  • Returns early
  • __interrupt__ in the result
Next up: Resuming — Command(resume)