$ man agent-patterns

ORCHESTRATION PATTERNS

How AI agents coordinate in multi-agent systems.

5 patterns documented

Hierarchical

A manager agent delegates subtasks to specialized worker agents and aggregates their results. The manager controls planning, task decomposition, and final synthesis. Workers operate independently and report back to the manager.

hierarchical-pattern
text
      [Manager]
      /   |   \
     /    |    \
    v     v     v
 [Worker] [Worker] [Worker]
    A        B        C
Use cases:
  • Complex projects requiring task decomposition and coordination
  • Research pipelines where a lead agent assigns analysis tasks
  • Customer support escalation workflows
  • Content creation with editor-writer hierarchies
Pros
  • Clear chain of command and accountability
  • Manager can re-plan dynamically based on worker outputs
  • Workers can be specialized and independently developed
Cons
  • Manager is a single point of failure
  • Can be slower due to sequential manager-worker communication
  • Manager context window can become a bottleneck

Sequential

Agents execute in a fixed pipeline order, each passing its output as input to the next. The chain processes data through a series of transformation or analysis stages, similar to a Unix pipeline.

sequential-pattern
text
  [Agent A] --> [Agent B] --> [Agent C] --> [Agent D]
   (input)     (transform)   (analyze)    (output)
Use cases:
  • Data processing pipelines (extract, transform, load)
  • Content pipelines: research -> draft -> edit -> publish
  • Code review chains: lint -> security scan -> style check
  • Document processing: parse -> summarize -> translate
Pros
  • Simple to understand, debug, and monitor
  • Each stage can be independently tested and swapped
  • Predictable execution order and resource usage
Cons
  • No parallelism — total latency is sum of all stages
  • Failure in one stage blocks the entire pipeline
  • Rigid structure makes dynamic re-routing difficult

Swarm

Peer-to-peer agent coordination where agents hand off tasks to each other dynamically based on context. There is no central controller — agents decide when to transfer control to a more appropriate peer, enabling emergent collaborative behavior.

swarm-pattern
text
  [Agent A] <--> [Agent B]
      ^  \          ^
      |   \        /
      v    v      v
  [Agent D] <--> [Agent C]
Use cases:
  • Customer service with specialist handoffs (billing, tech, sales)
  • Multi-domain problem solving requiring diverse expertise
  • Collaborative coding with specialized language agents
  • Adaptive workflows where the path depends on content
Pros
  • Highly flexible and adaptive routing
  • No single point of failure
  • Agents self-organize based on task requirements
Cons
  • Harder to debug and trace execution paths
  • Risk of infinite loops between agents
  • Emergent behavior can be unpredictable

Router

A central router agent classifies incoming requests and dispatches them to the most appropriate specialist agent. The router acts as an intelligent switchboard, analyzing the task and selecting the best handler without performing the work itself.

router-pattern
text
            [Router]
           /   |   \
          v    v    v
  [Specialist] [Specialist] [Specialist]
     Code        Data         Writing
Use cases:
  • API gateways that route to domain-specific agents
  • Help desks that triage and assign to specialist teams
  • Multi-model routing based on task complexity or type
  • Tool selection based on input classification
Pros
  • Clean separation of routing logic from execution
  • Easy to add new specialists without changing routing logic
  • Can incorporate cost/latency optimization in routing decisions
Cons
  • Router must understand all specialist capabilities
  • Classification errors send tasks to wrong specialists
  • Single-hop dispatch — no multi-step collaboration

Debate

Multiple agents independently analyze a problem and then critique each other's outputs through structured argumentation. A judge or consensus mechanism selects or synthesizes the best answer. This adversarial approach improves output quality through diverse perspectives.

debate-pattern
text
  [Agent A]   [Agent B]
      \           /
       v         v
      [  Debate  ]
       \       /
        v     v
       [Judge]
Use cases:
  • High-stakes decisions requiring multiple perspectives
  • Code review with competing analysis approaches
  • Legal or policy analysis with adversarial argumentation
  • Fact-checking and claim verification
Supported by:
Pros
  • Produces higher-quality outputs through adversarial pressure
  • Surfaces edge cases and counterarguments
  • Reduces single-agent bias and hallucination
Cons
  • High token usage — multiple full analyses plus debate rounds
  • Slower due to multiple rounds of generation
  • May produce deadlocks when agents strongly disagree
total 5 orchestration patterns