feat(core)!: Remove enableTruncation flag and gen_ai text truncation#22516
Draft
nicohrubec wants to merge 3 commits into
Draft
feat(core)!: Remove enableTruncation flag and gen_ai text truncation#22516nicohrubec wants to merge 3 commits into
enableTruncation flag and gen_ai text truncation#22516nicohrubec wants to merge 3 commits into
Conversation
Removes the `enableTruncation` integration option and the gen_ai message text-truncation machinery. Now that gen_ai spans always ride the v2 span path (which has far larger size limits than legacy transactions), the byte-limit text cropping and "keep only the last message" behavior that existed to fit gen_ai payloads into transaction size limits is no longer needed. Inline media stripping is kept and, importantly, is now unconditional. Previously image/media stripping was entangled with truncation: for openai/anthropic/google-genai/vercel-ai/workers-ai it only happened on the `getTruncatedJsonString` path, so with truncation off (the default) inline base64 blobs could leak into span attributes. `getGenAiMessagesJsonString` now always strips inline media before serializing, keeping all messages. Also removes the now-meaningless `sentry.sdk_meta.gen_ai.input.messages.original_length` attribute (it only ever signaled that truncation dropped messages). Media-stripping logic is consolidated into `mediaStripping.ts`; `messageTruncation.ts` is deleted. Truncation-specific test scenarios and instruments are removed, and the image-stripping tests are re-pointed at the default recording instruments. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
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.
Reviewed by Cursor Bugbot for commit b75fca6. Configure here.
Contributor
size-limit report 📦
|
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The deleted truncation tests were the only ones exercising `traceLifecycle: 'stream'` for openai/anthropic/google-genai/langchain/ langgraph gen_ai spans. Re-point the (otherwise orphaned) scenario-span-streaming.mjs + instrument-streaming.mjs at a new non-truncation test per provider that asserts full gen_ai input messages are recorded under span streaming. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Stacked on #22495. Removes the
enableTruncationintegration option and the gen_ai message text-truncation machinery, while keeping (and fixing) inline media stripping.Now that gen_ai spans always ride the v2 span path — which has far larger size limits than legacy transactions — the byte-limit text cropping and the "keep only the last message" reduction that existed to fit gen_ai payloads into transaction size limits are dead weight. This is a follow-up to the
streamGenAiSpansremoval.Decisions
getTruncatedJsonStringpath. With truncation off (the default sincestreamGenAiSpansshipped), inline base64 blobs could leak into span attributes for those providers.getGenAiMessagesJsonString(the replacement) always strips inline media before serializing. langchain/langgraph already stripped media independently vianormalizeContent, so they were unaffected and keep that path.sentry.sdk_meta.gen_ai.input.messages.original_lengthremoved. It existed only to signal that truncation dropped messages; with no truncation it would always equal the real count.@sentry/coreand@sentry/server-utils(the tracing-channel + vercel-ai dc-subscriber implementations).enableTruncationand this cleanup were pre-noted inMIGRATION.md, so that file is left as-is.Structure
mediaStripping.ts(stripInlineMediaFromMessagesmoved there and exported);messageTruncation.tsis deleted.instrument-with-pii.mjs) since stripping no longer depends on a truncation flag.