Handoff Tool
The handoff tool enables seamless call transfers between assistants in a multi-agent system. This guide covers all configuration patterns and use cases.
Table of Contents
- Overview
- System Prompt Best Practices
- Basic Configuration
- Multiple Destinations
- Dynamic Handoffs
- Context Engineering
- Variable Extraction
- Custom Function Definitions
Overview
The handoff tool allows assistants to transfer calls to other assistants. Key features:
- Transfer to specific assistants by ID or name (in a Squad)
- Support for multiple destination options
- Dynamic destination determination via webhook
- Context manipulation during handoff
- Variable extraction from conversations for subsequent assistants to use
System Prompt Best Practices
When using the handoff tool, add this to your system prompt for optimal agent coordination: https://openai.github.io/openai-agents-python/ref/extensions/handoff_prompt/
Basic Configuration
1. Single Destination Handoff
Using Assistant ID
Using Assistant Name (for Squad Members)
Multiple Destinations
2.1 Multiple Tools Pattern (OpenAI Recommended)
Best for OpenAI models - creates separate tool definitions for each destination:
2.2 Single Tool Pattern (Anthropic Recommended)
Best for Anthropic models - single tool with multiple destination options:
Dynamic Handoffs
3.1 Basic Dynamic Handoff
The destination is determined at runtime via handoff-destination-request
webhook:
Your server must respond to this request with a single destination. You may pass assistantId
, assistantName
(if using squads), or a transient assistant
. For example:
If the handoff should not executed, either respond with an empty destination, or provide a custom error. The custom error will be added to the message history.
3.2 Dynamic Handoff with Custom Parameters
Pass additional context to your webhook for intelligent routing:
Context Engineering
Control what conversation history is passed to the next assistant:
All Messages (Default)
Last N Messages
No Context
Variable Extraction
Extract and pass structured data during handoff. Variables extracted by the handoff tool are available to all subsequent assistants in the conversation chain. When a handoff extracts a variable with the same name as an existing one, the new value replaces the previous value.
1. variableExtractionPlan
in destinations
This extraction method will make an OpenAI structured output request to extract variables. Use this method if you have multiple destinations, each with different variables that need to be extracted.
2. tool.function
We will also extract variables in the tool call parameters from the LLM tool call (in addition to sending these parameters to your server in a handoff-destination-request
in a dynamic handoff). Be sure to include the destination
parameter with the assistant names or IDs in enum
, as that is how Vapi determines where to handoff the call to. The destination
parameter will not be extracted as a variable. Also, remember to add destination
and all other variables that are required to the JsonSchema’s required
array.
Custom Function Definitions
Override the default function definition for more control. You can overwrite the function name for each tool to put into the system prompt or pass custom parameters in a dynamic handoff request.
Best Practices
- Clear Descriptions: Write specific, actionable descriptions for each destination in your sytem prompt. Use
tool.function.name
to customize the name of the function to put into your prompt. - Context Management: Use
lastNMessages
to limit context size for performance - Model Optimization: Use multiple tools for OpenAI, single tool for Anthropic
- Variable Extraction: Extract key data before handoff to maintain context
- Testing: Test handoff scenarios thoroughly, including edge cases
Troubleshooting
- Ensure assistant IDs are valid and accessible
- Verify webhook server URLs are reachable and return proper format
- Check that required parameters in custom functions match destinations
- Monitor context size to avoid token limits
- Test variable extraction schemas with sample data
- Validate that assistant names exist in the same squad
Last updated: August 2025 VAPI Documentation - Handoff Tool