feat(core)!: Remove enableTruncation flag and all AI integrations truncation logic - #23045
feat(core)!: Remove enableTruncation flag and all AI integrations truncation logic#23045nicohrubec wants to merge 8 commits into
enableTruncation flag and all AI integrations truncation logic#23045Conversation
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>
size-limit report 📦
|
…-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>
enableTruncation flag and gen_ai text truncationenableTruncation flag and all AI integrations truncation logic
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>
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.
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.
| expect(chatSpan).toBeDefined(); | ||
| expect(completionSpan!.attributes[GEN_AI_PROVIDER_NAME].value).toBe('anthropic'); | ||
| expect(completionSpan!.attributes['sentry.op'].value).toBe('gen_ai.chat'); | ||
| expect(completionSpan!.attributes['sentry.origin'].value).toBe('auto.ai.anthropic'); |
There was a problem hiding this comment.
Span streaming tests reuse scenarios emitting error events
High Severity
The span-streaming tests now reuse scenario.mjs / scenario-chat.mjs, which exercise error-model requests (and for Anthropic also captureMessage) and therefore emit event envelopes before any span envelope is flushed. Since these runners neither ignore('event') nor expect those events, the ordered envelope matcher hits an event where a span is expected and fails. The same gap exists in the LangChain suite.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit 29afb51. Configure here.
…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>


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