fix(tracing): Strip runtime turn context from observable input messages#404
Open
sergical wants to merge 1 commit into
Open
fix(tracing): Strip runtime turn context from observable input messages#404sergical wants to merge 1 commit into
sergical wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…input messages The `gen_ai.input.messages` attribute on `gen_ai.chat` spans included internal runtime metadata and XML wrapper blocks as part of user message content. The Sentry Conversations view reads this attribute and renders it as the user message. Clean user messages before serializing to `gen_ai.input.messages`: 1. Drop `<runtime-turn-context>` content parts (skills, config, capabilities). 2. Unwrap `<current-instruction>` to extract the actual user text. 3. Strip `<thread-background>`, `<session-context>`, `<turn-context>` blocks so prior assistant responses don't bleed into user messages. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
6686c3d to
b2add82
Compare
Member
|
im not totally understanding of the problem i dont want the messages being sent to sentry to be at all different than the actual messages sent upstream, but if we have a giant xml tag wrapping everything thats probably some minor cleanup to be done (i havent hand audited the prompt) |
Member
Author
Member
|
do you mean in the thread transcript bits? if there is i def think this is more of a bug in the context gathering than a need for a change in reporting definitely the reporting should never falsify records |
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.

Summary
<runtime-turn-context>content parts from user messages before serializing togen_ai.input.messagesongen_ai.chatspans.<current-instruction>to extract just the user's actual text.<thread-background>,<session-context>,<turn-context>blocks so prior assistant responses don't bleed into user messages.After this change, the Conversations view shows clean user messages instead of internal runtime metadata.
Context
The Sentry Conversations view reads
gen_ai.input.messagesfromgen_ai.chatspans and extracts user messages viamessages.findLast(m => m.role === 'user'). Junior's user messages contained:<runtime-turn-context>content part with skills, config, and capabilities (separate content part — now dropped)<thread-background>(prior conversation history including assistant responses),<session-context>,<turn-context>, and<current-instruction>(now unwrapped/stripped)The runtime context is still available via
gen_ai.system_instructionson the span, so no observability is lost.Test plan
🤖 Generated with Claude Code