Handoffs between agents
Instead of one boss, agents pass the conversation to whichever colleague is best placed to continue it.
Passing control
In the handoffs pattern each agent can decide that another one should take over. The handoff updates a state value, such as active_agent, often by returning Command(goto=..., update=...), and the graph routes the following turns to that agent. Agents talk to the user directly, so a conversation can move from triage to billing to technical support like a call being transferred.
from langgraph.types import Command
def triage(state: State) -> Command:
if "charged" in state["messages"][-1].content:
return Command(goto="billing", update={"active_agent": "billing"})
return Command(goto="support", update={"active_agent": "support"})
# each later user turn goes straight to the agent in state["active_agent"]
def route_turn(state: State) -> str:
return state.get("active_agent", "triage")
builder.add_conditional_edges(START, route_turn, ["triage", "billing", "support"])A worked example
“I was charged twice.” Triage sees a billing problem and hands off; billing finds the duplicate charge and confirms a refund. “Also the app crashes when I log in.” Billing recognises a technical issue and hands off to support, which asks for the app version. Each agent kept its own focused prompt and tools; the user saw one continuous conversation.
In practice
Handoffs suit multi-step, customer-facing flows where different stages need different expertise. Pass along a short summary when handing off so the next agent does not have to reread everything, and give every agent a way back to triage. Because only one agent works at a time, they do not parallelise well; use subagents or Send for that.
Easy to confuse
- A handoff transfers control; a subagent call returns control. That is the whole difference between the two patterns.
- Without checkpointing, the active agent is forgotten between turns; the state must persist across the conversation.
In the handoffs pattern, what decides which agent answers the user next?
A handoff updates the state, typically with Command(goto=..., update=...), and the graph routes the next turn to the agent named there.
How do handoffs differ from the subagents pattern?
With handoffs, control moves between agents and the active one speaks to the user. With subagents, a central agent keeps control.
What is a weakness of handoffs that the docs point out?
Only the active agent works, so handoffs suit multi-step conversations, not splitting a task across agents at once.
Read more in the books
- LangChain and LangGraph documentation, LangChain: LangChain: Multi-agent, the handoffs pattern.
- Artificial Intelligence: A Modern Approach (4th ed.), Russell, Norvig: Ch. 18, “Multiagent Decision Making”.