Handing work to another agent
One agent with twelve tools is hard to work on. Two agents, each with one job, are not.
The run helper here is the loop from lesson 6, printing who said what. It is not part of ADK.
The specialist
billing = LlmAgent(
name="billing",
description="Handles refunds and charges.",
model=PretendModel(replies=[say("I have started your refund.")]),
instruction="Handle billing questions.",
)An ordinary agent. The description is the field that matters here: it is what another agent reads when deciding whether this is the right place to send someone.
The one that routes
triage = LlmAgent(
name="triage",
description="Routes customers to the right team.",
model=PretendModel(replies=[call("transfer_to_agent", agent_name="billing")]),
instruction="Send the customer to the right team.",
sub_agents=[billing],
)sub_agents is the whole wiring. Nobody wrote a tool called transfer_to_agent: ADK adds it when an agent has sub agents.
await run(triage, "I was charged twice")The handover shows up on the event's actions, which is the field lesson 6 pointed at, and the last line comes from billing rather than triage.
Who answers the customer
The new agent does. A transfer is a handover, not a question, and the conversation continues with the agent that took it.
| Transfer to a sub agent | An agent used as a tool | |
|---|---|---|
| Who replies | The new agent | The original agent |
| Good for | A different kind of problem | A step you need the answer from |
| In ADK | sub_agents | AgentTool |
AgentTool wraps an agent so it can go in a tools list, and the caller stays in charge. Reach for it when you want an answer back rather than a handover.
Two fields control direction: disallow_transfer_to_parent and disallow_transfer_to_peers. They stop a specialist bouncing the conversation back up or sideways, which is worth setting once you have more than two agents.
- Give billing a poor description and see whether routing still works.
- Add a second specialist for technical questions and script the model to pick it.
Little by little, you're building something great.