|
|
ADK Multi-Agent Systems
Author: Venkata Sudhakar
In ADK, an agent can use other agents as tools - this is the multi-agent pattern. A coordinator agent receives the user request, reasons about what needs to be done, and delegates subtasks to specialised sub-agents. Unlike SequentialAgent where the order is fixed in code, the coordinator decides dynamically which agents to call based on the conversation context. This gives you the flexibility of dynamic routing combined with the specialisation benefits of dedicated agents - each sub-agent is an expert in its domain and the coordinator orchestrates them intelligently without hard-coded routing logic. In ADK you expose sub-agents to a coordinator using AgentTool. The coordinator sees each sub-agent as a callable tool with a description. It calls them by passing a query string, the sub-agent processes it with its own tools and instructions, and returns a response. The coordinator then decides whether to call another agent or provide a final answer. This nesting can go multiple levels deep for complex enterprise workflows - coordinators can call other coordinators, building a hierarchy that mirrors your organisational structure. The below example builds an HR onboarding system: a coordinator routes new employee queries to three specialist agents - one for HR policies, one for IT system access, and one for desk and equipment assignments - delegating dynamically based on what the employee asks.
Running three different onboarding queries through the coordinator,
It gives the following output showing the coordinator routing to the right specialist,
Q1: What is the leave policy for new employees?
[Coordinator routes to: hr_policy_agent]
Welcome! Our leave policy gives you 18 days Earned Leave, 12 days Casual Leave,
and 12 Sick Leave days per year - a total of 42 days. You apply through the
HR portal with at least 3 days notice for planned leave. Is there anything
else about your benefits you would like to know?
Q2: I need access to Jira and GitHub. My employee ID is EMP-8821.
[Coordinator routes to: it_provisioning_agent x2]
Your Jira access has been provisioned and will be active within 1 hour.
For GitHub, manager approval is required first - your access will be
activated within 2-4 hours of your manager approving the request. You
will get an email confirmation for both. Welcome aboard!
Q3: Joining Engineering team as EMP-8821. What desk, equipment, and annual leave?
[Coordinator routes to: facilities_agent AND hr_policy_agent]
Here is everything you need to know:
DESK: EN-821 on the 3rd Floor, Tech Bay B zone.
EQUIPMENT: Dell XPS 15 laptop, 27-inch monitor, and a standing desk.
LEAVE: 42 days total (18 EL + 12 CL + 12 SL) applied via HR portal.
You are all set - welcome to the Engineering team!
# Q3: Coordinator autonomously called TWO specialist agents from one query
# No routing rules written - Gemini decided from the instruction which agents to use
Multi-agent systems with AgentTool are ideal when you have genuinely different domains of expertise that benefit from separate tools, instructions, and reasoning contexts. The coordinator instruction is the most important piece - describe each sub-agent clearly so the coordinator knows when to use it. Test edge cases: what does the coordinator do when a query spans all three agents? Does it call all three? Test with five to ten realistic queries before deployment. For production, add logging inside each tool and sub-agent to build an audit trail of every delegation decision and sub-agent response.
|
|