Sebastian Gomez
Build a background research agent
Lesson notebook: Lesson_3.ipynb
In this third lesson we turn the conversational assistant into a silent coordinator that researches, composes a report and only talks to you twice. We reuse tools from the previous lesson and add file persistence to get a clear artifact: a Markdown report.
Overview
- Reuse
get_financial_contextand add a tool to save Markdown. - Implement the Coordinator Dispatcher pattern: it runs in the background and replies twice.
- Force structured outputs with a consistent Markdown template.
- Test the experience from the ADK Web UI and view the report.
3.1 Initial setup
- Make sure you have
google-adkandyfinanceavailable. Use a recent version floor, for examplegoogle-adk>=1.16.0, and note the exact version you tested the notebook with so it stays reproducible, for examplegoogle-adk==1.16.0.
Note: the ADK API moves fast. If you reproduce this well after publication, install the latest version and check the changelog in case a signature changed.google-adk version number on PyPI before pinning it.
- Credentials: ADK reads
.envwhen you runadk weboradk run. If you useload_env()in the notebook, use it only as a helper and keep.envas the source of truth in real environments. - Work in a virtual environment to avoid conflicts between lessons.
Install the dependencies:
pip install "google-adk>=1.16.0" yfinance3.2 Project setup
Create the base app with the expected structure:
app04/
agent.py # coordinator agent implementation
.env # sensitive configuration
__init__.py # Python package3.3 Coordinator Dispatcher pattern
The challenge: an agent that "reads out loud" every result creates noise and cognitive load.
The solution: split the interaction into two phases.
- Coordination: it acknowledges the request and announces it is starting work.
- Silent execution: it searches, cross references data and generates a report without interrupting.
3.4 Tools and persistence
We reuse get_financial_context to enrich headlines and add save_news_to_markdown to persist the report.
Caveat on `yfinance`: get_financial_context depends on yfinance, which consumes unofficial data from Yahoo Finance. It is a source known to break without notice when Yahoo changes its internal API. If the metrics stop coming through, update yfinance or plan a fallback in your pipeline.
Notes on state and persistence:
- Changes to
tool_context.stateduring execution are tracked by the framework and persisted via the runner; they do not imply external storage unless you configure memory or artifact services. - Writing the file in
save_news_to_markdownproduces the final artifact explicitly.
3.5 Structured reports
Recommended template, embedded in the agent instructions:
- Title, date and context.
- Numbered list of 5 news items with: headline, company and ticker, financial metric (
get_financial_context) and a short summary.
3.6 Advanced instructions: coordinator agent
The agent shifts from "presenter" to "research coordinator" with strict rules.
Two messages maximum:
- Start: "Ok, I'm starting the research; give me a moment...".
- End: "Done, I saved the report in
ai_research_report.md".
Background work between the two messages: google_search, extract tickers, get_financial_context, format according to the template and save_news_to_markdown. No intermediate results and no extra conversation.
3.7 Testing in the Web UI
Run the UI:
# From the parent folder, then select "app04"
adk web
# Or directly into the app
adk web --port 8000 app04On Windows, use --no-reload if needed. Stop the process with Ctrl-C.
Suggested script:
- "Get me the latest AI news".
- The agent confirms the start and goes silent.
- The final message arrives confirming
ai_research_report.md. - Open the file and validate the format and content.
Close the process when you finish:
pkill -f "adk web"Optional (long term memory): to use Vertex AI Memory Bank from adk web or adk api_server, start with the flag --memory_service_uri=agentengine://<agent_engine_id>.
Note: see the memory guide in the official ADK documentation: Memory in ADK.agentengine:// URI scheme and the Memory Bank / Agent Engine naming have been evolving; confirm the current scheme against the 2026 documentation before publishing.
3.8 Viewing the report
From the notebook:
from IPython.display import Markdown, display
with open("ai_research_report.md", encoding="utf-8") as f:
display(Markdown(f.read()))Best practices and next steps
- Version
ai_research_report.mdonly if you need to audit results; otherwise ignore it. - Parameterize the number of news items and the report format if you are aiming for pipelines (podcast, newsletters).
- For production, evaluate external storage (buckets, databases).
- Practice the same pattern with other topics to fine tune prompts and templates.
Suggested exercises
- Add a second persistence tool that also saves the report in JSON format, reusing the same agent state.
- Parameterize the number of news items (for example, 3 or 10) through a variable that the coordinator reads from
tool_context.state. - Replace the topic "AI news" with one of your own interest and adjust the report template for that domain.
3-point summary
- The Coordinator Dispatcher pattern separates conversation from work: the agent only speaks at the start and at the end, and everything else happens silently.
- We reuse
get_financial_contextand addsave_news_to_markdownto produce a clear, persistent Markdown artifact. - A structured template in the agent instructions guarantees consistent reports that you can test from the ADK Web UI.
That's all, I hope this post is useful to you and that you can apply it to a project you have in mind. Leave me a comment if it helped, if you want to add an opinion or if you have any questions, and remember that if you liked it you can also share it using the social links below.
Previous lesson: ADK lesson 2: power up your agent with custom tools
Next lesson: ADK lesson 4: callbacks and guardrails for reliable agents
This content is based on the course "Building Live Voice Agents with Google's ADK!" by DeepLearning.AI (see course). This blog aims to bring ADK material to Spanish speakers.
Sebastian Gomez
Creador de contenido principalmente acerca de tecnología.