Pick the LangGraph prebuilt that fits a workflow with no central router
create_swarm is the LangGraph prebuilt for peer-handoff topologies; agents transfer control directly via handoff tools and the runtime swaps the active agent without a central manager call per hop.
Imagine a relay race versus a meeting room. In the relay (swarm), each runner directly hands the baton to the next runner; no coach in the middle. In the meeting room (supervisor), every runner reports to the coach and the coach decides who runs next. Swarm is faster and cheaper when runners can decide handoffs themselves; supervisor is needed when the routing decision is hard and needs a manager. LangGraph ships create_swarm for the relay model and create_supervisor for the meeting-room model. The question is which one matches your workflow.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
LangGraph ships two main multi-agent topologies as prebuilts: create_supervisor and create_swarm. They embody opposite design philosophies. Supervisor is centralized: every hop, a single manager agent decides which worker runs next. Swarm is decentralized: agents are peers and hand off directly to each other via tool calls.
Picking the right one is not a stylistic choice; it is a cost, latency, and architecture decision. The question prompts a workflow with no central router, which rules supervisor out by definition. This walkthrough explains why swarm fits, what the trade-offs are versus supervisor, and how to think about the hybrid case where you actually need both.
Mental model: swarm is peer to peer with handoff tools; supervisor is centralized with a manager per hop. Name maps to topology; pick by who decides routing.
What create_swarm is
The primitive
create_swarm is a LangGraph helper that takes a list of agents (each defined as a create_react_agent or similar) and wires them together with handoff tools. A handoff tool has the shape:
def transfer_to_review_agent():
return Command(goto='review_agent')
When the currently active agent calls this tool, the runtime updates the active_agent field in shared state and routes the next graph step to the named agent. The shared state (messages, scratch, accumulated context) carries forward unchanged.
What the runtime is doing
- One agent is 'active' at any moment.
- On each step, the active agent runs an LLM call.
- If the LLM output includes a tool call to a handoff tool, the runtime processes the handoff (updates state, swaps active agent).
- If the LLM output is a regular tool call, the tool runs and the same agent continues.
- If the LLM output is a final answer, the run terminates.
No supervisor call per hop
In create_supervisor, every hop includes one supervisor LLM call (routing decision) plus one worker LLM call (work). In create_swarm, only the active agent's LLM call runs each hop; there is no separate supervisor turn. That is the cost savings.
Situations where this technique stops working.
2–4 min · Everything important, quickly.
Real products, models, and research that use this idea.
- OpenAI's Swarm framework popularised the peer-handoff pattern; LangGraph's create_swarm is the production-grade equivalent.
- OpenAI Agents SDK uses the same handoff-tool primitive for peer transfers, and there are migration guides from Swarm to Agents SDK.
What an interviewer would ask next. Try answering before peeking at the approach.
QHow would you implement allowed-target lists on handoff tools in a swarm?
Each agent registers only the handoff tools it is allowed to call; the agent definition imports only the relevant transfer functions. Alternatively, register all handoff tools but wrap each in a per-agent permission check that fails the call when the source agent is not in the allowed-source list. The first is cleaner; the second is more dynamic.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Reaching for create_supervisor by default because it sounds more structured, then paying a per-hop supervisor LLM call for routing decisions the workers could have made via handoff tools.
60 second bullets to scan on the way to the call.
What create_swarm is in LangGraph
What create_supervisor is and how it differs
Primary sources. Browse if you want the original framing.
Same topic, related formats. Practice these next.