Skip to content

grounding_metadata is missing randomly #2189

@leeivan1007

Description

@leeivan1007

This is a product issue — the API server return grounding_metadata randomly.
Only 3 out of 20 responses contained a message.

Environment details

  • Programming language: 3.12.9
  • OS: Mac
  • Language runtime version: 3.12.9
  • Package version: 1.68.0
  • Model: gemini-3-flash-preview

Steps to reproduce

n = 0

for _ in range(20):

    response = client.models.generate_content(
        model="gemini-3-flash-preview",
        contents=contents,
        config=types.GenerateContentConfig(
            tools=[
                types.Tool(
                    file_search=types.FileSearch(
                        file_search_store_names=[file_search_store.name]
                    )
                )
            ]
        )
    )

    model_response = response.model_dump()

    n += 1

    if model_response['candidates'][0]['grounding_metadata']:
        print(f"Running Step {n}: Got grounding_metadata")
    else:
        print(f"Running Step {n}: Did't got grounding_metadata")

Ouput:

Running Step 1: Did't got grounding_metadata
Running Step 2: Did't got grounding_metadata
Running Step 3: Did't got grounding_metadata
Running Step 4: Did't got grounding_metadata
Running Step 5: Did't got grounding_metadata
Running Step 6: Did't got grounding_metadata
Running Step 7: Got grounding_metadata
Running Step 8: Did't got grounding_metadata
Running Step 9: Did't got grounding_metadata
Running Step 10: Did't got grounding_metadata
Running Step 11: Did't got grounding_metadata
Running Step 12: Did't got grounding_metadata
Running Step 13: Did't got grounding_metadata
Running Step 14: Did't got grounding_metadata
Running Step 15: Got grounding_metadata
Running Step 16: Got grounding_metadata
Running Step 17: Did't got grounding_metadata
Running Step 18: Did't got grounding_metadata
Running Step 19: Did't got grounding_metadata
Running Step 20: Did't got grounding_metadata

I'm not sure why data isn't being retrieved sometimes. I hope this issue can be resolved soon. Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p2Moderately-important priority. Fix may not be included in next release.type: 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