Quick Start
How It Works
| Pattern | Use Case | Control | Example |
|---|---|---|---|
| Handoffs | Dynamic routing | LLM decides | Customer service triage |
| Programmatic | Explicit control | Code decides | Error handling workflow |
| AgentFlow | Fixed sequence | Predefined order | Data processing pipeline |
| AgentTeam | Collaboration | Shared context | Multi-expert analysis |
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.- Basic Handoff
- Advanced Config
Pattern 2: Programmatic Handoffs
When to use: Your application code needs explicit control over which agent handles a task.- Basic Programmatic
- Async Concurrent
Pattern 3: AgentFlow (Sequential/Parallel)
When to use: Tasks follow a predictable sequence or can be executed in parallel.- Sequential
- Parallel
Pattern 4: AgentTeam (Collaborative)
When to use: Multiple agents need to work together on the same problem.Best Practices
Pattern Selection
Pattern Selection
Choose the right pattern for your use case:
- Start Simple: Use single agents first, add patterns as complexity grows
- LLM Routing: Use handoffs when the AI should decide the flow
- Deterministic: Use AgentFlow for predictable, repeatable processes
- Collaborative: Use AgentTeam when agents need to build on each other’s work
- Explicit Control: Use programmatic handoffs for error handling and conditionals
Context Management
Context Management
Optimize context sharing:
- Use
ContextPolicy.SUMMARYfor most handoffs (safe default) - Use
ContextPolicy.FULLonly when complete history is essential - Set
max_context_tokensto control costs and latency - Enable
detect_cycles=Trueto prevent infinite loops
Error Handling
Error Handling
Handle common errors:
Performance Optimization
Performance Optimization
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)
Related
Handoffs
LLM-driven agent routing
AgentFlow
Sequential and parallel workflows

