Build an evidence-grounded research assistant with Gemini, Google ADK, Docker, OpenTelemetry, Prometheus, Tempo, and Grafana

Generative AI can produce an answer in seconds.

But when that answer could influence a real-world decision, speed and fluency are not enough.

Imagine asking an AI assistant:

What does current research say about irrigation strategies for drought-stressed tomatoes grown in clay soil, and what additional local information is needed before applying the findings?

A conventional chatbot may return a polished recommendation. It may even sound authoritative.

But a researcher, agronomist, grower, or responsible AI developer should ask harder questions:

  • Which sources support each statement?
  • What searches did the AI perform?
  • Did it consider alternative terminology?
  • Are any studies in conflict?
  • Which claims are only partially supported?
  • What evidence was missing?
  • What local measurements are needed?
  • What exactly did the agent do before producing its answer?

Those questions inspired me to build the open-source Gemini Agriculture Research Assistant—an educational reference application that turns a complex question into a transparent, evidence-grounded, and observable research journey.

The project combines:

  • Gemini
  • Google Search grounding
  • Google Agent Development Kit
  • Docker Compose
  • OpenTelemetry
  • Prometheus
  • Tempo
  • Grafana
  • Streamlit

In this article, I’ll explain the architecture, why each component exists, and the patterns you can reuse when building trustworthy AI agents in other domains.

GitHub repository:

GitHub logo hastimal / gemini-agriculture-research-assistant

Evidence-grounded crop research assistant built with Gemini, Google ADK, Google Search grounding, and trusted agricultural sources.

Gemini Agriculture Research Assistant

From complex crop questions to transparent, evidence-grounded research.

CI Python 3.11+ Gemini Google ADK Streamlit OpenTelemetry Docker Compose License: Apache-2.0

Gemini Agriculture Research Assistant

Gemini Agriculture Research Assistant is an open-source, evidence-grounded crop research and developer-learning system. It demonstrates how Gemini (via the google-genai Interactions API), Google Search Grounding, deterministic Python verification, Google ADK, and OpenTelemetry work together to turn complex agricultural questions into transparent, citation-backed research—while keeping consequential agronomic decisions under human control.

Important

Research Assistant — Not an Autonomous Agronomist: This system helps researchers, extension professionals, educators, and developers investigate agricultural literature. It never prescribes chemical dosages, fertilizer rates, or rigid irrigation schedules, and it never replaces field inspection or local Cooperative Extension advice.

Why This Project Exists

Agricultural questions involve interacting biological, soil-physics, climatic, and economic variables. Single-shot LLM answers often blend peer-reviewed findings with unverified web advice, gloss over cultivar/stage trade-offs, or emit confident schedules without knowing local soil moisture or evapotranspiration ($\text{ET}_o$)…

PyPi Package:

gemini-agriculture-research-assistant · PyPI

Evidence-grounded crop research assistant built with Gemini, Google ADK, Google Search grounding, and trusted agricultural sources.

favicon pypi.org

From Answer Generation to Evidence Processing

The application does not treat research as one enormous prompt.

Instead, it models research as a sequence of explicit, inspectable stages:

User Question ↓ Research Planning ↓ Query Fan-Out ↓ Google Search Grounding ↓ Source Normalization and Deduplication ↓ Evidence Extraction ↓ Claim Verification ↓ Cited Synthesis ↓ Conversational Follow-Up 

This separation matters.

When retrieval, verification, and synthesis are hidden inside one model call, the final prose may look impressive while the underlying process remains impossible to inspect.

In this application, every stage leaves an artifact:

  • Research sub-questions
  • Executed search queries
  • Retrieved sources
  • Deduplicated source records
  • Supporting passages
  • Candidate claims
  • Verification decisions
  • Missing information
  • Run identifiers
  • Trace identifiers
  • OpenTelemetry spans

The goal is not simply to generate an answer.

The goal is to build an answer that can show its work.

1. Start with a Clear Research Experience

The application starts with a focused interface where the user can enter a research question, select a preset, provide optional field context, and choose between live and demonstration modes.

Crop Research Assistant home screen

The interface supports two execution modes.

Live mode

Live mode uses Gemini and Google Search grounding to retrieve current public information.

Deterministic demo mode

Demo mode uses a reproducible offline evidence fixture and does not require an API key.

This is more important than it may initially appear.

A deterministic mode allows the project to run during:

  • Workshops
  • Conference demonstrations
  • CI pipelines
  • Offline development
  • API outages
  • Quota limitations
  • Environments without credentials

It also makes the behavior easier to test. A developer can validate the complete user journey without depending on continuously changing search results.

2. Turn One Question into a Research Plan

Research questions are rarely atomic.

The tomato irrigation question contains several independent concerns:

  1. Crop sensitivity and growth stage
  2. Soil-water behavior in clay soil
  3. Irrigation methods and trade-offs
  4. Yield, quality, and water-use outcomes
  5. Missing local weather, soil, and water information

The Gemini-powered planner extracts the relevant context and decomposes the original question into focused research tasks.

Instead of hiding this decomposition inside the model, the application exposes it to the user.

A visible plan allows the user to ask:

  • Did the planner understand the question correctly?
  • Is an important research angle missing?
  • Are the questions too broad?
  • Are the local constraints represented?
  • Should any sub-question be revised?

This is one of the most reusable agent-design patterns:

Make the plan inspectable before asking users to trust the result.

3. Use Query Fan-Out to Improve Research Coverage

One search query represents only one phrasing of a problem.

A useful research process often needs several targeted searches covering:

  • Alternative terminology
  • Different institutions
  • Geographic constraints
  • Crop-specific terminology
  • Soil conditions
  • Management practices
  • Expected outcomes
  • Conflicting findings

The application fans the research plan out into explicit Google Search tasks.

Query fan-out journey

The Query Fan-Out view shows:

  • The original prompt
  • Generated research questions
  • Every executed query
  • Raw grounding results
  • Deduplicated sources
  • Evidence and claims derived from those sources
  • Retrieval status
  • Query latency
  • Model or fixture used

This solves an important trust problem:

There are no silent searches.

The user can see what the agent searched for and where retrieval may have missed an important angle.

Query fan-out improves recall, but more search results do not automatically create more truth.

The next step is to preserve source identity and evidence provenance.

4. Preserve Evidence, Not Just URLs

Search results are only candidates.

The assistant normalizes and deduplicates the retrieved sources before using them as evidence.

For every source, the application preserves information such as:

  • Source ID
  • Title
  • Publisher
  • Source type
  • Authority tier
  • Publication date
  • Retrieval date
  • Geographic scope
  • Crop scope
  • Supporting passage
  • Linked claim IDs
  • Source URL
  • Grounding metadata

Query fan-out journey

There is an important difference between a URL list and an evidence record.

A URL tells us where information came from.

An evidence record also tells us:

  • Which passage was used
  • How the passage was interpreted
  • Which claim depends on it
  • Whether the source supports or conflicts with that claim
  • How authoritative the source is considered
  • Under which geographic or agricultural conditions it applies

This provenance chain is useful far beyond agriculture.

The same pattern can support:

  • Healthcare research
  • Education
  • Public policy
  • Legal research
  • Scientific literature reviews
  • Financial analysis
  • Technical decision support

Whenever users must inspect the path from a source to a conclusion, provenance must survive every stage of the pipeline.

5. Verify Claims Before Writing the Answer

The answer composer should not be the only component deciding whether a statement is established.

Before synthesis, the application evaluates candidate claims against the collected evidence.

Each claim receives one of five statuses:

Status Meaning
Supported Retrieved evidence directly supports the claim.
Partially Supported Evidence supports only part of the statement or requires qualification.
Conflicting Retrieved sources disagree or describe incompatible conditions.
Unknown Available evidence is insufficient.
Suppressed The claim is withheld from established findings because of evidence-quality or safety rules.

Claim verification interface

This gives the final answer a safer vocabulary.

Instead of smoothing over disagreement, the assistant can explicitly state:

  • The evidence conflicts.
  • The result depends on growth stage.
  • The recommendation is only partially supported.
  • The available sources do not establish this claim.
  • Local verification is still required.

That qualification is especially important in agriculture.

Results from one cultivar, climate, irrigation system, market class, growth stage, or soil profile may not transfer directly to another field.

The application is therefore a research-transparency and decision-support tool.

It is not an autonomous agronomist.

Human experts and local field validation remain in control.

6. Generate a Cited Research Synthesis

After verification, the answer composer produces a synthesis that distinguishes between:

  • Supported conclusions
  • Partially supported findings
  • Conflicting evidence
  • Unknowns
  • Suppressed claims
  • Missing local information

Completed crop research results

The result is not merely a collection of links.

It connects the research question to:

  1. The generated research plan
  2. The executed searches
  3. The normalized sources
  4. The extracted evidence
  5. The evaluated claims
  6. The final cited explanation

A confident sentence should never become disconnected from the evidence that produced it.

7. Continue the Investigation with a Google ADK Agent

A static report is useful, but users naturally want to ask follow-up questions:

  • Why is this finding only partially supported?
  • Which sources specifically discuss clay soil?
  • Where do studies disagree about deficit irrigation?
  • What local measurements should I gather first?
  • Which sources come from USDA or university extensions?
  • What should I ask a local Cooperative Extension specialist?

The Google ADK research agent answers questions against the selected research run.

Research Agent follow-up interface

The agent can use tools to:

  • Retrieve the selected run
  • Summarize the run
  • List claims by status
  • Find conflicting findings
  • Identify missing information
  • Search the normalized source set
  • Explain evidence limitations

This grounding boundary is intentional.

A normal follow-up should not silently detach itself from the evidence already under review or launch unrelated searches without making that behavior visible.

The research agent should know which run, sources, claims, and trace the user is discussing.

8. Inspect the Agent with Google ADK Dev UI

The visible response is only the final event in an agentic workflow.

Developers also need to inspect:

  • Session state
  • Agent events
  • Tool calls
  • Tool results
  • Artifacts
  • Traces
  • Evaluations

Google ADK Dev UI makes this behavior inspectable.

Google ADK development interface

In the screenshot, we can see the agent:

  1. Reading the selected run from state
  2. Calling get_selected_run
  3. Calling run-summary and claim-analysis tools
  4. Searching sources
  5. Producing a response grounded in retrieved evidence

This is valuable when debugging agent behavior.

If the final response is incomplete, we can ask:

  • Did the agent receive the correct run ID?
  • Was the expected tool called?
  • Did the tool return the correct data?
  • Did session state change unexpectedly?
  • Did the agent ignore a conflicting claim?
  • Did a tool fail silently?

Without this visibility, developers are left debugging only the final text.

Observability for AI Agents: Four Tools, Four Different Jobs

“We added observability” can mean many different things.

In this architecture, each component has a distinct responsibility.

Component Responsibility Question it answers
OpenTelemetry Instruments the application and exports telemetry What telemetry does the application produce?
Prometheus Stores and queries time-series metrics How many runs occurred, how slow were they, and how often did they fail?
Tempo Stores distributed traces and spans What happened inside this specific run?
Grafana Visualizes metrics and explores traces How can developers navigate and correlate system behavior?

This distinction prevents a common source of confusion:

PromQL is used for Prometheus metrics. TraceQL is used for Tempo traces.

OpenTelemetry

OpenTelemetry instruments the application.

It creates telemetry describing important operations such as:

  • Workflow execution
  • Research planning
  • Search retrieval
  • Query fan-out
  • Google Search grounding
  • Source normalization
  • Evidence aggregation
  • Claim verification
  • Answer composition
  • ADK chat turns
  • ADK tool calls

The OpenTelemetry Collector receives this telemetry and routes it to the appropriate backend.

Prometheus

Prometheus answers aggregate operational questions:

  • How many workflows completed?
  • What is the success rate?
  • How many grounding calls failed?
  • What is the p95 workflow latency?
  • How many sources were retrieved?
  • How many claims were supported or suppressed?
  • Which workflow stage is slowest?

Tempo

Tempo answers questions about an individual execution:

  • What happened in this run?
  • Which span was slow?
  • Which search query failed?
  • How long did verification take?
  • Which model call caused degradation?
  • What were the parent-child relationships?

Grafana

Grafana provides the navigation and visualization layer.

It connects aggregate metrics with individual traces and gives developers a practical place to investigate system behavior.

The Grafana Operations Dashboard

The Grafana overview dashboard shows the overall health of the research assistant.

Grafana research assistant overview

The dashboard includes:

  • Total workflow runs
  • Success rate
  • Failed workflows
  • Grounding failures
  • Unsupported claims
  • Workflow latency
  • Research questions
  • Search-query count
  • Retrieved sources
  • Deduplicated sources
  • Evidence-item count
  • Claims by verification status
  • Stage-level latency
  • Recent traces

This answers the operational question:

Is the research system healthy overall?

But aggregate metrics cannot explain everything.

When one execution is unexpectedly slow or produces an unusual result, we need the trace.

Exploring Individual Traces in Tempo

The trace explorer separates different types of activity:

  • Research workflow traces
  • Research Agent chat traces
  • Error and degraded traces
  • Slow traces
  • Query fan-out spans
  • Google Search grounding spans
  • ADK tool spans

Grafana Tempo trace explorer

Developers can filter traces by:

  • Research mode
  • Run ID
  • Duration
  • Error status
  • Workflow stage
  • Agent activity

Each trace ID opens the full parent-child waterfall in Tempo.

The Trace Waterfall: Seeing Inside One Run

A useful trace should mirror the mental model of the application.

OpenTelemetry span waterfall

For this project, that means creating spans for:

  • Research workflow
  • Planning
  • Individual research questions
  • Individual fan-out searches
  • Google Search grounding
  • Source normalization
  • Evidence aggregation
  • Claim verification
  • Answer composition
  • ADK chat activity
  • ADK tool calls

When a run is slow or degraded, the waterfall can show whether the delay came from:

  • Planning
  • A particular search query
  • A model interaction
  • Grounding
  • Verification
  • Answer generation
  • API serialization

That is the difference between knowing that an agent failed and knowing where and why it failed.

Observability is not only an infrastructure feature.

For AI agents, observability is part of product trust.

Why Docker Is Part of the Architecture

An agentic application is rarely one process.

This project requires:

  • The Crop Research Assistant
  • Google ADK Dev UI
  • OpenTelemetry Collector
  • Prometheus
  • Tempo
  • Grafana

Installing and configuring all of these components independently would create unnecessary friction for learners and contributors.

Docker Compose turns the architecture into one reproducible environment.

Docker Desktop showing the complete stack

Docker provides:

  • Reproducible service configuration
  • Predictable networking
  • Consistent ports
  • Health checks
  • Isolated dependencies
  • One-command startup
  • One-command shutdown
  • The same environment for developers and demonstrations

From a Docker perspective, the lesson is broader than packaging:

Containers make a complex architecture teachable.

The same services and relationships can be reproduced across:

  • Developer laptops
  • Conference workshops
  • Classrooms
  • CI runners
  • Demonstration environments
  • Future cloud deployment targets

Run the Complete Stack

Clone the repository:

git clone https://github.com/hastimal/gemini-agriculture-research-assistant.git cd gemini-agriculture-research-assistant 

Start the deterministic demonstration stack:

./scripts/run_all.sh demo 

The script starts the complete environment and prints the available service URLs.

When you are finished:

./scripts/run_all.sh stop 

For live Gemini and Google Search grounding, copy the environment example, configure the required Gemini API key, and use the live mode documented in the repository.

You can also install the Python package:

pip install gemini-agriculture-research-assistant 

Explore the CLI:

crop-research --help 

Seven Design Lessons You Can Reuse

The most reusable parts of this project are not specific to agriculture.

1. Make the plan visible

Users should see how a broad goal becomes smaller tasks.

Hidden decomposition is difficult to evaluate.

2. Record every retrieval action

Show the executed queries, not only the final citations.

This exposes both research coverage and omissions.

3. Preserve provenance through the pipeline

A final sentence should be traceable to:

Final Statement ↓ Verified Claim ↓ Evidence Passage ↓ Normalized Source ↓ Original URL 

4. Separate verification from fluent writing

The component that writes persuasive prose should not be the only component deciding whether a statement is established.

5. Treat uncertainty as useful output

Conflicting, unknown, and partially supported findings should not be hidden.

They are valuable research results.

6. Design for degraded operation

APIs time out.

Quotas expire.

Models become unavailable.

Schemas change.

A responsible system should display degraded and failed states instead of returning a confident-looking fallback without explanation.

7. Correlate product state with telemetry

Display run and trace IDs in the application.

A developer should be able to move from an unexpected answer directly to the trace that produced it.

The Bigger Lesson

The most interesting question is no longer:

Can an LLM answer this question?

The better questions are:

Can the system show how it planned the work?

Can it identify the evidence behind every important claim?

Can it surface disagreement and uncertainty?

Can users inspect the searches that were executed?

Can developers reproduce, observe, test, and improve the workflow?

Gemini provides the intelligence.

Google ADK provides inspectable orchestration, state, agents, and tools.

Google Search grounding supplies current public evidence.

OpenTelemetry captures the workflow.

Prometheus measures aggregate behavior.

Tempo stores individual traces.

Grafana connects operational health with deep investigation.

Docker makes the complete system reproducible.

Together, these technologies turn a clever AI demo into an engineering system that developers can study, challenge, and extend.

What Would You Build Next?

Although this project focuses on agricultural research, the same architecture can be adapted to other evidence-heavy domains:

  • Healthcare information
  • Technical research
  • Education
  • Public policy
  • Scientific literature
  • Financial research
  • Legal discovery
  • Environmental analysis
  • Product evaluation

The domain can change while the core engineering contract remains the same:

Plan transparently. Retrieve explicitly. Verify before synthesis. Preserve provenance. Trace everything. Keep humans in control.

Explore the Open-Source Project

GitHub:

github.com/hastimal/gemini-agriculture-research-assistant

PyPI installation:

pip install gemini-agriculture-research-assistant 

CLI:

crop-research --help 

If you build on the project, I would love to hear:

  • Which domain would you adapt it to?
  • Which agent behavior do you most want to observe?
  • What evidence should an AI system preserve before asking users to trust its answer?

I build and teach practical AI-agent systems across Google technologies, Docker, and cloud-native observability.

As a Cloud & AI Expert and an open-source-focused community builder, I believe the next generation of AI education should go beyond model prompts. Developers should learn how to build complete systems that are grounded, observable, reproducible, and responsible.

This project is an educational reference implementation. Its research output should support—not replace—qualified agricultural expertise and local field validation.