"Require human approval before large transactions" is easy to say and easy to get wrong in practice — if the check is just a prompt instruction, there's no code-level guarantee the agent actually stops. LangGraph's interrupt() makes the pause a real, structural part of the graph: the run genuinely halts, state is saved, and nothing proceeds until a human's decision comes back in.
Implementing the safeguard
1. Identify the actual irreversible action. Not "the agent decided to transfer money" — the specific line of code that calls the transfer API. That's where the interrupt belongs.
2. Call interrupt() right before that action, passing the details a human needs to decide. The value you pass is what surfaces to whoever is reviewing — include the amount, recipient, and anything else relevant to the decision.
3. Resume execution with the human's decision via Command. Only after that resume does the node continue — and since LangGraph restarts the node from its beginning, keep any pre-interrupt logic idempotent.
# LangGraph node that pauses for human approval before a real transfer
from langgraph.types import interrupt, Command
def process_transaction(state):
amount = state["amount"]
if amount > 1000:
# Execution genuinely pauses here until a human responds
decision = interrupt({
"question": "Approve this transfer?",
"amount": amount,
"recipient": state["recipient"],
})
if not decision.get("approved"):
return {"status": "rejected"}
# Only reached after approval (or for amounts under the threshold)
execute_transfer(amount, state["recipient"])
return {"status": "completed"}
# Resuming after a human decision comes back:
# graph.invoke(Command(resume={"approved": True}), config=thread_config)
| Approach | Can the agent bypass it? |
|---|---|
| "Always ask for approval on large transfers" (prompt instruction) | Potentially, under the right conditions or a model error |
interrupt() before the transfer call |
No — execution structurally cannot proceed without a resume |
The reason this matters for "fail-safe" specifically: a prompt-level instruction is a request the model usually follows; a code-level interrupt() is a checkpoint the graph runtime enforces regardless of what the model generates.
Practical Challenge
Take one action your own agent workflow can perform that would be costly if wrong, and identify the exact line where an interrupt() call should sit — right before the action executes, not earlier in the reasoning chain.
Concept Check
interrupt() be called immediately before the irreversible action, rather than earlier in the agent's reasoning?Sources & Further Reading
- LangGraph Docs — Interrupts — official documentation for the
interrupt()andCommandmechanism used in this article.
AI