Skip to main content

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.


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$). This project separates planning, grounded retrieval, evidence normalization, deterministic claim verification, and missing-information reporting into an inspectable workflow.

What It Demonstrates

  • Gemini Interactions API & Grounding: Structured planning, Google Search grounding (tools=[{"type": "google_search"}]), and url_citation extraction with safe model fallback (gemini-3.8-flash → gemini-3.5-flash-lite).
  • Deterministic Claim Verification: Python verification scoring authority tier, recency, crop/stage relevance, contradictions, and prescription safety rules (SUPPORTED, PARTIALLY_SUPPORTED, CONFLICTING, UNKNOWN, Suppressed).
  • Google ADK Integration: A 6-tab Streamlit Research Agent plus the official Google ADK Dev UI (crop_research_agent) backed by 14 typed tools, persistent SQLite sessions, and a 10-case starter EvalSet.
  • Full-Stack Observability: OpenTelemetry traces and metrics exported via OTLP Collector to Grafana Tempo, Prometheus, and two pre-provisioned Grafana dashboards.

Key Capabilities

  • Zero-Credential Demo Mode: Runs out of the box with deterministic offline USDA, FAO, Cooperative Extension, NOAA, and peer-reviewed fixtures.
  • Live Grounded Mode: Uses GEMINI_API_KEY for real-time Google Search grounding and live Gemini synthesis.
  • Query Fan-Out Explorer: Visualizes decomposition from user question → sub-questions → search queries → deduplicated sources.
  • Evidence & Citation Explorer: Search, 6 filter axes, 4 sort modes, pagination, separated retrieved facts vs. model interpretation, and CSV/JSON exports.
  • Shared-Run Context: Completed Streamlit runs export atomically as SharedRunSnapshot JSON files so crop_research_agent in ADK Dev UI can inspect them immediately.

User Experience / Application Tabs

Tab Purpose
Research Compact question input, Load Preset, execution mode selector, collapsed advanced context, 10 KPI cards, executive summary, and progressive-disclosure findings.
Query Fan-Out Journey view (6-stage pipeline strip, Altair chart, grouped sub-question cards) and Table view with CSV export.
Evidence Searchable, filterable, paginated source cards with clickable canonical URLs, separated supporting passages vs. model interpretation, and CSV/JSON downloads.
Verification Separate Supported, Partially Supported, Conflicting, Unknown, and Suppressed KPI cards, distribution chart, and expandable claim rationales.
Research Agent Grounded Google ADK chat over the selected run with [SRCx] citations, no silent web search, confirmation-gated new evidence search, and ADK Dev UI links.
Traces Server-side Tempo trace inspector (with standalone in-memory fallback), Gantt waterfall timeline, hierarchical span tree, and span attribute/event inspector.

Architecture & Research Workflow

flowchart LR
    U["User Question"] --> P["1–3. Context, Planning & Query Fan-Out"]
    P --> R["4. Grounded Retrieval (Gemini / Fixtures)"]
    R --> E["5. Evidence Normalization & Deduplication"]
    E --> V["6. Deterministic Claim Verification"]
    V --> A["7. Grounded Synthesis & Missing Local Info"]
    A --> UI["Streamlit 6-Tab UI & SharedRunStore"]
    UI --> ADK["Google ADK Dev UI (crop_research_agent)"]
    UI --> OTEL["OTel Collector → Tempo & Prometheus → Grafana"]

Quick Start

Install from PyPI

pip install gemini-agriculture-research-assistant

Optional extras:

pip install "gemini-agriculture-research-assistant[ui]"            # Streamlit web interface
pip install "gemini-agriculture-research-assistant[adk]"           # Google ADK Dev UI support
pip install "gemini-agriculture-research-assistant[all]"           # UI + ADK + OpenTelemetry

Run the installed crop-research CLI:

crop-research demo
crop-research research "How should I irrigate tomatoes in clay soil during drought?" --mode demo
crop-research doctor
crop-research ui

Full Local Stack (Docker Compose + Observability)

chmod +x scripts/run_all.sh
./scripts/run_all.sh demo

Demo Mode vs. Live Mode

  • Demo Mode (./scripts/run_all.sh demo): Default safe mode. Requires no API key and uses deterministic offline agricultural fixtures.
  • Live Mode (./scripts/run_all.sh live): Reads GEMINI_API_KEY from your shell environment or untracked .env file, validates GEMINI_MODEL (gemini-3.8-flash) and GEMINI_FALLBACK_MODEL (gemini-3.5-flash-lite), and fails early if missing.

Complete Local Service Stack

Service Local URL / Endpoint Purpose
Crop Research Assistant http://localhost:8501 6-tab Streamlit UI
Google ADK Dev UI http://localhost:8000 Official adk web for crop_research_agent (127.0.0.1 only)
Grafana http://localhost:3000 Pre-provisioned Overview & Trace Explorer dashboards (127.0.0.1 only)
Prometheus http://localhost:9090 Metrics TSDB (127.0.0.1 only)
Grafana Tempo http://localhost:3200 Distributed trace store (127.0.0.1 only)
OTel Collector localhost:4317 / 4318 OTLP gRPC & HTTP receivers (127.0.0.1 only)
./scripts/run_all.sh status        # Check container health and print endpoints
./scripts/run_all.sh smoke         # Run 19-point end-to-end observability & ADK smoke suite
./scripts/run_all.sh stop          # Stop containers while preserving all local volumes
./scripts/run_all.sh clean         # Stop containers AND delete local volumes (warns first)

ADK Dev UI

The Google ADK Dev UI (http://localhost:8000) exposes crop_research_agent with 14 typed tools, persistent SQLite sessions (/data/adk/sessions.db), live State, Events, Artifacts, and the Eval tab (agents/crop_research_agent/eval/irrigation_research.evalset.json). See docs/adk-dev-ui.md.


Observability

Grafana (http://localhost:3000) is pre-provisioned with Agriculture Research Assistant — Overview (uid: agriculture-research-overview) and Agriculture Research Assistant — Trace Explorer (uid: agriculture-research-traces), with anonymous local Editor access enabled so /explore and Tempo TraceQL queries work without signing in. See docs/observability.md.


Screenshots

Home & Preset Loader Query Fan-Out Explorer
Home Query Fan-Out
Evidence Explorer Claim Verification
Evidence Verification
Grounded Research Agent Tempo Trace Waterfall
Research Agent Traces
Google ADK Dev UI Grafana Overview & Trace Explorer
ADK Dev UI Grafana Overview

Trusted-Source Policy & Responsible-Use Boundaries

Sources are ranked across 7 institutional tiers (USDA-ARS/NRCS, FAO, State/National Agricultural Agencies, Land-Grant Cooperative Extension, NOAA/Climate Agencies, Peer-Reviewed Research, and Reputable Research Institutions; see docs/source-policy.md). High-stakes chemical, fertilizer, or rigid-schedule prescriptions are deterministically suppressed. See docs/responsible-use.md.


Testing & Quality

uv run --no-sync ruff format --check src tests scripts agents
uv run --no-sync ruff check src tests scripts agents
uv run --no-sync mypy src
uv run --no-sync pytest --cov=agriculture_research --cov-report=term-missing

Project Structure

  • src/agriculture_research/ — Core pipeline (planner.py, retrieval.py, evidence.py, verifier.py, answer.py, workflow.py), gemini_client.py, run_store.py, tempo_client.py, telemetry.py, adk/, and ui/.
  • agents/crop_research_agent/ — ADK-discoverable root_agent, shared-run context.py, and starter eval/.
  • observability/ — OpenTelemetry Collector, Tempo, Prometheus, and Grafana provisioning/dashboards.
  • scripts/ — run_all.sh, smoke_observability.py, demo_research.py, run_app.py.
  • tests/ — 65 unit, integration, UI, ADK, and observability tests (>=85% coverage enforced).

Documentation

Roadmap, Contributing, License & Attribution

Metadata

Release files for gemini-agriculture-research-assistant 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gemini-agriculture-research-assistant 0.4.0
File Size Uploaded Provenance Actions
gemini_agriculture_research_assistant-0.4.0.tar.gz 2.3 MB With provenance Details for gemini_agriculture_research_assistant-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gemini-agriculture-research-assistant 0.4.0
File Interpreter ABI Platform Actions
gemini_agriculture_research_assistant-0.4.0-py3-none-any.whl Python 3 none any Details for gemini_agriculture_research_assistant-0.4.0-py3-none-any.whl

Total release size: 2.5 MB

Release files / gemini_agriculture_research_assistant-0.4.0.tar.gz

Download URL gemini_agriculture_research_assistant-0.4.0.tar.gz
Size 2.3 MB
Tags Source
SHA-256 checksum
How to use checksums
e208a9001594ae33d5e3a8c1028434e0cecc3df67a471ac88fda4e5c9580a74a
BLAKE2b-256 checksum
How to use checksums
1366af9fcfd79a015cf249200f6b6305b1b6f85083b3b5f19f1b299e121a04c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 5, 2026.

Transparency log

Release files / gemini_agriculture_research_assistant-0.4.0-py3-none-any.whl

Download URL gemini_agriculture_research_assistant-0.4.0-py3-none-any.whl
Size 141.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3d8bc2a319388e54ad36f87aac2edb8d62c4a736ec4c6360e15093a973f9c969
BLAKE2b-256 checksum
How to use checksums
e392baaaf3fad6b0613b788f4992142a7b2e6013c73adcda0188f2d22990063d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 5, 2026.

Transparency log

Security for gemini-agriculture-research-assistant 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for gemini_agriculture_research_assistant-0.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 5, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page