Customer Support Escalation with Handoffs
This example demonstrates how to configure an agent with handoff agents — pre-defined specialist agents that the main agent can delegate to when a task requires specific expertise.What This Example Shows
- Defining handoff agents inline within the
agent_config - How the main agent decides when to hand off to a specialist
- Nested agent specifications with independent configurations
- Using handoffs through the
/v1/agent/completionsendpoint
How Handoffs Work
Unlike sub-agent delegation where agents are created dynamically at runtime, handoffs are pre-defined in your request. You specify the specialist agents upfront, and the main agent can route tasks to them as needed.Step 1: Setup
Step 2: Define the Agent with Handoffs
The main agent gets ahandoffs array containing fully configured specialist agents:
Step 3: Run It
- Support-Triage-Agent receives the query and identifies it as a technical issue
- Hands off to Technical-Support-Agent
- Technical-Support-Agent provides debugging steps for the rate limit error
Step 4: Test Different Routes
Each handoff agent is a fully independent agent with its own model, system prompt, and configuration. The main agent decides which specialist to route to based on the task content.
Next Steps
- Agent Completions Reference — Full agent configuration parameters including
handoffs - Sub-Agent Delegation — Dynamic agent creation at runtime (vs pre-defined handoffs)
- HierarchicalSwarm — Multi-level agent coordination via the swarm endpoint