Skip to main content

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_turn mode, equipped with google_search) to fetch a grounded real-world forecast.
  • It then delegates to the Flight Booker (in task mode, also equipped with google_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_search Grounding & Scope): Both specialists use ADK's built-in google_search tool (from google.adk.tools import google_search) so weather forecasts and flight schedule lookups return grounded real-world results. Running google_search requires a valid GOOGLE_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, cd into the adk-training project 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โ€‹

  1. Return to the parent directory and launch the Dev UI:
    cd ..
    uv run adk web
    (Select travel_team from the agent dropdown in the UI).
  2. Verify the Flow:
    • Ask: "I want to go to Tokyo next week."
    • Observe: The travel_planner should call the weather_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_booker decides it's done: it calls the framework-injected finish_task tool, and control returns to travel_planner immediately, within that same turn -- not on a separate follow-up turn -- with no "hand-off" code written by you. travel_planner then presents the final combined plan in that same response.

Bonus (optional): Try rewiring weather_checker as an AgentTool instead of a sub_agents entry: drop mode="single_turn", remove it from sub_agents, and instead give travel_planner tools=[AgentTool(agent=weather_agent)] (import from google.adk.tools.agent_tool). Re-run the same request and compare the Trace tab: with AgentTool the whole weather lookup happens inside travel_planner's own function call -- there's no separate weather_checker author entry the way there was with mode="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_turn instead of task for a database lookup specialist?
  • What happens to the conversation history when a sub-agent is in task mode? (Hint: Check the Trace tab).
  • How does the mode setting improve the reliability of complex, multi-step workflows compared to standard chat mode?

๐Ÿ” Reference Solution Vaultโ€‹

๐Ÿงช

16: Collaborative Teams(Challenge Lab)

Part 3: Multi-Agent Systems โ€ข Module 16

Overall Course Progress:
0%(0/98)
Next: 17: Static Workflows ๐Ÿ“– โ†’