Skip to content

fix(llmobs): read the text of Bedrock Converse guardContent blocks - #10173

Open
colecrawford-reify wants to merge 1 commit into
DataDog:masterfrom
colecrawford-reify:fix/llmobs-bedrock-converse-guardcontent
Open

fix(llmobs): read the text of Bedrock Converse guardContent blocks#10173
colecrawford-reify wants to merge 1 commit into
DataDog:masterfrom
colecrawford-reify:fix/llmobs-bedrock-converse-guardcontent

Conversation

@colecrawford-reify

Copy link
Copy Markdown

What does this PR do?

Reads the text of Bedrock Converse guardContent blocks when building the LLM Observability input for converse and converseStream requests, instead of recording them as [Unsupported content type: guardContent].

Motivation

guardContent is 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 recorded llm span 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.js covers a guarded text block between two plain text blocks. A guarded image block still falls through to the placeholder.

Fixes #10172

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +503 to +504
} else if (typeof block.guardContent?.text?.text === 'string') {
content += block.guardContent.text.text

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: LLM Observability drops the text of Bedrock Converse guardContent blocks

1 participant