Bedrock Converse drops reasoningContent, breaking extended thinking with tool use
Bug description
The Bedrock Converse chat model (BedrockProxyChatModel) does not handle Anthropic
reasoningContent (extended thinking) blocks. They are silently dropped when parsing
the response and are never sent back when rebuilding the assistant turn. As a result:
- With thinking enabled and no tools, the reasoning text is never surfaced (reasoning tokens are billed but the content is discarded).
- With thinking enabled and tools, every tool-use turn fails with a Bedrock
ValidationException, because Bedrock requires the assistant message containing atoolUseblock to also carry the preceding signedreasoningContentblock when the follow-uptoolResultis sent. Since Spring AI's internal tool loop (ToolCallAdvisorre-invokes the model with the tool result) rebuilds that assistant turn without the reasoning block, the next request is rejected.
Two code paths are involved (line numbers from 2.0.0-M8,
models/spring-ai-bedrock-converse/.../BedrockProxyChatModel.java):
- Response parsing (
toChatResponse, ~L653): content is filtered totext+toolUseonly —ContentBlock.Type.REASONING_CONTENTis dropped:message.content().stream() .filter(content -> content.type() != ContentBlock.Type.TOOL_USE) .filter(content -> content.text() != null) // reasoningContent has null text → dropped - Request building (assistant branch of createRequest, ~L366): the assistant turn is reconstructed from message.getText() + assistantMessage.getToolCalls() only — there is no path that re-emits a reasoningContent block (with its signature).
This appears related to #3388 (AssistantMessage has no field to carry reasoning), but that issue is generic; this is specifically the Bedrock Converse drop + tool-replay failure. The same gap is present on main.
Environment
- Spring AI: 2.0.0-M8 (also reproduces on main)
- Model: eu.anthropic.claude-sonnet-4-6 (any thinking-capable Claude model on Bedrock)
- Java: 25
- AWS SDK bedrockruntime via spring-ai-starter-model-bedrock-converse
- No vector store
Steps to reproduce
- Build a BedrockProxyChatModel for a thinking-capable Claude model.
- Enable extended thinking by passing the Anthropic thinking object through BedrockChatOptions.requestParameters (→ Converse additionalModelRequestFields), e.g. {"thinking": {"type": "enabled", "budget_tokens": 2048}}, with temperature 1.0.
- Register at least one tool and send a prompt that triggers a tool call.
- The first model response returns a reasoningContent + toolUse; Spring AI executes the tool and re-invokes the model with the toolResult. That second request throws a Bedrock ValidationException (the assistant turn is missing the required reasoningContent block).
Expected behavior
- reasoningContent blocks parsed from the Converse response are preserved on the resulting AssistantMessage (text + signature), and
- re-emitted as a reasoningContent ContentBlock (ahead of the toolUse block, with the original signature) when that assistant turn is rebuilt for the next request,
so that extended thinking works on the Converse API both standalone and with tool use, matching the first-party Anthropic provider's thinking support.
Minimal Complete Reproducible example
Minimal Complete Reproducible example
Drop-in @Test for models/spring-ai-bedrock-converse/.../BedrockProxyChatModelIT.java
(reuses the existing MockWeatherService and @RequiresAwsCredentials setup in that class).
It mirrors the existing functionCallTest, only adding extended thinking via
requestParameters. It passes today with thinking disabled and fails with thinking enabled:
the tool-result turn throws software.amazon.awssdk.services.bedrockruntime.model.ValidationException
because the rebuilt assistant turn is missing the required reasoningContent block.
@Test
void functionCallWithThinkingEnabled() {
UserMessage userMessage = new UserMessage(
"What's the weather like in San Francisco, Tokyo and Paris? Return the result in Celsius.");
List<Message> messages = new ArrayList<>(List.of(userMessage));
var promptOptions = BedrockChatOptions.builder()
// Anthropic constraint: temperature must be 1.0 when thinking is enabled
.temperature(1.0)
// Inject the Anthropic `thinking` object via Converse additionalModelRequestFields.
// requestParameters is typed Map<String,String> but the converter accepts nested maps.
.requestParameters(Map.of("thinking",
Map.of("type", "enabled", "budget_tokens", 2048)))
.toolCallbacks(List.of(FunctionToolCallback.builder("getCurrentWeather", new MockWeatherService())
.description("Get the weather in location. Return in 36°C format")
.inputType(MockWeatherService.Request.class)
.build()))
.build();
// Fails: ValidationException on the second (tool-result) turn, because the assistant
// message replayed by the internal tool loop omits the signed reasoningContent block
// that Bedrock requires to precede the toolUse block.
ChatResponse response = this.chatModel.call(new Prompt(messages, promptOptions));
assertThat(response.getResult().getOutput().getText()).contains("30", "10", "15");
}
(requestParameters(Map<String,String>) is the public M8 way to reach additionalModelRequestFields;
the same failure occurs through any path that sets the thinking field. Note the
Map.of(...) argument relies on the converter handling nested maps, which it does.)
Thanks for the detailed report. I looked into this and opened #6414 to preserve Bedrock Converse reasoningContent on assistant tool-use turns and replay it when the follow-up tool result request is built.
If you have a chance, it would be helpful to try the PR branch against your extended-thinking + tool-use scenario and confirm whether it resolves the failure you reported.
Nice one @jewoodev, that was fast. I built your branch (2.0.1-SNAPSHOT) and pointed my original thinking + tool-use case at real Bedrock, and it works now. 🎉
Setup I tested with:
- Your branch
bedrock-reasoning-content-replayat2.0.1-SNAPSHOT - Bedrock
eu.anthropic.claude-sonnet-4-6ineu-west-1 - Extended thinking on via
requestParameters(additionalModelRequestFields.thinking,budget_tokens: 2048),temperature: 1.0
What changed:
On 2.0.0-M8 the follow-up call (the tool-result turn) blew up with a ValidationException, because the rebuilt assistant turn had dropped the signed reasoningContent. With your PR the whole tool-calling loop runs clean, no exception. The tool-call turn now comes back as a BedrockAssistantMessage that holds onto the reasoning, and it gets replayed ahead of the toolUse on the next request. Final answer came back with the right temperatures too.
Your AWS-free mapping tests cover the unit side well. If it helps, here's the live integration test I ran. It's standalone, so no Spring context and no @RequiresAwsCredentials, which means it'll run against a plain static-key profile. Feel free to pull it in or tweak it, or I can raise it as a follow-up if you'd rather:
BedrockThinkingToolReplayIT.java
package org.springframework.ai.bedrock.converse;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
import software.amazon.awssdk.regions.Region;
import org.springframework.ai.chat.messages.AssistantMessage;
import org.springframework.ai.chat.messages.Message;
import org.springframework.ai.chat.messages.UserMessage;
import org.springframework.ai.chat.model.ChatResponse;
import org.springframework.ai.chat.prompt.Prompt;
import org.springframework.ai.model.tool.DefaultToolCallingManager;
import org.springframework.ai.model.tool.ToolCallingManager;
import org.springframework.ai.model.tool.ToolExecutionResult;
import org.springframework.ai.tool.function.FunctionToolCallback;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Live reproduction for gh-6413 / PR gh-6414: extended thinking + tool use.
*/
class BedrockThinkingToolReplayIT {
private static final String MODEL_ID = "eu.anthropic.claude-sonnet-4-6";
private BedrockProxyChatModel chatModel() {
return BedrockProxyChatModel.builder()
.credentialsProvider(ProfileCredentialsProvider.create("bedrock"))
.region(Region.EU_WEST_1)
.timeout(Duration.ofMinutes(3))
.options(BedrockChatOptions.builder().model(MODEL_ID).build())
.build();
}
@SuppressWarnings({ "unchecked", "rawtypes" })
private static Map<String, String> thinkingEnabled(int budgetTokens) {
return (Map) Map.of("thinking", Map.of("type", "enabled", "budget_tokens", budgetTokens));
}
@Test
void extendedThinkingWithToolUseCompletesAndReplaysReasoning() {
var chatModel = chatModel();
ToolCallingManager toolCallingManager = DefaultToolCallingManager.builder().build();
// Anthropic requires temperature == 1 when thinking is enabled.
var options = BedrockChatOptions.builder()
.model(MODEL_ID)
.maxTokens(4096)
.temperature(1.0)
.requestParameters(thinkingEnabled(2048))
.toolCallbacks(List.of(FunctionToolCallback.builder("getCurrentWeather", new MockWeatherService())
.description("Get the weather in location. Return in 36°C format")
.inputType(MockWeatherService.Request.class)
.build()))
.build();
List<Message> messages = new ArrayList<>(List.of(new UserMessage(
"What's the weather like in San Francisco, Tokyo and Paris? Return the result in Celsius.")));
var prompt = new Prompt(messages, options);
ChatResponse response = chatModel.call(prompt);
// Reasoning is attached to the tool-call generation, not a leading text block.
assertThat(response.hasToolCalls()).as("model should call the weather tool").isTrue();
AssistantMessage toolTurn = response.getResults()
.stream()
.map(g -> g.getOutput())
.filter(m -> !m.getToolCalls().isEmpty())
.findFirst()
.orElseThrow();
assertThat(toolTurn).isInstanceOf(BedrockAssistantMessage.class);
assertThat(((BedrockAssistantMessage) toolTurn).hasReasoningContents())
.as("reasoning block must be preserved on the tool-call turn for replay (gh-6413)")
.isTrue();
// Drive the tool-calling loop. Before the fix, the call below threw
// ValidationException on the tool-result turn.
int guard = 0;
while (response.hasToolCalls() && guard++ < 5) {
ToolExecutionResult toolExecutionResult = toolCallingManager.executeToolCalls(prompt, response);
prompt = new Prompt(toolExecutionResult.conversationHistory(), options);
response = chatModel.call(prompt);
}
assertThat(response.hasToolCalls()).as("loop should terminate").isFalse();
assertThat(response.getResult().getOutput().getText()).contains("30", "10", "15");
}
}
Looks good to me. Thanks again for jumping on this, will be great to have it in 2.0.1.
Hi @jewoodev, any ETA on when this fix hits release? We're really looking forward for getting it on our project. Thanks
Hey, is there any updates?
Thanks for checking in. I don't have a release ETA, since that's up to the maintainers and release schedule.
The current status is that #6414 is open with the fix, and the original reporter confirmed that the PR branch resolves the Bedrock extended-thinking + tool-use failure against real Bedrock. I'll keep the PR updated if maintainers request any changes.
PR merged upstream.