Skip to content

feat(core)!: Remove enableTruncation flag and all AI integrations truncation logic - #23045

Merged
nicohrubec merged 10 commits into
developfrom
feat/remove-gen-ai-text-truncation-2
Aug 6, 2026
Merged

feat(core)!: Remove enableTruncation flag and all AI integrations truncation logic#23045
nicohrubec merged 10 commits into
developfrom
feat/remove-gen-ai-text-truncation-2

Conversation

@nicohrubec

@nicohrubec nicohrubec commented Aug 5, 2026

Copy link
Copy Markdown
Member

This PR removes the enableTruncation flag and all related truncation logic for the AI integrations, including image and text truncation, as well as cleans out any truncation integration tests.

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.

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

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 30.12 kB - -
@sentry/browser - with treeshaking flags 28.32 kB - -
@sentry/browser (incl. Tracing) 47.53 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 47.54 kB - -
@sentry/browser (incl. Tracing, Profiling) 52.29 kB - -
@sentry/browser (incl. Tracing, Replay) 86.91 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 76.33 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 91.6 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 104.25 kB - -
@sentry/browser (incl. Feedback) 47.45 kB - -
@sentry/browser (incl. sendFeedback) 34.96 kB - -
@sentry/browser (incl. FeedbackAsync) 40.1 kB - -
@sentry/browser (incl. Metrics) 31.2 kB - -
@sentry/browser (incl. Logs) 31.41 kB - -
@sentry/browser (incl. Metrics & Logs) 32.11 kB - -
@sentry/react 31.93 kB - -
@sentry/react (incl. Tracing) 49.79 kB - -
@sentry/vue 35.2 kB - -
@sentry/vue (incl. Tracing) 49.51 kB - -
@sentry/svelte 30.14 kB - -
CDN Bundle 32.13 kB - -
CDN Bundle (incl. Tracing) 47.81 kB - -
CDN Bundle (incl. Logs, Metrics) 33.67 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 49.19 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 73.02 kB - -
CDN Bundle (incl. Tracing, Replay) 85.45 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 86.77 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 91.27 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.59 kB - -
CDN Bundle - uncompressed 95.27 kB - -
CDN Bundle (incl. Tracing) - uncompressed 142.78 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 99.9 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 146.75 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 224.6 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 262.03 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 266 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 275.74 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 279.69 kB - -
@sentry/nextjs (client) 52.36 kB - -
@sentry/sveltekit (client) 47.99 kB - -
@sentry/core/server 65.54 kB - -
@sentry/core/browser 51.82 kB - -
@sentry/node 119.17 kB -1.06% -1.27 kB 🔽
@sentry/node/import (ESM hook with diagnostics-channel injection) 0 B added added
@sentry/node - without tracing 84.09 kB - -
@sentry/aws-serverless 92.59 kB - -
@sentry/cloudflare (withSentry) - minified 212.56 kB -2.42% -5.26 kB 🔽
@sentry/cloudflare (withSentry) 524.74 kB -2.3% -12.32 kB 🔽

View base workflow run

nicohrubec and others added 3 commits August 5, 2026 11:16
…-text-truncation-2

# Conflicts:
#	dev-packages/node-integration-tests/suites/tracing/anthropic/test.ts
#	dev-packages/node-integration-tests/suites/tracing/langchain/v1/test.ts
#	dev-packages/node-integration-tests/suites/tracing/openai/test.ts
#	packages/server-utils/src/ai/vercel-ai/utils.ts
#	packages/server-utils/src/vercel-ai/vercel-ai-dc-subscriber.ts
Media stripping was the last piece of gen_ai input processing left after
truncation removal. Since gen_ai spans always use the v2 span path (not subject
to transaction payload-size limits), full input messages — including inline
media (base64 images, audio, files) — are now recorded verbatim.

- Delete `mediaStripping.ts` and the `getGenAiMessagesJsonString` helper; call
  sites now use `stringify` from `@sentry/core` directly.
- Collapse langchain's `normalizeContent` into `stringify` now that it no longer
  strips media.
- Remove media-stripping unit tests and the anthropic/openai media scenarios;
  the node integration suites already assert the full output format.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@nicohrubec nicohrubec changed the title feat(core)!: Remove enableTruncation flag and gen_ai text truncation feat(core)!: Remove enableTruncation flag and all AI integrations truncation logic Aug 6, 2026
nicohrubec and others added 3 commits August 6, 2026 11:14
The per-suite span-streaming tests existed only to prove input messages were
recorded in full (not truncated) — firing 50k-char payloads. With no
message-modifying logic left in the SDK, that assertion is redundant.

Reuse each suite's basic scenario against `instrument-streaming.mjs` and assert
the same core span attributes as the static-lifecycle base tests, so the
`traceLifecycle: 'stream'` path stays covered without the truncation framing or
giant payloads. Delete the now-unused `scenario-span-streaming.mjs` files.

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

`instrument-streaming.mjs` configures `traceLifecycle: 'stream'` (span
streaming), which is easily confused with the `scenario-stream*` files that
exercise streaming *responses* — a different concept. Rename to
`instrument-span-streaming.mjs` to disambiguate.

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

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 29afb51. Configure here.

nicohrubec and others added 2 commits August 6, 2026 11:59
…ale comments

With no message-truncation logic left in the SDK, tests that assert "we keep the
full message" or use giant payloads to prove non-truncation exercise behavior
that no longer exists.

- Remove the duplicate "keeps all messages including inline media" test (same
  code path as the plain serialization test).
- Reword the 200k-char "without truncation" anthropic test to a basic input
  messages check, drop the "non-array input" case (pure `stringify`, covered in
  core), and make the empty-array test self-contained.
- Fix stale comments/JSDoc that still referenced truncation.

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

The span-streaming tests reuse the basic scenarios, which also emit event
envelopes (error-model exceptions, captureMessage). The tests only assert on a
span envelope and don't ignore events, so under the ordered envelope matcher an
event arriving before the span would fail the test — it passed only because the
streamed span happened to match first. Add `.ignore('event')` so the outcome no
longer depends on envelope timing.

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

Copy link
Copy Markdown
Member Author

torch

@nicohrubec
nicohrubec marked this pull request as ready for review August 6, 2026 10:57
@nicohrubec
nicohrubec requested review from a team as code owners August 6, 2026 10:57
@nicohrubec
nicohrubec requested review from JPeer264, andreiborza and mydea and removed request for a team and mydea August 6, 2026 10:57
Comment thread packages/server-utils/src/ai/workers-ai/utils.ts

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

Image

…ests

`addRequestAttributes` no longer takes the `enableTruncation` parameter, but six
call sites in the workers-ai utils test still passed a trailing `false`. JS
ignores the extra arg so the tests passed, but they were stale — remove it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@nicohrubec
nicohrubec merged commit 246c98f into develop Aug 6, 2026
271 checks passed
@nicohrubec
nicohrubec deleted the feat/remove-gen-ai-text-truncation-2 branch August 6, 2026 11:24
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.

3 participants