Skip to content

feat(core): Disable gen_ai message truncation by default when streamGenAiSpans is enabled#21603

Open
andreiborza wants to merge 5 commits into
developfrom
ab/stream-genai-spans-disable-truncationa
Open

feat(core): Disable gen_ai message truncation by default when streamGenAiSpans is enabled#21603
andreiborza wants to merge 5 commits into
developfrom
ab/stream-genai-spans-disable-truncationa

Conversation

@andreiborza

Copy link
Copy Markdown
Member

Setting streamGenAiSpans: true now disables gen_ai input truncation by default. Because gen_ai spans are sent as v2 span envelope items, they are not subject to the transaction payload-size limits that truncation works around.

Set enableTruncation: true on the respective AI integration to opt back into truncation.

@andreiborza andreiborza requested a review from a team as a code owner June 17, 2026 11:24
@andreiborza andreiborza requested review from JPeer264 and mydea and removed request for a team June 17, 2026 11:24
@andreiborza andreiborza force-pushed the ab/stream-genai-spans-disable-truncationa branch from fd07b23 to d2d45f5 Compare June 17, 2026 11:26
@andreiborza andreiborza requested review from nicohrubec and removed request for JPeer264 and mydea June 17, 2026 11:26
…GenAiSpans` is enabled

Setting `streamGenAiSpans: true` now disables gen_ai input truncation by default.
Because gen_ai spans are sent as v2 span envelope items, they are not subject to
the transaction payload-size limits that truncation works around.

Set `enableTruncation: true` on the respective AI integration to opt back into
truncation.
@andreiborza andreiborza force-pushed the ab/stream-genai-spans-disable-truncationa branch from d2d45f5 to f15a1f7 Compare June 17, 2026 11:27
@github-actions

github-actions Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Path Size % Change Change
@sentry/browser 27.45 kB - -
@sentry/browser - with treeshaking flags 25.88 kB - -
@sentry/browser (incl. Tracing) 45.88 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.11 kB - -
@sentry/browser (incl. Tracing, Profiling) 50.65 kB - -
@sentry/browser (incl. Tracing, Replay) 85.08 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 74.68 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 89.78 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 102.44 kB - -
@sentry/browser (incl. Feedback) 44.62 kB - -
@sentry/browser (incl. sendFeedback) 32.25 kB - -
@sentry/browser (incl. FeedbackAsync) 37.38 kB - -
@sentry/browser (incl. Metrics) 28.52 kB - -
@sentry/browser (incl. Logs) 28.76 kB - -
@sentry/browser (incl. Metrics & Logs) 29.45 kB - -
@sentry/react 29.25 kB - -
@sentry/react (incl. Tracing) 48.17 kB - -
@sentry/vue 32.56 kB - -
@sentry/vue (incl. Tracing) 47.74 kB - -
@sentry/svelte 27.48 kB - -
CDN Bundle 29.86 kB - -
CDN Bundle (incl. Tracing) 48.28 kB - -
CDN Bundle (incl. Logs, Metrics) 31.4 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 49.58 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 70.71 kB - -
CDN Bundle (incl. Tracing, Replay) 85.61 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 86.88 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 91.46 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.71 kB - -
CDN Bundle - uncompressed 88.8 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.04 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 93.5 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 150.02 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 218.33 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 264.91 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 268.87 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 278.61 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 282.56 kB - -
@sentry/nextjs (client) 50.58 kB - -
@sentry/sveltekit (client) 46.27 kB - -
@sentry/core/server 76.16 kB +0.04% +23 B 🔺
@sentry/core/browser 63.31 kB +0.04% +22 B 🔺
@sentry/node-core 61.84 kB - -
@sentry/node 128.3 kB +0.02% +13 B 🔺
@sentry/node - without tracing 74.22 kB -0.01% -1 B 🔽
@sentry/aws-serverless 85.47 kB -0.01% -1 B 🔽
@sentry/cloudflare (withSentry) - minified 174.48 kB - -
@sentry/cloudflare (withSentry) 436.52 kB - -

View base workflow run

Comment thread packages/core/src/tracing/ai/utils.ts Outdated
* Resolves whether truncation should be enabled.
* If the user explicitly set `enableTruncation`, that value is used.
* Otherwise, truncation is disabled when span streaming is active.
* Otherwise, truncation is disabled when gen_ai spans are streamed — either via full span

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: technically this should be more like "when gen_ai spans are sent through the span streaming/v2 path?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yep, updated in 6e648eb

Comment thread packages/core/src/tracing/ai/utils.ts Outdated
Comment thread CHANGELOG.md Outdated

### Important Changes

- **feat(core): Disable gen_ai message truncation by default when `streamGenAiSpans` is enabled ([#21603](https://github.com/getsentry/sentry-javascript/pull/21603))**

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

l: should we call this out? I think enableTruncation is not even documented and was meant more for internal testing no?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No, probably not. I'll move it out of important.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Removed in 6e648eb

andreiborza and others added 2 commits June 17, 2026 16:24
@andreiborza andreiborza requested a review from nicohrubec June 17, 2026 14:55

@nicohrubec nicohrubec left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nice

@andreiborza andreiborza enabled auto-merge (squash) June 17, 2026 14:56
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