Skip to content

Google GenAI: grounding metadata from Google Search not captured in span output #153

@braintrust-bot

Description

@braintrust-bot

Gap

When Gemini models use Google Search grounding (via the google_search tool), the response includes a grounding_metadata field containing search results, citations, search queries, and search entry points. This metadata is silently dropped from the span output — only the model's text response is captured.

Google Search grounding is one of Gemini's key differentiating features, allowing models to ground their responses in real-time web data. Without capturing the grounding metadata, users cannot verify which search results the model used, audit citation accuracy, or debug grounding quality.

What is missing

The grounding_metadata field on GenerateContentResponse.candidates[].grounding_metadata should be extracted and logged in the span output. This includes:

  • grounding_chunks — the actual search result snippets used by the model
  • grounding_supports — which parts of the response are supported by which chunks
  • search_entry_point — the rendered search widget URL
  • web_search_queries — the queries the model issued to Google Search

The tool declarations (google_search) pass through _serialize_tools() in the input, but the grounding results on the response side are not extracted.

Braintrust docs status

not_found — the Gemini integration page documents generate_content, streaming, function calling, structured outputs, thinking tokens, and context caching, but does not mention grounding or Google Search integration.

Upstream sources

  • Google GenAI grounding guide: https://ai.google.dev/gemini-api/docs/grounding
  • google.genai.types.GroundingMetadata — contains grounding_chunks, grounding_supports, search_entry_point, web_search_queries
  • Grounding is GA for Gemini 1.5 and 2.0 models

Local files inspected

  • py/src/braintrust/wrappers/google_genai/__init__.py:
    • _gc_process_result() — processes non-streaming results; extracts text, usage_metadata, and content.parts but not grounding_metadata
    • _serialize_tools() — serializes tool declarations (including google_search) for span input
    • Zero references to grounding_metadata, grounding_chunks, grounding_supports, search_entry_point, or web_search_queries
  • py/src/braintrust/wrappers/test_google_genai.py — no grounding-related test cases
  • py/src/braintrust/integrations/adk/tracing.py — the ADK integration also does not extract grounding metadata

Metadata

Metadata

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions