Skip to main content
Multi-agent patterns enable different types of collaboration between agents, from dynamic routing to fixed workflows to collaborative teams.
The user describes a task; handoffs, workflows, or teams pick the collaboration pattern.

Quick Start

1

Simple Handoffs

2

With Configuration

---Multi-agent patterns enable different types of collaboration between agents.
The user sends one request; the router agent chooses handoffs, workflows, or team patterns as needed.

Configuration Options

Handoff Configuration

Complete handoff configuration reference

Common Patterns

Pattern 1: Handoffs (LLM-Driven)

When to use: LLM decides which specialist agent to call based on the user’s request.

Pattern 2: Programmatic Handoffs

When to use: Your application code needs explicit control over which agent handles a task.

Pattern 3: AgentFlow (Sequential/Parallel)

When to use: Tasks follow a predictable sequence or can be executed in parallel.

Pattern 4: AgentTeam (Collaborative)

When to use: Multiple agents need to work together on the same problem.

Best Practices

Choose the right pattern for your use case:
  1. Start Simple: Use single agents first, add patterns as complexity grows
  2. LLM Routing: Use handoffs when the AI should decide the flow
  3. Deterministic: Use AgentFlow for predictable, repeatable processes
  4. Collaborative: Use AgentTeam when agents need to build on each other’s work
  5. Explicit Control: Use programmatic handoffs for error handling and conditionals
Optimize context sharing:
  • Use ContextPolicy.SUMMARY for most handoffs (safe default)
  • Use ContextPolicy.FULL only when complete history is essential
  • Set max_context_tokens to control costs and latency
  • Enable detect_cycles=True to prevent infinite loops
Handle common errors:
Optimize for your use case:
  • Handoffs: Best for dynamic routing (10-100ms overhead)
  • AgentFlow: Best for predictable pipelines (minimal overhead)
  • AgentTeam: Best for collaborative analysis (higher context cost)
  • Programmatic: Best for explicit control (lowest overhead)

Handoffs

LLM-driven agent routing

AgentFlow

Sequential and parallel workflows