Skip to content

feat: Remove truncation when stream_gen_ai_spans is enabled#6260

Open
alexander-alderman-webb wants to merge 18 commits into
webb/gen-ai-v2from
webb/remove-truncation
Open

feat: Remove truncation when stream_gen_ai_spans is enabled#6260
alexander-alderman-webb wants to merge 18 commits into
webb/gen-ai-v2from
webb/remove-truncation

Conversation

@alexander-alderman-webb
Copy link
Copy Markdown
Contributor

@alexander-alderman-webb alexander-alderman-webb commented May 12, 2026

Note: Depends on #6079

Description

Remove message popping and binary blob redaction when the experimental stream_gen_ai_spans is enabled.

Stop parametrizing truncation tests that fail when the stream_gen_ai_spans option is enabled.

Issues

Reminders

@alexander-alderman-webb alexander-alderman-webb changed the title feat: Remove truncation when stream_gen_ai_spans is enabled feat: Remove truncation when stream_gen_ai_spans is enabled May 12, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 12, 2026

Codecov Results 📊

282 passed | Total: 282 | Pass Rate: 100% | Execution Time: 42.74s

All tests are passing successfully.

❌ Patch coverage is 45.00%. Project has 14761 uncovered lines.

Files with missing lines (10)
File Patch % Lines
langchain.py 3.18% ⚠️ 578 Missing
langgraph.py 5.24% ⚠️ 217 Missing
utils.py 80.74% ⚠️ 99 Missing and 56 partials
ai_client.py 0.00% ⚠️ 148 Missing
openai.py 90.84% ⚠️ 63 Missing and 71 partials
anthropic.py 86.68% ⚠️ 59 Missing and 42 partials
utils.py 14.56% ⚠️ 88 Missing
invoke_agent.py 0.00% ⚠️ 82 Missing
invoke_agent.py 0.00% ⚠️ 47 Missing
litellm.py 87.92% ⚠️ 18 Missing and 16 partials

Generated by Codecov Action

@alexander-alderman-webb alexander-alderman-webb marked this pull request as ready for review May 12, 2026 14:04
@alexander-alderman-webb alexander-alderman-webb requested a review from a team as a code owner May 12, 2026 14:04
Comment thread sentry_sdk/ai/utils.py Outdated
Comment thread sentry_sdk/ai/utils.py Outdated
Comment thread tests/integrations/langgraph/test_langgraph.py
Copy link
Copy Markdown
Contributor

@sentrivana sentrivana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Two things:

  1. Does message truncation exclusively affect gen_ai spans currently? In other words, is it guaranteed that all spans that will become very large because of this change will be sent as v2 spans, or do we need an extra check to only lift the truncation for gen_ai spans specifically?
  2. If we remove the parametrization from the truncation tests, will we have test coverage for the "stream_gen_ai_spans=True should not truncate messages" code path?

@alexander-alderman-webb
Copy link
Copy Markdown
Contributor Author

  1. That's a possible edge case, and since it's unexpected for truncate_and_annotate_messages to not truncate in some cases, I moved the logic to the call sites in the integrations: 4ec3ff7
  2. By removing the parametrization we do not assert that there is no truncation when stream_gen_ai_spans=True. I don't have strong feelings here, and removed the parametrization because I try to avoid having to many tests that assert the absence of something 🤷 . Happy to parametrize the tests again as well.

@sentrivana
Copy link
Copy Markdown
Contributor

2. By removing the parametrization we _do not_ assert that there is no truncation when `stream_gen_ai_spans=True`. I don't have strong feelings here, and removed the parametrization because I try to avoid having to many tests that assert the absence of something 🤷 . Happy to parametrize the tests again as well.

I'm fine with removing the parametrization, but we should have some test coverage for the messages being there as expected, without truncation, in the stream_gen_ai_spans=True case. If this is already tested by another existing test not touched by this PR, fine to leave as is. If not, would be good to add a new test for that specifically.

@alexander-alderman-webb
Copy link
Copy Markdown
Contributor Author

Yes, that makes sense. I'll update other tests to accept two inputs messages and assert that both are present when the option is enabled (demonstrating that input truncation is disabled in this case).

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 962fd65. Configure here.

Comment thread tests/integrations/openai_agents/test_openai_agents.py
Copy link
Copy Markdown
Contributor

@sentrivana sentrivana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants