Skip to content

Bug: Streaming responses don't capture response_id or model_version #5812

Open

Description

@ericapisani

Problem

In streaming.py, the accumulate_streaming_response() function initializes response_id and model to None (lines 53-54) but never populates them from the streaming chunks. The accumulation loop (lines 56-83) never reads chunk.response_id or chunk.model_version.

This means streaming responses will always have null for gen_ai.response.id and gen_ai.response.model.

The non-streaming path correctly captures both in utils.py:886-890:

if getattr(response, "response_id", None):
    span.set_data(SPANDATA.GEN_AI_RESPONSE_ID, response.response_id)
if getattr(response, "model_version", None):
    span.set_data(SPANDATA.GEN_AI_RESPONSE_MODEL, response.model_version)

Files

  • sentry_sdk/integrations/google_genai/streaming.py — accumulate_streaming_response()

Acceptance Criteria

  • Streaming chunks are checked for response_id and model_version
  • gen_ai.response.id and gen_ai.response.model are populated on streaming spans
  • Test added to verify streaming responses capture these fields

Activity

  1. linear-code commented on Mar 24, 2026

    @linear-code
  2. NIK-TIGER-BILL commented on Mar 30, 2026

    @NIK-TIGER-BILL
  3. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Mar 30, 2026
  4. Bahtya commented on Apr 6, 2026

    @Bahtya

    I'd like to work on this. The fix is straightforward — extract response_id and model_version from streaming chunks in the accumulation loop, using getattr to safely handle missing attributes. I've identified the exact location in sentry_sdk/integrations/google_genai/streaming.py. Happy to submit a PR if this approach looks correct.

  5. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Apr 21, 2026
  6. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Aug 11, 2026
  7. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Sep 15, 2026
  8. added
    Junior: repro
    on Nov 12, 2026
  9. sentry-junior commented on Nov 12, 2026

    @sentry-junior
    Contributor

    Reproduced in getsentry/repro#71. Draft fix #8260 was closed without merging.

  10. added
    Junior: repro
    and removed
    Junior: repro
    on Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugJunior: reproPythonSpans

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions