Skip to content

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

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-f87961d0
May 7, 2026
Merged

fix(bedrock): preserve reasoningContent in normalized responses#21202
teknium1 merged 1 commit into
mainfrom
hermes/hermes-f87961d0

Conversation

@teknium1

@teknium1 teknium1 commented May 7, 2026

Copy link
Copy Markdown
Contributor

Salvage of #20366 onto current main (172 commits stale).

Bedrock thinking text now survives normalization on both raw converse() and streaming converse_stream() paths. Previously agent/bedrock_adapter.py:normalize_converse_response() didn't handle reasoningContent blocks, and the stream path only forwarded reasoning to the callback — nothing persisted onto the assistant message. The transport layer (agent/transports/bedrock.py:108) already reads msg.reasoning_content, so the field just arrived empty and NormalizedResponse.reasoning was always None even on Claude 4.6+ thinking output.

Changes

  • agent/bedrock_adapter.py: collect reasoningContent.text blocks in both normalize_converse_response() and stream_converse_with_callbacks(), attach as reasoning_content on the assistant SimpleNamespace.
  • tests/agent/test_bedrock_adapter.py: assert streamed reasoning persists on the normalized message, not only via callback.
  • tests/agent/transports/test_bedrock_transport.py: regression coverage for raw Converse with reasoningContent.

Validation

Before After
NormalizedResponse.reasoning on Bedrock thinking output None Thinking text
tests/agent/test_bedrock_adapter.py + tests/agent/transports/test_bedrock_transport.py - 137 passed
E2E adapter → transport chain (real imports) reasoning lost reasoning preserved

Authored-by: @molvikar via cherry-pick, no follow-up fixes needed.
Closes #20366

@github-actions

github-actions Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-f87961d0 vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 7483 on HEAD, 7483 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 3932 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

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.

3 participants