Conversation
The _openai_to_bedrock() function appended reasoningContent blocks after text and toolUse blocks. Bedrock API requires that if an assistant message contains any thinking blocks, the first block must be a thinking block. This caused ValidationException on multi-turn conversations with extended thinking enabled: 'If an assistant message contains any thinking blocks, the first block must be thinking. Found text' The fix collects reasoning blocks separately and prepends them to the content array, matching the original block ordering that Bedrock produced. Before: [text, toolUse, reasoningContent] -> ValidationException After: [reasoningContent, text, toolUse] -> Correct Fixes aws#416
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #419 +/- ##
=======================================
Coverage ? 91.17%
=======================================
Files ? 58
Lines ? 5018
Branches ? 765
=======================================
Hits ? 4575
Misses ? 252
Partials ? 191
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Hi team, I also facing this error for toolUse, can you all help me fix? Appreciate it |
jariy17
approved these changes
Apr 17, 2026
|
hi @cagataycali we having trouble in production with toolCall Arguments. Can you help me check it. Thank you |
Contributor
|
Hi @phongtran222, Please report this as a issue and we can fix it from there. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Fixes #416 —
_openai_to_bedrock()appendsreasoningContentblocks aftertextandtoolUse, but Bedrock requires thinking blocks to come first.3-line fix. No new dependencies. No behavioral change for messages without reasoning.
The Bug
Bedrock error:
Changes
Verification
15 tests across 3 suites all pass:
Impact
OpenAIConverseConverterreasoningContent(empty list prepended = no change)AgentCoreMemoryConverterusers (already works correctly)I understand this repo's policy on external PRs — feel free to close if preferred and cherry-pick internally. The fix is also documented in the #416 comment thread.