Skip to content

fix(bedrock): preserve reasoningContent in normalized responses - #20366

Closed
molvikar wants to merge 1 commit into
NousResearch:mainfrom
molvikar:fix/bedrock-reasoning-persistence
Closed

fix(bedrock): preserve reasoningContent in normalized responses#20366
molvikar wants to merge 1 commit into
NousResearch:mainfrom
molvikar:fix/bedrock-reasoning-persistence

Conversation

@molvikar

@molvikar molvikar commented May 5, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Preserves Bedrock reasoningContent when normalizing Converse responses.

Before this change, Bedrock thinking text could appear in the streaming callback path, but it was dropped from the normalized assistant message shape. That caused downstream transport normalization to produce NormalizedResponse.reasoning=None even when Bedrock had returned reasoning content.

This change fixes both paths:

  • Raw converse() responses now collect reasoningContent blocks into the normalized message.
  • Streaming converse_stream() responses now persist reasoning text onto the normalized message instead of only forwarding it to the callback.

As a result, Bedrock reasoning now survives normalization consistently across raw and streaming flows.

Related Issue

Fixes #

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • Tests (adding or improving test coverage)

Changes Made

  • Updated agent/bedrock_adapter.py

  • Preserved reasoningContent blocks in normalize_converse_response()

  • Preserved streamed reasoning deltas in stream_converse_with_callbacks()

  • Attached normalized reasoning onto the assistant message as reasoning_content

  • Updated tests/agent/test_bedrock_adapter.py

  • Added an assertion that streamed reasoning is persisted on the normalized message, not only emitted via callback

  • Updated tests/agent/transports/test_bedrock_transport.py

  • Added regression coverage for raw Converse responses containing reasoningContent

How to Test

1. Run:
   uv run pytest tests/agent/test_bedrock_adapter.py -q

2. Run:
   uv run pytest tests/agent/transports/test_bedrock_transport.py -q

3. Verify both pass, and confirm Bedrock normalized responses now retain reasoning text.

## Test Results

uv run pytest tests/agent/test_bedrock_adapter.py -q -> 118 passed
uv run pytest tests/agent/transports/test_bedrock_transport.py -q -> 19 passed

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

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P2 Medium — degraded but workaround exists provider/bedrock AWS Bedrock (boto3, IAM) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants