Skip to content
Ashish.
All posts
Diagram illustrating the three multi-agent system topologies: Orchestrator, Handoff, and Swarm.
6 min readDevelopmentArchitects, ML EngineersFeatured#multi-agent#orchestrator#handoff#swarm#agent-coordination#ai-architecture

Multi-Agent Systems: Orchestrator, Handoff, and Swarm

Explore multi-agent system architectures including orchestrator-worker, handoff, and swarm patterns for effective agent coordination.

By Ashish KumarPart 5 of Building AI Agents

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

  1. Input Reception: The Orchestrator receives the user prompt.
  2. Decomposition: Using few-shot prompting or chain-of-thought reasoning, the Orchestrator breaks the request into sub-tasks.
  3. 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.
  4. 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

  1. Specialisation: Each agent is trained or prompted to excel in a narrow domain (e.g., BillingAgent, TechnicalSupportAgent).
  2. Evaluation: An agent processes the current context. It evaluates whether the current query falls within its domain.
  3. Transfer: If the agent determines it cannot resolve the request, it invokes a transfer tool that explicitly passes the conversation history and current state to a designated successor agent.
  4. 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

  1. Shared Memory: All agents read and write to a single, growing context window.
  2. Peer Selection: When an agent is invoked, it can choose to call another agent directly, rather than returning control to a central hub.
  3. 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.
  4. 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.

FeatureOrchestratorHandoffSwarm
Control FlowCentralisedSequential/RoutedDecentralised/P2P
Best ForComplex, multi-step workflows requiring strict planningDomain-specific queries with clear boundariesIterative refinement, collaborative creation
LatencyHigh (due to central processing)Medium (chain-dependent)Variable (can be low if parallel)
Fault ToleranceLow (Orchestrator failure breaks system)Medium (depends on chain length)High (redundant capabilities)
ComplexityHigh (planning logic)Low (simple routing)Medium (state management)

Recommendation

  1. 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).
  2. Use Handoff when you have distinct, siloed domains that rarely overlap (e.g., a helpdesk bot routing to IT, HR, or Sales).
  3. 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