fix(google_genai): populate response_id and model_version in streaming accumulator#5914
Closed
NIK-TIGER-BILL wants to merge 1 commit intogetsentry:masterfrom
Closed
Conversation
…g accumulator In `accumulate_streaming_response()`, `response_id` and `model` are initialised to `None` and never updated from the streaming chunks, so streaming spans always have `null` for `gen_ai.response.id` and `gen_ai.response.model`. The non-streaming path in `utils.py` already captures both fields via `getattr(response, 'response_id', None)` and `getattr(response, 'model_version', None)`. Fix: read those same attributes from each chunk inside the accumulation loop and keep the first non-empty value, which is the same behaviour the Gemini SDK itself uses for per-chunk metadata. Fixes getsentry#5812 Signed-off-by: NIK-TIGER-BILL <nik.tiger.bill@github.com>
|
This PR has been automatically closed. The referenced issue does not show a discussion between you and a maintainer. To avoid wasted effort on both sides, please discuss your proposed approach in the issue first and wait for a maintainer to respond before opening a PR. Please review our contributing guidelines for more details. |
Contributor
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Langchain
Bug Fixes 🐛Ci
Google Genai
Openai
Other
Documentation 📚
Internal Changes 🔧Langchain
Openai
Other
Other
🤖 This preview updates automatically when you update the PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #5812
Problem
accumulate_streaming_response()insentry_sdk/integrations/google_genai/streaming.pyinitialisesresponse_idandmodeltoNoneand never reads them from the streaming chunks. This means streaming spans always havenullforgen_ai.response.idandgen_ai.response.model.The non-streaming code path in
utils.pyalready captures both fields correctly:Fix
Read
chunk.response_idandchunk.model_versioninside the chunk-accumulation loop, keeping the first non-empty value:This mirrors how the Gemini SDK itself exposes metadata on streaming chunks and is consistent with the non-streaming code path.