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:
| Scenario | Single Agent | Multi-Agent |
|---|---|---|
| Customer support with billing, tech, sales | One agent tries to do everything | Specialists for each domain |
| Document processing pipeline | One prompt handles all stages | Separate parse, analyze, summarize agents |
| Research with multiple sources | One agent manages all tools | Dedicated 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:
- Router agent receives user message
- AI analyzes intent and context
- Calls
_handoff_to_[agent]tool - Target agent continues the conversation
- 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:
- First agent completes its task
- Output automatically passes to next agent
- Chain continues until final agent responds
- 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 summaryPattern 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:
- Parent agent is working on a task
- Encounters a subtask requiring specialist
- Calls sub-agent as a tool
- Sub-agent executes and returns result
- Parent continues with the result
Use cases:
- Reusable specialist agents
- Complex nested workflows
- Modular agent design
Comparison
| Aspect | Router Pattern | Pipeline Pattern | Hierarchy Pattern |
|---|---|---|---|
| Routing | AI-driven | Predefined | AI-driven |
| Control Flow | Dynamic | Sequential | Nested |
| Conversation | Transferred | Transformed | Isolated |
| Best For | Customer routing | Pipelines | Delegation |
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.