When to reach for it
- Central control and traceability are essential.
- Multiple specialists must be coordinated.
- Tasks are dynamically delegated.
/pattern/supervisor/
A central agent dynamically decides which specialized agent or tool works next.
When to reach for it
When it backfires
The tradeoff
Clear operational control is maintained at the cost of a potential coordination bottleneck.
Every step starts and ends with the supervisor. Watch the dispatch: the supervisor chooses a specialist, the specialist returns, the supervisor decides whether to dispatch again or to answer.
from langgraph.graph import StateGraph, END
def supervisor(state):
# LLM picks the next agent by name — or "done"
choice = llm.choose_next(
history=state["messages"],
options=["shipping", "refunds", "tech", "done"],
)
return {"next": choice}
graph = StateGraph(State)
graph.add_node("supervisor", supervisor)
graph.add_node("shipping", shipping_agent)
graph.add_node("refunds", refunds_agent)
graph.add_node("tech", tech_agent)
graph.add_conditional_edges("supervisor",
lambda s: s["next"],
{"shipping": "shipping", "refunds": "refunds",
"tech": "tech", "done": END})
# Each specialist returns control to the supervisor:
for spec in ["shipping", "refunds", "tech"]:
graph.add_edge(spec, "supervisor")
graph.set_entry_point("supervisor")The supervisor accumulates tools, becomes the place where every prompt change lands, and ends up holding raw user data it doesn't need.
Fix · Keep the supervisor's prompt & toolset minimal. Specialists own their tools. Sensitive data stays inside the specialist's scope.
The supervisor sends to Shipping, gets a partial answer, sends to Shipping again, gets the same partial answer, and the loop never terminates.
Fix · Hard max_iterations. Schema-validate the supervisor's "next" output. Log every routing decision.
Refunds doesn't know what Shipping found because the supervisor summarised away the detail. Decisions are made on stale or wrong assumptions.
Fix · Pass structured state, not text summaries. Pydantic v2 schemas at every handoff. Keep raw facts inspectable.
Search patterns, frameworks, and pages.