When to Use Handoffs
Splitting Work Between Agents → Give each part of a conversation its own agent with a focused prompt and only the tools it needs, such as triage, billing and scheduling. Compacting Long Conversations → An agent can hand off to itself, replacing a long conversation with a summary.Defining a Handoff
Handoffs are part of an agent’scallTemplate. This front desk agent hands billing questions to a billing agent. The model fills
in {{issue}} when it hands off, and {{customerName}} comes from the call’s templateContext.
The model sees each handoff as a tool. Handoffs aren’t tools in the API, though, so a call’s
toolOverrides don’t affect them.
Conversation History
conversationHistory sets what the target agent starts with. It takes one of these:
{"retain": true}→ Keep the whole conversation.segments→ Build the history from segments, in order. Each one is either asliceof the existing messages or atemplateof new messages. A slice works like a Python slice:{"start": -4}keeps the last four messages. Templated messages may use{{variables}}, and each one must set arole.
toolResultText if it’s set.
Template Variables
The target agent’s templates, such as its system prompt, are filled the same way as the templated history messages:- Variables the call’s
templateContexthas take their values from it. - The model generates the rest when it hands off. They appear to the model as the handoff tool’s parameters, using the types in the
target agent’s
contextSchema.
authTokens are different: the model never generates them, so they always come from the call’s
templateContext. The default contextSchema of an agent requires the variables that the auth tokens of every agent it can reach
through handoffs use. If you set contextSchema yourself, it must include them.
What Changes on a Handoff
A handoff starts a new call stage. These settings come from the target agent:systemPromptandtemperaturevoice,voiceOverridesorexternalVoicelanguageHintandtranscriptionSettingstimeExceededMessageandinactivityMessagesselectedToolsandhandoffssharedSecrets
model, medium, firstSpeakerSettings, maxDuration,
recordingEnabled, vadSettings and triggers.
Compacting a Conversation
A handoff to the agent itself continues the call with the same settings and a new conversation history. This one replaces the conversation with a summary the model writes, followed by the last four messages:Updating and Deleting Agents
A call continues with the agent revisions that were published when it started, however many times it hands off. Updating or deleting an agent doesn’t affect calls in progress. Publishing an agent also publishes a new revision of every agent that can reach it through handoffs, so new calls use the update right away. If one of those agents can’t be updated, for example because itscontextSchema lacks a variable that a tool auth
token of the updated agent uses, the request fails with a 409 that lists those agents, and nothing is published.
Deleting an agent that other agents hand off to fails with a 409 that lists those agents. Remove their handoffs first.