Lab 16: Building a Hybrid News Aggregator
Goal
In this lab, you will build a sophisticated News Aggregator using a hybrid graph architecture. You will learn how to:
- Run two specialized research nodes in parallel (Fan-out).
- Synchronize the results using a JoinNode (Fan-in).
- Process the combined data in a sequential step.
The Architecture
┌──── Node A (Tech News) ────┐
START ──┼ ├──→ JoinNode → Summarizer → END
└──── Node B (Market News) ──┘
Step 1: Create the Project
uv run adk create news_aggregator
cd news_aggregator
Step 2: Implement the Specialist Nodes
Open agent.py. Your task is to define three agents: two for research and one for synthesis.
# In agent.py (Starter Code)
from google.adk import Agent, Workflow
from google.adk.workflow import JoinNode
# TODO: Define 'tech_researcher'
# Instruction: Find 3 headlines about AI and Robotics.
# Output key: "tech_news"
tech_researcher = ...
# TODO: Define 'market_researcher'
# Instruction: Find 3 headlines about Stock Market trends.
# Output key: "market_news"
market_researcher = ...
# TODO: Define 'summarizer'
# Instruction: Combine {tech_news} and {market_news} into a newsletter.
summarizer = ...
Step 3: Assemble the Hybrid Graph
Exercise: Complete the root_agent definition using the edges parameter to implement the Fan-out/Join pattern.
# 1. Create the synchronization point
syncer = JoinNode(name="news_sync")
# 2. Build the Workflow
# TODO: Define the edges to:
# - Start both researchers in parallel from "START".
# - Converge both researchers at the 'syncer'.
# - Connect the 'syncer' to the 'summarizer'.
root_agent = Workflow(
name="NewsSystem",
edges=[
# Parallel Branch 1
("START", ..., ...),
# Parallel Branch 2
(..., ..., ...),
# Sequential Final Step
(..., ...)
]
)
Step 4: Run and Verify
- Start the Dev UI:
uv run adk web . - Test: Send the prompt "Give me today's update."
- Inspect: Open the Graph View. Verify that the researchers start at the same time and the summarizer only runs after both finish.
Lab Summary
You have built a hybrid multi-agent graph!
- You mastered Fan-out by defining multiple edges from START.
- You mastered Fan-in using the
JoinNode. - You learned that sequential and parallel execution are just different edge configurations.
🕵️ Hidden Solution 🕵️
Looking for the solution? Here's a hint (Base64 decode me):
L2RvYy1hZGstdHJhaW5pbmcvbW9kdWxlMTYtc3RhdGljLW9yY2hlc3RyYXRpb24vbGFiLXNvbHV0aW9u
The direct link is: Lab Solution