fix(tracing): Strip runtime turn context from observable input messages#404
fix(tracing): Strip runtime turn context from observable input messages#404sergical 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
|
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) |
|
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 |
|
Superseded by #412. The replacement keeps GenAI span messages faithful to the actual model transcript and removes non-causal prompt context at assembly time instead of cleaning span payloads for display. |
Keep model-visible prompt context causal and non-duplicative. This supersedes GH-404 by fixing prompt assembly instead of cleaning span payloads for display. **Runtime Context** User turns keep causal runtime identifiers in `<runtime-turn-context>`, including `gen_ai.conversation.id` and the active `trace_id`, so the bot can correlate its own turn with telemetry and debug data. Internal model names, synthetic channel labels, Slack capability summaries, thinking-level routing metadata, runtime version, and duplicate sandbox paths are no longer exposed in the prompt. **Prompt Shape** Empty capabilities, context, runtime, and loaded-skill blocks are omitted instead of emitted as placeholder markup. When thread background is needed, it remains a top-level sibling block next to the current instruction. **Thread History** When Pi history already carries prior messages, the fresh prompt continues to omit the Slack transcript background so previous user messages are not duplicated. Supersedes GH-404 --------- Co-authored-by: OpenAI GPT-5 Codex <codex@openai.com> Co-authored-by: GPT-5 Codex <gpt-5-codex@openai.com>

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