fix(llmobs): read the text of Bedrock Converse guardContent blocks - #10173
fix(llmobs): read the text of Bedrock Converse guardContent blocks#10173colecrawford-reify wants to merge 1 commit into
Conversation
A guardContent block scopes a Bedrock guardrail to part of a Converse turn, usually the user question. The LLM Observability walker treated it as an unsupported block and recorded a placeholder, so the llm span kept the surrounding context and lost the question. Read guardContent.text.text like a plain text block. Input-only block, so response and stream extraction are unchanged. Fixes DataDog#10172
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ebe192168c
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| } else if (typeof block.guardContent?.text?.text === 'string') { | ||
| content += block.guardContent.text.text |
There was a problem hiding this comment.
Extract guarded text from system blocks too
When a caller places guardContent in the top-level system array—where Bedrock permits it as a SystemContentBlock—this new branch never runs: extractRequestParamsConverse invokes this helper only for params.messages, while its system loop accepts only block.text. Consequently, guarded system instructions are still dropped entirely from the LLMObs input; reuse this extraction for system blocks or add equivalent handling and coverage.
AGENTS.md reference: AGENTS.md:L79-L80
Useful? React with 👍 / 👎.
What does this PR do?
Reads the text of Bedrock Converse
guardContentblocks when building the LLM Observability input forconverseandconverseStreamrequests, instead of recording them as[Unsupported content type: guardContent].Motivation
guardContentis how a Converse caller scopes a Bedrock guardrail to part of a turn, typically the user's question, with retrieved context left unscanned around it. With the current walker the recordedllmspan keeps the context and loses the question, which is the one part of the prompt anyone reading the span needs. The block is input-only, so response and stream extraction are unchanged.Additional Notes
One unit test in
bedrockruntime.util.spec.jscovers a guarded text block between two plain text blocks. A guarded image block still falls through to the placeholder.Fixes #10172