Skip to content

fix(bedrock-converse): Improve handling of reasoningContent in responses from Converse & ConverStream requests#20853

Open
mattref wants to merge 1 commit intorun-llama:mainfrom
mattref:bedrock-converse-fix-thinking-changes
Open

fix(bedrock-converse): Improve handling of reasoningContent in responses from Converse & ConverStream requests#20853
mattref wants to merge 1 commit intorun-llama:mainfrom
mattref:bedrock-converse-fix-thinking-changes

Conversation

@mattref
Copy link
Contributor

@mattref mattref commented Mar 3, 2026

Description

Fixes #20851 by addressing a regression introduced in #20664 that caused certain fields within reasoningContent, such as signature, to not be captured as expected when using the Bedrock Converse/ConverseStream APIs. This renders certain usage of BedrockConverse unusable, such as using the LLM with extended thinking and tool calling.

The changes in this PR were made to stay aligned with the Converse/ConverseStream specifications.

As part of the review of #20664 , a variety of changes were made that ultimately left the PR in a state where no new behaviors were being introduced. Additionally, as mentioned in my comment on #20851 , I also noticed that #20664 introduced some changes that aren't clear. For example, the added extract_thinking_from_block function contains a "Fallback for other potential keys (Nova, etc.)", but I can't find that in the Converse documentation.

This fix rolls back some of these changes in an effort to stay aligned with the Bedrock specifications, as the abstraction of extract_thinking_from_block does not appear to be needed. Per AWS documentation, content blocks from Converse and content block deltas from ConverseStream are distinct, and as such, keeping them logically distinct in the code seems sensical.

# Fallback for other potential keys (Nova, etc.)
for key in ("reasoning_content", "thinking", "reasoning"):
if key in block:
val = block[key]
if isinstance(val, str):
return val
if isinstance(val, dict):
return val.get("text") or val.get("content")

Also, it adds thinking_text as part of the tuple returned from _get_content_and_tool_calls, but it isn't used anywhere, as decided by @AstraBert in this comment and then later removed by the author of the PR.

One other observation is that the original PR made a change here, which I'm not really sure about (sorry for the formatting in the diff). @logan-markewich , @AstraBert would like your input on the change as I was hesitant to roll it back or adjust.

                if text := tool_result_content.get("text", None):
-                  text_content += text
-               tool_call_ids.append(tool_result_content.get("toolUseId", ""))
+                  # Use first text block as content for compatibility
+                  pass
+              tool_call_ids.append(tool_result.get("toolUseId", ""))
                status.append(tool_result.get("status", ""))

if text := tool_result_content.get("text", None):
# Use first text block as content for compatibility
pass
tool_call_ids.append(tool_result.get("toolUseId", ""))

Version Bump?

Did I bump the version in the pyproject.toml file of the package I am updating? (Except for the llama-index-core package)

  • Yes
  • No

Type of Change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Your pull-request will likely not be merged unless it is covered by some form of impactful unit testing.

  • I added new unit tests to cover this change
  • I believe this change is already covered by existing unit tests

Suggested Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added Google Colab support for the newly added notebooks.
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I ran uv run make format; uv run make lint to appease the lint gods

…ses from Converse & ConverStream requests

Resolves run-llama#20851 by fixing a regression introduced
in run-llama#20664 that caused certain fields within `reasoningContent`,
such as `signature`, to not be captured as expected
when using the Bedrock Converse/ConverseStream APIs.

PR run-llama#20664 was merged via commit: cf1b558
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Signature field not being provided in BedrockConverse requests (regression)

1 participant