Lab 16: Building a Collaborative Travel Team
Goalโ
In this lab, you will build a Travel Planning Team consisting of a Coordinator, a Weather Specialist, and a Flight Booker. You will learn how to use the mode parameter to create a system where sub-agents fulfill specific tasks and then automatically return control to the main planner.
The Scenarioโ
- Coordinator receives the user's travel request.
- It delegates to the Weather Specialist (in
single_turnmode, equipped withgoogle_search) to fetch a grounded real-world forecast. - It then delegates to the Flight Booker (in
taskmode, also equipped withgoogle_search) to look up real flight options and gather user preferences across multiple turns before returning control. - Finally, the Coordinator synthesizes the complete travel plan.
Important (
google_searchGrounding & Scope): Both specialists use ADK's built-ingoogle_searchtool (from google.adk.tools import google_search) so weather forecasts and flight schedule lookups return grounded real-world results. Runninggoogle_searchrequires a validGOOGLE_API_KEY(or an authenticated Vertex AI GCP project). While flight options and schedules are looked up live via Google Search, actual ticket purchase/booking is of course simulated and never performed.
Step 1: Create 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.
uv run adk create travel_team
cd travel_team
Step 2: Implement the Collaborative Specialistsโ
Open agent.py. Your task is to define the team, attach tools=[google_search] to both specialists, and configure their collaboration modes correctly.
Exercise: Complete the agent definitions by setting the appropriate mode and tools for each specialist.
# In agent.py (Starter Code)
from google.adk import Agent
from google.adk.tools import google_search
# Note: every agent below needs rerun_on_resume=True. Any agent that's part
# of a sub_agents dispatch chain can be "woken up" when a task-mode
# sub-agent pauses and resumes across turns -- without the flag on ALL
# three agents (coordinator included), you'll hit:
# "ValueError: A node must have rerun_on_resume=True."
# 1. Define the Weather Specialist
# Hint: Use 'single_turn' mode for a quick, non-interactive lookup, and
# attach tools=[google_search] for grounded real-world forecasts.
weather_agent = Agent(
name="weather_checker",
model="gemini-3.8-flash",
mode=..., # TODO: Set collaboration mode for a quick 1-step lookup
rerun_on_resume=True,
tools=[...], # TODO: Equip with google_search for real-world weather forecasts
instruction="""
# TODO: Write instructions to use google_search to provide a brief,
# grounded 3-day weather forecast for the requested destination.
"""
)
# 2. Define the Flight Booker
# Hint: Use 'task' mode to allow the agent to ask the user questions about
# flight preferences before finishing, and attach tools=[google_search] to
# look up real flight options (without performing an actual ticket purchase).
flight_agent = Agent(
name="flight_booker",
model="gemini-3.8-flash",
mode=..., # TODO: Set collaboration mode for multi-turn task with auto-return
rerun_on_resume=True,
tools=[...], # TODO: Equip with google_search to look up real flight options
instruction="""
# TODO: Write instructions to help the user select a flight:
# 1. Ask about preferred airline or departure time if not provided.
# 2. Use google_search to look up realistic flight options/schedules.
# 3. Present a clear itinerary confirmation (note: no real ticket is purchased).
"""
)
# 3. Define the Coordinator
# Hint: Coordinator should NOT have a mode set (it's the root), but it
# still needs rerun_on_resume=True (see note above).
root_agent = Agent(
name="travel_planner",
model="gemini-3.8-flash",
rerun_on_resume=True,
instruction="""
# TODO: Write instructions to coordinate the team.
# 1. Get weather from weather_checker.
# 2. Arrange flight options via flight_booker.
# 3. Present the final cohesive plan.
""",
# TODO: Register your specialists here
sub_agents=[]
)
Step 3: Run and Testโ
- Return to the parent directory and launch the Dev UI:
(Select
cd ..
uv run adk webtravel_teamfrom the agent dropdown in the UI). - Verify the Flow:
- Ask: "I want to go to Tokyo next week."
- Observe: The
travel_plannershould call theweather_checker. - Observe: Then it should call the
flight_booker. The flight booker might ask you "Which airline do you prefer?" or "Do you want a morning flight?". Keep answering -- it may take more than one exchange before it has everything it needs. - Final Check: Watch the Trace tab for the turn where
flight_bookerdecides it's done: it calls the framework-injectedfinish_tasktool, and control returns totravel_plannerimmediately, within that same turn -- not on a separate follow-up turn -- with no "hand-off" code written by you.travel_plannerthen presents the final combined plan in that same response.
Bonus (optional): Try rewiring
weather_checkeras anAgentToolinstead of asub_agentsentry: dropmode="single_turn", remove it fromsub_agents, and instead givetravel_plannertools=[AgentTool(agent=weather_agent)](import fromgoogle.adk.tools.agent_tool). Re-run the same request and compare the Trace tab: withAgentToolthe whole weather lookup happens insidetravel_planner's own function call -- there's no separateweather_checkerauthor entry the way there was withmode="single_turn". Same call-and-return result, different plumbing.
Lab Summaryโ
You have built a Collaborative Agent Team!
- You used
mode="single_turn"for background utility tasks. - You used
mode="task"for interactive sub-tasks with automatic return. - You observed how the ADK 2.0 framework manages the hand-off lifecycle so you can focus on agent logic.
Self-Reflection Questionsโ
- Why would you use
single_turninstead oftaskfor a database lookup specialist? - What happens to the conversation history when a sub-agent is in
taskmode? (Hint: Check the Trace tab). - How does the
modesetting improve the reliability of complex, multi-step workflows compared to standardchatmode?
๐ Reference Solution Vaultโ
Official Solution Vault โ Module 16
Locked Challenge โ Active Pedagogical Socratic Gate