Skip to content

fix(core): Improve message truncation for multimodal content and normalize streaming span names#19500

Merged
RulaKhaled merged 5 commits intodevelopfrom
fix-ai-issues
Feb 26, 2026
Merged

fix(core): Improve message truncation for multimodal content and normalize streaming span names#19500
RulaKhaled merged 5 commits intodevelopfrom
fix-ai-issues

Conversation

@RulaKhaled
Copy link
Member

This PR introduces some fixes across AI integrations.

  1. Normalize streaming span description
    Removes the stream-response suffix from span descriptions across OpenAI, Anthropic, and Google GenAI integrations. Streaming and non-streaming spans now use the same naming format (e.g., chat gpt-4 instead of chat gpt-4 stream-response), making grouping and filtering more consistent.

  2. Expand multimodal media stripping
    Adds detection and redaction of three additional inline media formats in truncateGenAiMessages:

  • OpenAI vision format with nested image_url objects ({ image_url: { url: "data:..." } })
  • OpenAI input_audio parts ({ type: "input_audio", input_audio: { data: "..." } })
  • OpenAI file parts with inline data ({ type: "file", file: { file_data: "..." } })
  1. Rename redaction placeholder
    Changes the placeholder for stripped binary data from [Filtered] to [Blob substitute] to better communicate what happened.

  2. Fix off-by-one in truncation byte accounting
    Subtracts the 2-byte JSON array wrapper ([ and ]) from the effective max bytes budget, and fixes a boundary condition in truncateTextByBytes to avoid strings that land exactly on the byte limit.

Closes #19496 #19479

@github-actions
Copy link
Contributor

github-actions bot commented Feb 24, 2026

size-limit report 📦

Path Size % Change Change
@sentry/browser 25.62 kB - -
@sentry/browser - with treeshaking flags 24.12 kB - -
@sentry/browser (incl. Tracing) 42.42 kB - -
@sentry/browser (incl. Tracing, Profiling) 47.09 kB - -
@sentry/browser (incl. Tracing, Replay) 81.24 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 70.86 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 85.94 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 98.2 kB - -
@sentry/browser (incl. Feedback) 42.43 kB - -
@sentry/browser (incl. sendFeedback) 30.29 kB - -
@sentry/browser (incl. FeedbackAsync) 35.34 kB - -
@sentry/browser (incl. Metrics) 26.79 kB - -
@sentry/browser (incl. Logs) 26.93 kB - -
@sentry/browser (incl. Metrics & Logs) 27.61 kB - -
@sentry/react 27.37 kB - -
@sentry/react (incl. Tracing) 44.76 kB - -
@sentry/vue 30.07 kB - -
@sentry/vue (incl. Tracing) 44.27 kB - -
@sentry/svelte 25.64 kB - -
CDN Bundle 28.16 kB - -
CDN Bundle (incl. Tracing) 43.25 kB - -
CDN Bundle (incl. Logs, Metrics) 29 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 44.09 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 68.08 kB - -
CDN Bundle (incl. Tracing, Replay) 80.13 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 80.99 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 85.64 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 86.53 kB - -
CDN Bundle - uncompressed 82.34 kB - -
CDN Bundle (incl. Tracing) - uncompressed 128.06 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 85.18 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 130.89 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 208.84 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 244.94 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 247.76 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 257.85 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 260.66 kB - -
@sentry/nextjs (client) 47.17 kB - -
@sentry/sveltekit (client) 42.88 kB - -
@sentry/node-core 52.18 kB +0.03% +11 B 🔺
@sentry/node 173.61 kB +0.1% +162 B 🔺
@sentry/node - without tracing 97.33 kB +0.02% +10 B 🔺
@sentry/aws-serverless 113.13 kB +0.01% +9 B 🔺

View base workflow run

@github-actions
Copy link
Contributor

github-actions bot commented Feb 24, 2026

node-overhead report 🧳

Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.

Scenario Requests/s % of Baseline Prev. Requests/s Change %
GET Baseline 8,901 - 8,641 +3%
GET With Sentry 1,583 18% 1,654 -4%
GET With Sentry (error only) 5,987 67% 5,989 -0%
POST Baseline 1,156 - 1,170 -1%
POST With Sentry 548 47% 575 -5%
POST With Sentry (error only) 1,021 88% 1,044 -2%
MYSQL Baseline 3,169 - 3,201 -1%
MYSQL With Sentry 308 10% 396 -22%
MYSQL With Sentry (error only) 2,554 81% 2,595 -2%

View base workflow run

Copy link

@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.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

('type' in part && (part.type === 'blob' || part.type === 'base64')) ||
'b64_json' in part ||
('type' in part && 'result' in part && part.type === 'image_generation') ||
('uri' in part && typeof part.uri === 'string' && part.uri.startsWith('data:'))
Copy link
Member

Choose a reason for hiding this comment

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

m: could we refactor these into some more helpers or add some kind of explanation what we check with these cases here?

Copy link
Member Author

Choose a reason for hiding this comment

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

sure

Copy link
Member

@nicohrubec nicohrubec left a comment

Choose a reason for hiding this comment

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

thanks!

@RulaKhaled RulaKhaled enabled auto-merge (squash) February 26, 2026 11:52
@RulaKhaled RulaKhaled merged commit ab883e7 into develop Feb 26, 2026
437 of 439 checks passed
@RulaKhaled RulaKhaled deleted the fix-ai-issues branch February 26, 2026 12:17
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.

Resolve Nodejs Langchain LLM tests failures

2 participants