Skip to content

fix(bedrock): do not record an empty reasoning part for redacted Converse content - #932

Open
pcbeingused333 wants to merge 3 commits into
open-telemetry:mainfrom
pcbeingused333:fix/bedrock-converse-stream-redacted-reasoning
Open

pcbeingused333 wants to merge 3 commits into
open-telemetry:mainfrom
pcbeingused333:fix/bedrock-converse-stream-redacted-reasoning

Conversation

@pcbeingused333

@pcbeingused333 pcbeingused333 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

A Bedrock Converse reasoning block that comes back as redactedContent was recorded as a reasoning part with an empty string in the non-streaming path, and was missing from the streaming path. Neither carries readable content, and recording the empty part makes the output messages look as if the model produced a blank thought.

Both paths now skip a redactedContent block, so the recorded output messages match for streamed and non-streamed calls. How to record redacted reasoning, if at all, is tracked in the semantic conventions repository: open-telemetry/semantic-conventions-genai#616.

test_extract_content_block_reasoning now expects no part for redacted content, and test_stream_wrapper_skips_redacted_reasoning checks that a streamed redacted block leaves only the text part. Both fail on the previous head of this branch and pass now, the bedrock converse tests pass, and ruff is clean. No request was made to Bedrock.

This change was made with Claude Code.

The non-streaming converse path records a redactedContent reasoning
block as an empty reasoning part, but the streaming handler only read
reasoningContent deltas with text, so a redacted block was missing from
the output messages of a streamed call. Record it as an empty reasoning
part as well.
Copilot AI balanced review requested due to automatic review settings October 20, 2026 13:08
@pcbeingused333
pcbeingused333 requested a review from a team as a code owner October 20, 2026 13:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The narrow fix aligns streaming with existing non-streaming behavior and includes targeted regression coverage.

No open issues 🎉

What changed in this PR

Preserves redacted reasoning blocks in Bedrock Converse streaming telemetry, matching non-streaming behavior.

Changes:

  • Records redacted reasoning deltas as empty reasoning parts.
  • Adds a regression test and changelog entry.
File Description
instrumentation/​opentelemetry-instrumentation-genai-bedrock/​tests/​test_converse_stream.py Tests preservation of redacted reasoning.
instrumentation/​opentelemetry-instrumentation-genai-bedrock/​src/​opentelemetry/​instrumentation/​genai/​bedrock/​stream.py Handles redacted reasoning deltas.
instrumentation/​opentelemetry-instrumentation-genai-bedrock/​.changelog/​932.fixed Documents the fix.

Review effort: Balanced

@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Waiting on reviewers · refreshed 2026-10-21 05:39 UTC

Review the latest changes.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

@lmolkova lmolkova left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What's the point of recording "" instead of redacted content?

I think this needs discussion / documentation in https://github.com/open-telemetry/semantic-conventions-genai to decide if/how to record redacted content and for now dropping it does not seem too different from having empty string.

@pcbeingused333

Copy link
Copy Markdown
Contributor Author

Fair point. The change only makes the streaming path match extract_content_block, which already records redactedContent as an empty reasoning part, so it doesn't add information. If dropping the block is acceptable until semantic-conventions-genai defines whether and how redacted reasoning is recorded, I'm happy to close this PR rather than keep an empty part. Should the non-streaming path stop emitting the empty part instead, so both paths are consistent? Glad to do that if you prefer.

@lmolkova

Copy link
Copy Markdown
Member

Fair point. The change only makes the streaming path match extract_content_block, which already records redactedContent as an empty reasoning part, so it doesn't add information. If dropping the block is acceptable until semantic-conventions-genai defines whether and how redacted reasoning is recorded, I'm happy to close this PR rather than keep an empty part.

thanks for the context! could you please create issue in semconv-genai repo to track it?

Should the non-streaming path stop emitting the empty part instead, so both paths are consistent? Glad to do that if you prefer.

Sounds good! Let's do it

@pcbeingused333 pcbeingused333 changed the title fix(bedrock): keep redacted reasoning blocks in streamed converse output fix(bedrock): do not record an empty reasoning part for redacted Converse content Oct 21, 2026
@pcbeingused333

Copy link
Copy Markdown
Contributor Author

Done. Both the streaming and the non-streaming path now skip redactedContent instead of recording an empty reasoning part, and the title, description, tests and changelog are updated. Opened open-telemetry/semantic-conventions-genai#616 to track whether and how redacted reasoning should be recorded; it links #192, which covers reasoning parts more broadly.

This branch has not been deployed

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants