handoff operation is for: one operation inside a
tool’s operation tree that moves the conversation to
another agent. It is still agent → agent; reaching a person is a
transfer.
When the model should pick the desk from what the caller wants, put the
destinations on the agent’s own
handoffs field instead.
That is one line per edge; this is a tool with a lifecycle, a version and a
publish step.When the tree should decide
The two live side by side on one agent. A front desk can route by intent through
its
handoffs and carry an escalation tool that routes by tier.
The mechanics
The operation’s full field reference is on the handoff operation. What matters for this pattern:- It is terminal in its chain. Nothing may follow it in the top-level list
or in a
then/elsebranch, and branches do not rejoin. Anything the tool must do first — logging the routing decision, stampinguserdata— goes before it. - Name exactly one target.
target_agent_idis a stored agent and must already be published — publishing the tool fails otherwise.agent_nameresolves against the team defined on the call, which cannot be checked when the tool is published, so it publishes with a warning instead. context: "summary"needs asummary, and it is a value rather than a request. This tree runs after the model’s tool call, so there is no argument being written at that moment to take one from. Point it at where the text comes from:{{args.summary}}— a property on this tool’s ownjson_schemathat the model filled — or{{tooldata.brief}}published by an earlierhttporcodeoperation, or fixed prose. There is no second LLM call either way. Asummaryunder any other context is an error.recent_turnsworks exactly as it does on ahandoffsentry: the tail that crosses verbatim, defaulting to two turns undersummaryand none undernone, and refused undertranscript. See context policies.messageis said while the target loads, queued before the target is built, exactly as the config field’s is.- The cap is shared. Both kinds of handoff count against the same limit of 25 on one call.
A complete tool
A support line that escalates. The tool looks the caller’s account up by the number they called from, and hands enterprise accounts to their own desk; everyone else stays with the agent that called it.tools and publish the agent. Three things about
that tree are worth naming:
CRM_API_KEYmust already exist as a workspace secret, and the credential belongs there rather than in an argument the model wrote.- The
ifis terminal, so both outcomes are complete inside their own branch. Theelseis what stops the tool from returning nothing on the common path. {{system_vars.human_phone_number}}is empty on a web call and on text — it is the number on a phone call. On any other channel, look the account up by something the session actually carries, such as{{userdata.account_id}}.
Routing before the agent speaks
Ahandoff operation is also legal in an
on_enter hook, which is how you route a caller
before anyone says anything: the hook looks the number up and hands the call
straight to the right desk, and the agent that answered never speaks. (A
transfer is refused in a hook, for reasons specific to transfers.)
Keep the lookup fast if you do this. The hook runs before the greeting, so its
latency is silence on the caller’s ear.
Next
The handoff operation
Every field on the operation, in reference form.
Context policies
What
context and recent_turns mean for the target.Patterns
This pattern in the context of a whole multi-agent design.