Practice: Refund Approval
Pause for a manager.
Let's practise. Small refunds should go through automatically. Refunds over twenty pounds need a manager. One graph, with a branch, and an interrupt only on the risky path.

- Small refunds: automatic
- Large refunds: a manager
- Interrupt only when needed
Refunds with a threshold
The router sends small amounts to auto, and large amounts to manager, which calls interrupt. We try an eight pound refund, and a forty five pound one. Run it. The small refund completes immediately. The large one pauses, and finishes only after the manager approves.
from typing import TypedDict
from langgraph.checkpoint.memory import InMemorySaver
from langgraph.graph import StateGraph, START
from langgraph.types import Command, interrupt
class State(TypedDict):
amount: float
status: str
def manager(s):
ok = interrupt(f"Refund £{s['amount']}? approve/decline") == "approve"
return {"status": "refunded (manager)" if ok else "declined"}
b = StateGraph(State); b.add_node(manager); b.add_node("auto", lambda s: {"status": "refunded (auto)"})
b.add_conditional_edges(START, lambda s: "manager" if s["amount"] > 20 else "auto")
graph = b.compile(checkpointer=InMemorySaver())
for i, amount in enumerate([8.0, 45.0]):
cfg = {"configurable": {"thread_id": f"t{i}"}}
out = graph.invoke({"amount": amount}, cfg)
print(amount, out.get("status") or graph.invoke(Command(resume="approve"), cfg)["status"])8.0 refunded (auto) 45.0 refunded (manager)
What you practised
You combined a routing function, an interrupt on one branch, and a checkpointer. Only risky cases wait for a person. Try adding a third branch, that rejects refunds over two hundred pounds automatically.
| key | value |
|---|---|
| Route | by amount |
| Interrupt | only when risky |
| Resume | with a decision |
| Try | an auto-reject branch |
Summary
Route small cases automatically, and interrupt only for risky ones. Next, a quiz on human in the loop.
Key takeaways- Threshold routing
- Interrupt on one branch
- Resume to finish