DocsRuntimetoolsGenerateHandoffTools
Package: @hexos/runtime

Auto-generates handoff tools for an agent based on its canHandoffTo configuration.

For each target agent ID listed in canHandoffTo, creates a ToolDefinition named handoff_to_<targetId> that returns a HandoffResult when executed. The LLM uses these tools to route conversations to specialized agents in the multi-agent swarm pattern.

Only generates tools for target agents that exist in the allAgents registry. The tool description includes the target agent’s name and description to help the LLM make informed routing decisions.

Related: AgentRuntime calls this in getAgentTools(), isHandoffResult detects the returned marker, HandoffResult is the tool output type.

function generateHandoffTools(agent: AgentDefinition, allAgents: Map<string, AgentDefinition>): ToolDefinition[]

Parameters

agent

allAgents

MapAgentDefinition>