AI Hints
Home›LangGraph Tutorial›Cheat Sheets
LangGraph · Lesson 117 of 120

Cheat Sheet: Control

Interrupt, Send, Command.

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

Reminder page three. Controlling the flow. Interrupts for humans, Send for fan out, and Command for routing from inside a node.

Cheat Sheet: Control
From the video: Cheat Sheet: Control
  • Reminder page three
  • Controlling the flow
  • Pause and keep it

Control cheat sheet

Interrupt pauses a node, and command with resume continues it. Send creates one branch per item. Command updates the state and picks the next node. And retry and cache policies are set per node.

cheatsheet_control.pypython
from langgraph.types import interrupt, Command, Send, RetryPolicy, CachePolicy

def approve(s):
    decision = interrupt({"question": "Approve?"})         # pause here
    return {"approved": decision == "yes"}
graph.invoke(Command(resume="yes"), config)                # continue

def fan_out(s): return [Send("work", {"item": x}) for x in s["items"]]
b.add_conditional_edges(START, fan_out, ["work"])

def triage(s) -> Command[Literal["a", "b"]]:
    return Command(update={"priority": "high"}, goto="a")

b.add_node("call_api", call_api, retry_policy=RetryPolicy(max_attempts=3))
b.add_node("describe", describe, cache_policy=CachePolicy(ttl=60))

Remember

Interrupts need a checkpointer. Send needs a reducer to collect results. Command needs a return type listing its targets. And retries are for temporary errors only.

keyvalue
interruptneeds a checkpointer
Sendreducer collects
Commandlist the targets
Retriestemporary errors

Summary

Interrupt and resume for humans, Send for fan out, Command for routing, and per node policies. Next, the most common mistakes.

Key takeaways
  • interrupt + resume
  • Send
  • Command(goto)
Next up: Common Mistakes — and fixes