Skip to content

types.GoogleSearch doesn't return GroundingChunk with actual text snippet #3235

Open

Description

@guillermojp

Running generate_content with types.Tool(google_search=types.GoogleSearch()) returns candidates with format:

GroundingChunk(
  web=GroundingChunkWeb(
    domain='somedomain.com',
    title='somedomain.com',
    uri='https://vertexaisearch.cloud.google.com/grounding-api-redirect/...'
  )
)

The grounding chunk should be accompanied by the actual snippet/full text used during generation. Otherwise, results are not possible to validate other than by fetching the original link.

Environment details

  • Programming language: python
  • OS: macos
  • Language runtime version: 3.14.3
  • Package version: 2.33.0

Steps to reproduce

from google.genai import types, Client

client = Client(vertexai=True, project="...", location="...", credentials="...")
response = await client.aio.models.generate_content(
    model="gemini-3.8-flash",
    contents="why doesn't google genai with GoogleSearch grounding return GroundingChunk with text snippets?",
    config=types.GenerateContentConfig(tools=[types.Tool(google_search=types.GoogleSearch())]),
)
print(response.candidates[-1].grounding_metadata.grounding_chunks[0].web)
>>> GroundingChunk(
>>>   web=GroundingChunkWeb(
>>>     domain='somedomain.com',
>>>     title='somedomain.com',
>>>     uri='https://vertexaisearch.cloud.google.com/grounding-api-redirect/...'
>>>   )
>>> )

Thanks!

Activity

  1. added
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    priority: p2Moderately-important priority. Fix may not be included in next release.
    on Oct 28, 2026
  2. Venkaiahbabuneelam commented on Oct 29, 2026

    @Venkaiahbabuneelam

    Hi @guillermojp,

    The GroundingChunk.web object returned by Google Search grounding provides only uri and title by backend API design; search index text snippets are not returned in the web grounding chunk payload.

    To correlate sources with the generated output without fetching the URLs, inspect candidate.grounding_metadata.grounding_supports. This structure maps segments in the generated response to the corresponding chunk indices:

    metadata = response.candidates[0].grounding_metadata
    if metadata.grounding_supports:
        for support in metadata.grounding_supports:
            print(f"Segment: {support.segment.text}")
            sources = [metadata.grounding_chunks[i].web.uri for i in support.grounding_chunk_indices]
            print(f"Sources: {sources}")

    If your workload strictly requires retrieved text snippets inside grounding_chunks, consider using Vertex AI Search data stores (types.VertexAISearch), which return retrieved_context chunks containing the snippet text.

    For details on grounding structures and response fields, refer to the Vertex AI Grounding overview.

    Because GroundingChunk fields are defined and populated directly by the Vertex AI backend service rather than the Python SDK, adding search snippet content to types.GoogleSearch chunks would require a service-level update. You can submit a feature request directly through Google Cloud Support or the Cloud Console feedback channel..

    Thanks

  3. github-actions commented on Nov 6, 2026

    @github-actions

    This issue has been marked as stale because it has been open for 7 days with no activity. It will be closed in 2 days if no further activity occurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.status:awaiting user responsestatus:staletype: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions