Handoffs
Passing control.
In a handoff, there's no supervisor. The agent currently talking to the customer decides, this isn't my area, and passes control straight to a colleague. Like a shop assistant calling over the manager.

- No supervisor
- The agent decides
- Pass to a colleague
A front desk that hands off
The front desk node replies with structured output. An answer, and a handoff field, either none, or orders. If it hands off, a command goes to the orders agent. Otherwise, it answers and ends. Run it. A general question is answered at the front desk. An order question is handed to the orders specialist.
from typing import Literal
from pydantic import BaseModel
from langchain.chat_models import init_chat_model
from langgraph.graph import MessagesState, StateGraph, START, END
from langgraph.types import Command
from specialists import orders
class Desk(BaseModel):
answer: str
handoff: Literal["none", "orders"]
desk_model = init_chat_model("google_genai:gemini-flash-lite-latest", temperature=0).with_structured_output(Desk)
def front_desk(s: MessagesState) -> Command[Literal["orders", "__end__"]]:
d = desk_model.invoke([("system", "You run the Riverside Books front desk (open Sun 11am-4pm). Hand off order questions.")] + s["messages"])
return Command(goto="orders") if d.handoff == "orders" else Command(update={"messages": [("ai", d.answer)]}, goto=END)
b = StateGraph(MessagesState); b.add_node(front_desk); b.add_node("orders", orders); b.add_edge(START, "front_desk")
for q in ["What are your opening hours on Sunday?", "Has order RB-5678 shipped?"]:
out = b.compile().invoke({"messages": [{"role": "user", "content": q}]})
print(q, "->", out["messages"][-1].text.strip()[:90])What are your opening hours on Sunday? -> We are open on Sundays from 11 am to 4 pm. Has order RB-5678 shipped? -> Order RB-5678 has not shipped yet; it is currently being packed.
Also uses shop_tools.py
from langchain.tools import tool
BOOKS = {
"The Hobbit": {"stock": 7, "price": 8.99, "author": "J.R.R. Tolkien"},
"Dune": {"stock": 3, "price": 9.99, "author": "Frank Herbert"},
"Circe": {"stock": 0, "price": 10.99, "author": "Madeline Miller"},
}
@tool
def check_stock(title: str) -> int:
"""Copies of a book in stock at Riverside Books."""
return BOOKS.get(title, {}).get("stock", 0)
@tool
def get_price(title: str) -> float:
"""Price of a book in pounds."""
return BOOKS.get(title, {}).get("price", 0.0)
@tool
def get_author(title: str) -> str:
"""Author of a book."""
return BOOKS.get(title, {}).get("author", "unknown")Also uses specialists.py
from langchain.agents import create_agent
from langchain.tools import tool
from shop_tools import check_stock, get_price, get_author
@tool
def order_status(order_id: str) -> str:
"""Status of an order. Order ids look like RB-1234."""
return {"RB-1234": "shipped, arriving Thursday", "RB-5678": "being packed"}.get(order_id, "not found")
MODEL = "google_genai:gemini-flash-lite-latest"
books = create_agent(MODEL, tools=[check_stock, get_price, get_author], name="books",
system_prompt="You are the books specialist at Riverside Books. Be brief.")
orders = create_agent(MODEL, tools=[order_status], name="orders",
system_prompt="You are the orders specialist at Riverside Books. Be brief.")Handoffs vs supervisor
Handoffs feel natural, because the customer talks to one agent at a time, and control moves only when needed. A supervisor adds a routing step to every request, but keeps decisions in one place. Both use command to move control.
| key | value |
|---|---|
| Handoffs | agent decides |
| Supervisor | central routing |
| Both | use Command |
| Choose | by how work flows |
Summary
In a handoff, the active agent passes control directly to a colleague, using a command. Next, making each specialist really focused.
Key takeaways- Agent decides
- Command(goto=...)
- No central router