
Multi-Agent Systems: Orchestrator, Handoff, and Swarm
Explore multi-agent system architectures including orchestrator-worker, handoff, and swarm patterns for effective agent coordination.
As Large Language Models (LLMs) move from single-turn chatbots to autonomous agents capable of executing complex workflows, the architectural challenge shifts from prompt engineering to system orchestration. An agent is no longer just a stateless function; it is a node in a graph. The efficiency, reliability, and cost of these systems depend entirely on how nodes communicate. This evolution demands careful selection of coordination patterns that balance control, latency, and fault tolerance.
There is no universal "best" architecture. Instead, there are three primary topologies for agent coordination: Orchestrator, Handoff, and Swarm. Each represents a different distribution of control and data flow. Understanding the mechanism behind each pattern allows architects to select the right topology for their specific latency, cost, and complexity constraints.
The Orchestrator-Worker Pattern
The Orchestrator pattern is the most common starting point for multi-agent systems. It operates on a hub-and-spoke model where a central "Orchestrator" agent holds the global context and makes all routing decisions.
Mechanism
- Input Reception: The Orchestrator receives the user prompt.
- Decomposition: Using few-shot prompting or chain-of-thought reasoning, the Orchestrator breaks the request into sub-tasks.
- Dispatch: The Orchestrator invokes specific "Worker" agents. Workers can be:
- Sequential: Worker A finishes, then Worker B starts (using A's output as input).
- Parallel: Multiple Workers run simultaneously, and the Orchestrator aggregates results.
- Aggregation: The Orchestrator synthesises the final response from the workers' outputs.
Technical Implementation
In practice, this looks like a central loop managing a list of pending tasks. Consider a code generation task using Python pseudocode with a hypothetical agent framework:
class Orchestrator:
def process(self, user_request):
# 1. Decompose
plan = self.llm.generate_plan(user_request)
# 2. Dispatch
results = []
for task in plan.steps:
if task.type == "SEARCH":
results.append(search_agent.execute(task.query))
elif task.type == "CODE":
results.append(code_agent.execute(task.code_snippet))
# 3. Aggregate
return self.llm.synthesize(results)Trade-offs
The Orchestrator pattern ensures high coherence because one entity controls the narrative. However, it introduces a single point of failure. If the Orchestrator hallucinates the plan, all downstream workers fail. Additionally, the Orchestrator must maintain the full context of all intermediate steps, which can exhaust context windows and increase latency due to the "middleman" overhead.
The Handoff Pattern
The Handoff pattern, often seen in customer service bots or complex debugging tools, is a sequential, stateful routing model. Unlike the Orchestrator, there is no central planner dictating the entire workflow upfront. Instead, agents pass control to one another based on specific conditions.
Mechanism
- Specialisation: Each agent is trained or prompted to excel in a narrow domain (e.g.,
BillingAgent,TechnicalSupportAgent). - Evaluation: An agent processes the current context. It evaluates whether the current query falls within its domain.
- Transfer: If the agent determines it cannot resolve the request, it invokes a
transfertool that explicitly passes the conversation history and current state to a designated successor agent. - Termination: The process ends when an agent determines it has resolved the issue.
Technical Implementation
This pattern relies on explicit state transitions. In frameworks like LangChain or OpenAI's Assistants API, this is often implemented via tool calling where a specific tool triggers a system-level switch.
// Example of an agent deciding to hand off
{
"content": "I cannot process this financial transaction. Transferring to billing.",
"tool_calls": [
{
"id": "handoff_1",
"function": {
"name": "transfer_to_billing",
"arguments": "{\"reason\": \"insufficient_context_for_payment\"}"
}
}
]
}Trade-offs
Handoff offers better modularity and cost efficiency because generalist models don't need to be prompted for every niche capability. However, it lacks global optimisation. If the handoff chain is long, the cumulative latency increases. Furthermore, "context drift" can occur if the handoff does not preserve critical historical context, leading to the new agent asking the user questions already answered.
The Swarm Pattern
The Swarm pattern, popularised by OpenAI's recent research, represents a decentralised approach. In a swarm, there is no single orchestrator. Instead, all agents have equal access to the shared conversation history (the "global state"). Any agent can act at any time.
Mechanism
- Shared Memory: All agents read and write to a single, growing context window.
- Peer Selection: When an agent is invoked, it can choose to call another agent directly, rather than returning control to a central hub.
- Collaborative Editing: Agents can modify the shared state. For example, Agent A might draft code, and Agent B might review and correct it, with both changes visible in the shared history.
- No Central Router: The "routing" is implicit. The user or a simple trigger invokes an agent, and that agent decides whom to talk to next.
Technical Implementation
In a swarm, the interaction graph is fully connected (or nearly so). The code structure is simpler but the logic is distributed.
# Simplified Swarm Interaction
def agent_a_work():
# Agent A works on the problem
result = agent_a.run()
# Agent A decides to ask Agent B for verification
return agent_b.run(context=result)
def agent_b_work():
# Agent B reviews and potentially modifies the result
return agent_b.review(agent_a_work())Trade-offs
Swarms are highly flexible and robust. If one agent fails, others can compensate. They excel at iterative refinement tasks (like coding or writing) where multiple perspectives improve the output. However, they are prone to infinite loops (Agent A asks B, B asks A, repeat) and conflicting edits if agents overwrite each other's work without version control or consensus mechanisms. Managing the context window size becomes critical, as every interaction adds tokens.
Synthesis: Choosing the Right Topology
Architects should select a pattern based on three factors: Task Structure, Latency Requirements, and Fault Tolerance. Effective multi agent coordination requires aligning these constraints with the appropriate topology.
| Feature | Orchestrator | Handoff | Swarm |
|---|---|---|---|
| Control Flow | Centralised | Sequential/Routed | Decentralised/P2P |
| Best For | Complex, multi-step workflows requiring strict planning | Domain-specific queries with clear boundaries | Iterative refinement, collaborative creation |
| Latency | High (due to central processing) | Medium (chain-dependent) | Variable (can be low if parallel) |
| Fault Tolerance | Low (Orchestrator failure breaks system) | Medium (depends on chain length) | High (redundant capabilities) |
| Complexity | High (planning logic) | Low (simple routing) | Medium (state management) |
Recommendation
- Use the orchestrator pattern when the task requires strict adherence to a business process or when the output must be highly consistent and structured (e.g., generating a financial report from multiple sources).
- Use Handoff when you have distinct, siloed domains that rarely overlap (e.g., a helpdesk bot routing to IT, HR, or Sales).
- Use Swarm when the task benefits from creative iteration or peer review (e.g., code generation, essay writing, or complex debugging where multiple agents can inspect the same artifact).
In production systems, hybrid approaches are common. An orchestrator worker setup might manage the high-level workflow, while a swarm of agents handles the iterative refinement of a specific sub-task. The key is to align the data flow topology with the cognitive load required by the agents to ensure robust agent coordination.
Conclusion
Choosing between Orchestrator, Handoff, and Swarm is not about finding the most advanced architecture, but the most appropriate one for your constraints. Orchestrators offer control and coherence at the cost of complexity and latency. Handoffs provide modularity and cost-efficiency but require careful state management. Swarms offer flexibility and robustness but demand robust consensus mechanisms to prevent chaos. By understanding these trade-offs, architects can build multi-agent systems that are not just intelligent, but reliable and scalable.
Related posts
Building a Deep Research Agent: Multi-Agent Guide
A technical walkthrough for ML engineers on constructing a multi-agent research system that handles synthesis and citations.
Context Compaction: Summaries, Scratchpads, and Handoffs
Explore context compaction techniques including summaries, scratchpads, and handoffs to optimize long running agents and reduce token costs.
Short-Term Memory: Summarization and Compaction
Explore how agents manage context through summarization and compaction techniques for efficient short-term memory.