Skip to content

fix: accept grounding chunk metadata#2562

Open
he-yufeng wants to merge 1 commit into
googleapis:mainfrom
he-yufeng:fix/grounding-chunk-metadata
Open

fix: accept grounding chunk metadata#2562
he-yufeng wants to merge 1 commit into
googleapis:mainfrom
he-yufeng:fix/grounding-chunk-metadata

Conversation

@he-yufeng

Copy link
Copy Markdown
Contributor

Summary

Fixes #2510.

Some Vertex batch responses with Google Search grounding include groundingMetadata.groundingChunks[].chunkMetadata. The SDK currently rejects that payload because GroundingChunk forbids unknown fields and does not declare chunk_metadata.

This adds the field to both the model and TypedDict shape so the response can validate without dropping the metadata.

Testing

python -m pytest google\genai\tests\types\test_types.py::test_generate_content_response_accepts_grounding_chunk_metadata -q
python -m pytest google\genai\tests\types\test_types.py -q
python -m py_compile google\genai\types.py google\genai\tests\types\test_types.py
git diff --check

I also ran python -m pyink --check google\genai\types.py google\genai\tests\types\test_types.py; it wants to reformat the existing generated/style-preserved files wholesale, so I did not apply it.

@Venkaiahbabuneelam Venkaiahbabuneelam self-assigned this Jun 8, 2026
@Venkaiahbabuneelam Venkaiahbabuneelam added the size:M Code changes between 10-40 lines label Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M Code changes between 10-40 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Validating batch response with Google Search grounding against GenerateContentResponse causes validation error

2 participants