Lab 15: Building Your First Multi-Agent Greeting Router
Goalβ
In this lab, you will build and run your first live Multi-Agent System (MAS) using ADK 2.0's sub_agents delegation pattern:
- A
router_agent(root_agent) whose sole job is to understand which language the user wants and transfer the conversation to the matching specialist. - Two domain specialists β
spanish_greeter_agentandjapanese_greeter_agentβ isolated in their own module (specialists.py) with crisp, non-overlappingdescriptionstrings.
Expected Behaviorβ
| User Prompt | Expected Flow |
|---|---|
"Can you greet me in Spanish?" | router_agent transfers to spanish_greeter_agent β replies warmly in Spanish ("Β‘Hola!..."). |
"Please greet me in Japanese." | router_agent transfers to japanese_greeter_agent β replies politely in Japanese. |
"Greet me in French!" | router_agent sees no matching specialist in sub_agents β politely explains French isn't supported yet. |
Step 1: Scaffold the Projectβ
Environment setup:
- 1-Click Launch (Browser): Open in GitHub CodespacesOpen in Google Cloud Shell
- Local machine: If you're continuing the course in sequence,
cdinto theadk-trainingproject you created in Module 2 and skip the block below -- your environment and dependencies already carry forward. If you're starting fresh at this module, create that project first:uv init adk-training --python 3.10 && cd adk-training
uv add "google-adk>=2.1.0" python-dotenv- DevContainer / Codespaces (Alternative): If you opened this repository in a DevContainer or GitHub Codespaces, Python 3.11,
uv,gcloud, and all core ADK dependencies are pre-installed in your container environment.
From your main adk-training directory, scaffold a new agent project:
uv run adk create greeting_system
Your folder structure will look like this once you add specialists.py:
adk-training/
βββ greeting_system/
βββ .env
βββ __init__.py
βββ specialists.py <-- Step 2: Specialist sub-agents
βββ agent.py <-- Step 3: Coordinator (root_agent)
Step 2: Implement the Specialist Sub-Agents (greeting_system/specialists.py)β
Create greeting_system/specialists.py and complete the TODO placeholders. Remember: the coordinator's LLM reads each specialist's description to decide whom to transfer to!
# greeting_system/specialists.py
from google.adk import Agent
# TODO: Define spanish_greeter (name="spanish_greeter_agent", model="gemini-3.8-flash")
# - Write a clear `description` so the router knows it handles Spanish greetings.
# - Write an `instruction` telling it to greet warmly ONLY in Spanish.
spanish_greeter = Agent(
name="spanish_greeter_agent",
model="gemini-3.8-flash",
description=..., # TODO: Action-oriented description for discovery
instruction=..., # TODO: Greet warmly in Spanish only
)
# TODO: Define japanese_greeter (name="japanese_greeter_agent", model="gemini-3.8-flash")
# - Write a clear `description` so the router knows it handles Japanese greetings.
# - Write an `instruction` telling it to greet politely ONLY in Japanese (with romaji).
japanese_greeter = Agent(
name="japanese_greeter_agent",
model="gemini-3.8-flash",
description=..., # TODO: Action-oriented description for discovery
instruction=..., # TODO: Greet politely in Japanese only
)
Step 3: Wire the Coordinator (greeting_system/agent.py)β
Open greeting_system/agent.py and configure root_agent to delegate via sub_agents:
# greeting_system/agent.py
from google.adk import Agent
from .specialists import spanish_greeter, japanese_greeter
# TODO: Define root_agent (name="router_agent", model="gemini-3.8-flash")
# - Instruct it to delegate to the matching specialist in sub_agents (never greet in Spanish/Japanese itself),
# and politely decline unsupported languages like French.
# - Register both specialists in `sub_agents=[...]`.
root_agent = Agent(
name="router_agent",
model="gemini-3.8-flash",
instruction=..., # TODO: Triage instructions
sub_agents=[...], # TODO: Register spanish_greeter and japanese_greeter
)
Step 4: Run and Inspect the Hand-off in Dev UIβ
- Launch the Dev UI from your parent
adk-trainingdirectory:(Selectuv run adk webgreeting_systemfrom the agent dropdown). - Test all three scenarios (Spanish, Japanese, and unsupported French).
- Check the Trace Tab: Expand the turn where you asked for Spanish β you will see
router_agentautomatically invoketransfer_to_agent(agent_name="spanish_greeter_agent"), followed immediately byspanish_greeter_agentgenerating the final reply!
Self-Reflection Questionsβ
- What is the single most important field that lets
router_agentknow which specialist to transfer to? - How would you extend this team to support Italian greetings without rewriting the existing specialists?
- After
router_agenttransfers a conversation tospanish_greeter_agent, who handles the user's next message by default? (Hint: Try sending a second message in the same chat session!)
π Reference Solution Vaultβ
Official Solution Vault β Module 15
Locked Challenge β Active Pedagogical Socratic Gate
Step 1/3: Question 1 of 1