logo_smallAxellero.io

Multi-Agent Orchestration

Patterns for coordinating multiple AI agents to handle complex tasks.

Multi-agent orchestration allows you to combine specialized agents to handle complex tasks that require different capabilities or expertise.

Why Multi-Agent?

Single agents work well for focused tasks, but complex scenarios often benefit from multiple specialized agents:

ScenarioSingle AgentMulti-Agent
Customer support with billing, tech, salesOne agent tries to do everythingSpecialists for each domain
Document processing pipelineOne prompt handles all stagesSeparate parse, analyze, summarize agents
Research with multiple sourcesOne agent manages all toolsDedicated searcher, analyzer, writer

Benefits of multi-agent:

  • Specialized prompts for each task
  • Clearer separation of concerns
  • Easier testing and debugging
  • Reusable agent components

Orchestration Patterns

Pattern 1: Router Pattern (Dynamic Handoff)

The AI agent decides which specialist to route to based on conversation context.

┌──────────────────────────────────────────────────────────┐
│                    ROUTER PATTERN                         │
├──────────────────────────────────────────────────────────┤
│                                                          │
│    ┌─────────┐                                           │
│    │  User   │                                           │
│    └────┬────┘                                           │
│         │                                                │
│         ▼                                                │
│    ┌─────────────┐                                       │
│    │   Router    │ ← General agent with handoff tools    │
│    │   Agent     │                                       │
│    └──────┬──────┘                                       │
│           │                                              │
│           │ AI decides based on context                  │
│           │                                              │
│     ┌─────┼─────┬─────────────┐                          │
│     ▼     ▼     ▼             ▼                          │
│  ┌─────┐ ┌─────┐ ┌─────┐ ┌─────────┐                     │
│  │Sales│ │Tech │ │Bill-│ │ Escalate│                     │
│  │Agent│ │Agent│ │ ing │ │ to Human│                     │
│  └─────┘ └─────┘ └─────┘ └─────────┘                     │
│                                                          │
└──────────────────────────────────────────────────────────┘

How it works:

  1. Router agent receives user message
  2. AI analyzes intent and context
  3. Calls _handoff_to_[agent] tool
  4. Target agent continues the conversation
  5. Conversation context is transferred

Configuration:

  • Connect target agents via Handoff connection (orange port)
  • Each handoff creates a tool the router can call
  • Set clear descriptions for each specialist

Example:

User: "I'd like to upgrade my subscription"

Router thinks: "This is about billing/subscription changes"
Router calls: _handoff_to_billing_agent

Billing Agent: "I can help you upgrade! What plan are you interested in?"

Pattern 2: Pipeline Pattern (Sequential Chaining)

Agents execute in a predefined sequence, each processing the output of the previous one.

┌──────────────────────────────────────────────────────────┐
│                    PIPELINE PATTERN                       │
├──────────────────────────────────────────────────────────┤
│                                                          │
│    ┌─────────┐                                           │
│    │  Input  │                                           │
│    └────┬────┘                                           │
│         │                                                │
│         ▼                                                │
│    ┌─────────────┐                                       │
│    │  Stage 1    │ Extract / Parse                       │
│    │   Agent     │                                       │
│    └──────┬──────┘                                       │
│           │ automatic                                    │
│           ▼                                              │
│    ┌─────────────┐                                       │
│    │  Stage 2    │ Analyze / Process                     │
│    │   Agent     │                                       │
│    └──────┬──────┘                                       │
│           │ automatic                                    │
│           ▼                                              │
│    ┌─────────────┐                                       │
│    │  Stage 3    │ Summarize / Output                    │
│    │   Agent     │                                       │
│    └──────┬──────┘                                       │
│           │                                              │
│           ▼                                              │
│    ┌─────────┐                                           │
│    │ Output  │                                           │
│    └─────────┘                                           │
│                                                          │
└──────────────────────────────────────────────────────────┘

How it works:

  1. First agent completes its task
  2. Output automatically passes to next agent
  3. Chain continues until final agent responds
  4. No AI decision-making on routing

Configuration:

  • Connect agents via Chaining connection (yellow port)
  • Set conditions for when chaining should occur
  • Use {{ctx.last_model_response}} to access previous output

Example:

Input: [Long document text]

Stage 1 (Parser): Extracts key sections, entities, dates
Stage 2 (Analyzer): Identifies themes, sentiment, risks
Stage 3 (Summarizer): Creates executive summary

Output: Structured report with summary

Pattern 3: Hierarchy Pattern (Sub-Agent Delegation)

A parent agent delegates specific subtasks to child agents and incorporates their results.

┌──────────────────────────────────────────────────────────┐
│                   HIERARCHY PATTERN                       │
├──────────────────────────────────────────────────────────┤
│                                                          │
│    ┌─────────────┐                                       │
│    │   Parent    │                                       │
│    │   Agent     │                                       │
│    └──────┬──────┘                                       │
│           │                                              │
│           │ Delegates subtask                            │
│           ▼                                              │
│    ┌─────────────┐                                       │
│    │  Sub-Agent  │ ← Another agentflow                   │
│    │   (Tool)    │                                       │
│    └──────┬──────┘                                       │
│           │                                              │
│           │ Returns result                               │
│           ▼                                              │
│    ┌─────────────┐                                       │
│    │   Parent    │ ← Continues with sub-agent result     │
│    │   Agent     │                                       │
│    └─────────────┘                                       │
│                                                          │
└──────────────────────────────────────────────────────────┘

How it works:

  1. Parent agent is working on a task
  2. Encounters a subtask requiring specialist
  3. Calls sub-agent as a tool
  4. Sub-agent executes and returns result
  5. Parent continues with the result

Use cases:

  • Reusable specialist agents
  • Complex nested workflows
  • Modular agent design

Comparison

AspectRouter PatternPipeline PatternHierarchy Pattern
RoutingAI-drivenPredefinedAI-driven
Control FlowDynamicSequentialNested
ConversationTransferredTransformedIsolated
Best ForCustomer routingPipelinesDelegation

Practical Examples

Customer Support System

                    ┌─────────────┐
                    │   Triage    │
                    │   Agent     │
                    └──────┬──────┘

            ┌──────────────┼──────────────┐
            │              │              │
            ▼              ▼              ▼
     ┌───────────┐  ┌───────────┐  ┌───────────┐
     │  Billing  │  │   Tech    │  │   Sales   │
     │  Agent    │  │  Support  │  │   Agent   │
     └───────────┘  └───────────┘  └───────────┘
  • Pattern: Handoff
  • Triage Agent: Understands intent, routes to specialist
  • Each Specialist: Has domain-specific tools and knowledge base

Document Analysis Pipeline

     Document → Parser → Analyzer → Reviewer → Report
  • Pattern: Chaining
  • Parser: Extracts structured data
  • Analyzer: Performs analysis
  • Reviewer: Checks quality, adds insights
  • Report: Formats final output

Research Assistant

     ┌─────────────────┐
     │ Research Agent  │
     └────────┬────────┘

    ┌─────────┼─────────┐
    ▼         ▼         ▼
┌───────┐ ┌───────┐ ┌───────┐
│Search │ │Analyze│ │ Write │
│Sub-Ag │ │Sub-Ag │ │Sub-Ag │
└───────┘ └───────┘ └───────┘
  • Pattern: Sub-Agent
  • Research Agent: Coordinates the research process
  • Sub-Agents: Specialized for search, analysis, writing

Best Practices

Design

  • Keep each agent focused on one responsibility
  • Use clear, specific system prompts
  • Document handoff conditions explicitly

Testing

  • Test each agent in isolation first
  • Test handoff scenarios with realistic conversations
  • Verify context is properly transferred

Monitoring

  • Track which agents handle which requests
  • Monitor handoff patterns for optimization
  • Review chains for bottlenecks

Performance

  • Minimize unnecessary handoffs (each adds latency)
  • Use chaining when sequence is known
  • Consider sub-agents for reusable components

Limitations

  • Each agent call adds latency and cost
  • Context size grows with chain length
  • Complex orchestrations are harder to debug

Start simple with a single agent. Add multi-agent orchestration when you have clear evidence that specialization will improve quality or maintainability.