Source: ADK agent transfer (adk-python source and LlmAgent docs)
How Google ADK implements transfer_to_agent: an enum-constrained transfer tool, target selection from parent/peers/sub-agents, and the injected transfer instructions.
Contents
- What: open-source code (
src/google/adk/tools/transfer_to_agent_tool.py,src/google/adk/flows/llm_flows/extensions/_agent_transfer.py) and the LlmAgent docs page - Author: Google
- Date:
mainbranch read 2026-11-14 (ADK 2.x) - Original: transfer_to_agent_tool.py, _agent_transfer.py, LlmAgent docs
Summary
In ADK, an LLM agent transfers control by calling transfer_to_agent(agent_name, ...). The function does no work itself; it sets transfer_to_agent on the tool context’s actions and the runtime switches agents. A request processor decides which agents are valid targets and injects both the tool and instructions describing those targets.
Key claims
TransferToAgentToolconstrainsagent_namewith a JSON Schema enum of valid targets, which the code says prevents hallucinated agent names; an optionaltransfer_reasonargument can be included.- Valid targets: the agent’s sub-agents, its parent unless
disallow_transfer_to_parent, and its peers unlessdisallow_transfer_to_peers. Sub-agents intaskorsingle_turnmode are excluded, since they are invoked as delegated tasks instead. - The injected instruction lists target agents with their descriptions, tells the model to answer itself if it is the best fit, otherwise call the transfer tool without other text, and to transfer to the parent if no one fits.
- The docs say
descriptionis mainly read by other agents to decide routing, so it should distinguish an agent from its peers. AgentToolwraps an agent as a tool; in Python the docs prefermode='single_turn'sub-agents, which ADK exposes as tools automatically. In Go v2.0.0,ModeChatagents are reachable from peers viatransfer_to_agent.