Skip to content

feat(core)!: Remove enableTruncation flag and gen_ai text truncation - #22548

Draft
nicohrubec wants to merge 4 commits into
developfrom
feat/remove-gen-ai-text-truncation
Draft

feat(core)!: Remove enableTruncation flag and gen_ai text truncation#22548
nicohrubec wants to merge 4 commits into
developfrom
feat/remove-gen-ai-text-truncation

Conversation

@nicohrubec

@nicohrubec nicohrubec commented Jul 23, 2026

Copy link
Copy Markdown
Member

Remove genai text truncation:

  • Removes the enableTruncation integration option and all gen_ai text-truncation logic (messageTruncation.ts); byte-limit cropping and "keep only the last message" are gone now that gen_ai spans always use the v2 span path.
  • Keeps inline media stripping and makes it unconditional, so this is now being applied to both transaction and span streaming paths.
  • All input messages are now recorded in full (media stripped), stripping is consolidated into mediaStripping.ts.
  • Covers both @sentry/core and @sentry/server-utils.
  • Removes truncation specific tests. Adds a new span streaming scenario because the span streaming path was so far only tested together with truncation.

nicohrubec and others added 3 commits July 22, 2026 16:54
Removes the `streamGenAiSpans` client option. The behavior it gated
(extracting gen_ai spans from transactions into a v2 span envelope
container) was already the default and is now unconditional — there is
no longer a way to opt out.

For static transactions, `extractGenAiSpansFromEvent` always pulls
gen_ai spans into a v2 span container. For full span streaming
(`traceLifecycle: 'stream'`), the existing `hasSpanStreamingEnabled`
guard still short-circuits so spans are not extracted twice.

Because gen_ai spans now always take the v2 path (not subject to the
transaction payload-size limits that truncation works around),
`shouldEnableTruncation` simplifies to `!getClient()`. The
`enableTruncation` escape hatch is intentionally left in place for a
follow-up.

Test suites that set `streamGenAiSpans: false` to assert on
`transaction.spans` are migrated to assert on the v2 span container;
redundant `streamGenAiSpans: true` config lines are removed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ength` attribute

This internal SDK-meta span attribute only ever signaled how many gen_ai
input messages existed before truncation dropped some. It carries no
meaning for consumers on its own and is being removed ahead of the
truncation removal. Text truncation itself is unchanged by this commit.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Removes the `enableTruncation` integration option and the gen_ai message
text-truncation machinery. Now that gen_ai spans always ride the v2 span
path (far larger size limits than legacy transactions), the byte-limit
cropping and "keep only the last message" reduction is dead weight.

Inline media stripping is kept and is now unconditional: previously media
was only stripped on the truncation path, so with truncation off inline
base64 could leak into span attributes for openai/anthropic/google-genai/
vercel-ai/workers-ai. `getGenAiMessagesJsonString` now always strips media
before serializing, keeping all messages.

Media-stripping logic is consolidated into `mediaStripping.ts`;
`messageTruncation.ts` is deleted. Truncation-specific test scenarios and
instruments are removed; image-stripping tests are re-pointed at the
default recording instruments, and full span-streaming coverage is kept
via non-truncation streaming tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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 2 potential issues.

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 e541815. Configure here.

Comment thread packages/core/src/server-exports.ts
@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.77 kB -0.06% -16 B 🔽
@sentry/browser - with treeshaking flags 26.21 kB -0.06% -14 B 🔽
@sentry/browser (incl. Tracing) 46.29 kB -0.04% -16 B 🔽
@sentry/browser (incl. Tracing + Span Streaming) 48.08 kB +0.01% +4 B 🔺
@sentry/browser (incl. Tracing, Profiling) 51.12 kB +0.01% +5 B 🔺
@sentry/browser (incl. Tracing, Replay) 85.57 kB -0.02% -11 B 🔽
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 75.21 kB -0.02% -11 B 🔽
@sentry/browser (incl. Tracing, Replay with Canvas) 90.28 kB -0.02% -12 B 🔽
@sentry/browser (incl. Tracing, Replay, Feedback) 102.93 kB -0.04% -32 B 🔽
@sentry/browser (incl. Feedback) 44.96 kB +0.01% +3 B 🔺
@sentry/browser (incl. sendFeedback) 32.57 kB -0.05% -14 B 🔽
@sentry/browser (incl. FeedbackAsync) 37.63 kB -0.01% -2 B 🔽
@sentry/browser (incl. Metrics) 28.86 kB -0.06% -17 B 🔽
@sentry/browser (incl. Logs) 29.08 kB -0.09% -24 B 🔽
@sentry/browser (incl. Metrics & Logs) 29.78 kB -0.06% -16 B 🔽
@sentry/react 29.56 kB -0.09% -24 B 🔽
@sentry/react (incl. Tracing) 48.59 kB -0.02% -5 B 🔽
@sentry/vue 33.2 kB -0.06% -18 B 🔽
@sentry/vue (incl. Tracing) 48.25 kB -0.05% -20 B 🔽
@sentry/svelte 27.79 kB -0.07% -19 B 🔽
CDN Bundle 30.1 kB -0.02% -5 B 🔽
CDN Bundle (incl. Tracing) 48.16 kB -0.02% -7 B 🔽
CDN Bundle (incl. Logs, Metrics) 31.69 kB -0.02% -4 B 🔽
CDN Bundle (incl. Tracing, Logs, Metrics) 49.48 kB -0.02% -5 B 🔽
CDN Bundle (incl. Replay, Logs, Metrics) 70.95 kB -0.01% -1 B 🔽
CDN Bundle (incl. Tracing, Replay) 85.72 kB -0.01% -6 B 🔽
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 87.02 kB -0.01% -1 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback) 91.5 kB -0.01% -1 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.78 kB - -
CDN Bundle - uncompressed 89.72 kB -0.04% -33 B 🔽
CDN Bundle (incl. Tracing) - uncompressed 144.82 kB -0.03% -33 B 🔽
CDN Bundle (incl. Logs, Metrics) - uncompressed 94.43 kB -0.04% -33 B 🔽
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 148.8 kB -0.03% -33 B 🔽
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 219.19 kB -0.02% -33 B 🔽
CDN Bundle (incl. Tracing, Replay) - uncompressed 264.06 kB -0.02% -33 B 🔽
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 268.02 kB -0.02% -33 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 277.76 kB -0.02% -33 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 281.71 kB -0.02% -33 B 🔽
@sentry/nextjs (client) 51.1 kB -0.06% -26 B 🔽
@sentry/sveltekit (client) 46.71 kB -0.08% -33 B 🔽
@sentry/core/server 79.31 kB -1.1% -878 B 🔽
@sentry/core/browser 51.98 kB -0.03% -14 B 🔽
@sentry/node 123.44 kB -0.96% -1.19 kB 🔽
@sentry/node (incl. diagnostics channel injection) 148.85 kB -0.81% -1.21 kB 🔽
@sentry/node/import (ESM hook with diagnostics-channel injection) 70.03 kB -0.01% -2 B 🔽
@sentry/node - without tracing 74.43 kB -0.45% -330 B 🔽
@sentry/aws-serverless 83.92 kB -0.4% -332 B 🔽
@sentry/cloudflare (withSentry) - minified 194.38 kB -1.15% -2.26 kB 🔽
@sentry/cloudflare (withSentry) 477.98 kB -1.22% -5.89 kB 🔽

View base workflow run

The migrated media-stripping test hard-coded `auto.ai.anthropic`, which is
`auto.ai.orchestrion.anthropic` under the orchestrion runtime. Gate it on
`isOrchestrionEnabled()` like the rest of the suite.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Base automatically changed from feat/remove-enable-truncation-flag to develop July 29, 2026 09:48
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.

1 participant