Skip to content

AWS Bedrock does not show or support Sonnet and Opus 4 Extended Thinking #4201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
thatseant opened this issue Jun 1, 2025 · 6 comments · May be fixed by #4481
Open

AWS Bedrock does not show or support Sonnet and Opus 4 Extended Thinking #4201

thatseant opened this issue Jun 1, 2025 · 6 comments · May be fixed by #4481
Labels
bug Something isn't working Issue - Needs Scoping Valid, but needs effort estimate or design input before work can start.

Comments

@thatseant
Copy link

thatseant commented Jun 1, 2025

App Version

v3.19.1

API Provider

AWS Bedrock

Model Used

Claude Sonnet 4

🔁 Steps to Reproduce

Configration shown here: List does not showing :thinking variant

Image Image

💥 Outcome Summary

List of models does not show :thinking variants for Anthropic Models. This is contrary to what was stated in #3844

Typing in various prompts after selecting Sonnet 4 also never trigger reasoning/extended thinking.

Model should either show :thinking variant or should have Enable Reasoning Mode (Similar to Anthropic as Provider) with Max Thinking Tokens configuration

Image

📄 Relevant Logs or Errors (Optional)

@thatseant thatseant added the bug Something isn't working label Jun 1, 2025
@thatseant thatseant changed the title Bedrock does not show or support Sonnet and Opus 4 Extended Thinking AWS Bedrock does not show or support Sonnet and Opus 4 Extended Thinking Jun 1, 2025
Copy link

dosubot bot commented Jun 1, 2025

Hi @thatseant! I'm Dosu and I’m helping the Roo-Code team.

Based on the latest documentation and release notes, Roo Code claims to support the Anthropic Claude Sonnet 4 and Opus 4 models with the :thinking (Extended Thinking) variant for Bedrock, Anthropic, and Vertex providers, as of version 3.18 and 3.18.1 [source][source]. However, the official Bedrock provider documentation and supported model lists do not mention any :thinking variants or extended thinking capabilities for these models—only the standard model IDs like anthropic.claude-sonnet-4-20250514-v1:0 and anthropic.claude-opus-4-20250514-v1:0 are shown as available [source].

There is no documentation or configuration guidance for enabling a :thinking variant or reasoning mode for Sonnet 4 via Bedrock. The model dropdown in Roo Code for Bedrock only lists the standard variants, and there is no mention of a "Max Thinking Tokens" or "Enable Reasoning Mode" option for Bedrock as there is for Anthropic direct or Vertex AI [source].

No issues or discussions were found in the documentation about this gap, and there is no detailed documentation about the referenced pull request (#3844) beyond the release note stating support was added. The absence of the :thinking variant in your Bedrock configuration appears to be a documentation or implementation gap: the release notes claim support, but the actual Bedrock provider and UI do not expose these variants.

If you require the :thinking variant or extended reasoning features, you may need to use the Anthropic direct or Vertex AI providers, where these options are explicitly documented and available [source][source]. For Bedrock, the feature either has not been fully implemented, is not exposed by AWS, or is not yet surfaced in Roo Code's UI.

If you need further clarification or a workaround, you may want to check for updates in future releases or reach out for clarification on whether AWS Bedrock currently exposes these variants and if Roo Code plans to support them in the UI.

To reply, just mention my name @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Join Discord Share on X

@thatseant
Copy link
Author

thatseant commented Jun 1, 2025

Hi I'm able to enable reasoning to work successfully in a example app that use Bedrock API with following settings:

// Claude 4 model ID (cross-region inference profile)
const CLAUDE_4_MODEL_ID = 'us.anthropic.claude-sonnet-4-20250514-v1:0';
    
const inferenceConfig = {
      maxTokens: 20000,
      temperature: 1,
      topP: 0.95
    };

// Reasoning configuration to enable thinking
const additionalModelRequestFields = {
  thinking: {
    type: "enabled",
    budget_tokens: 10000  // Budget for reasoning tokens
  }
};

const command = new ConverseStreamCommand({
  modelId: CLAUDE_4_MODEL_ID,
  messages: messages,
  inferenceConfig: inferenceConfig,
  additionalModelRequestFields: additionalModelRequestFields
}); 

https://docs.aws.amazon.com/bedrock/latest/userguide/claude-messages-extended-thinking.html

@daniel-lxs daniel-lxs added Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. Issue - Unassigned / Actionable Clear and approved. Available for contributors to pick up. and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Jun 2, 2025
@daniel-lxs daniel-lxs moved this from Triage to Issue [Unassigned] in Roo Code Roadmap Jun 3, 2025
@daniel-lxs daniel-lxs moved this from Issue [Unassigned] to Issue [Needs Scoping] in Roo Code Roadmap Jun 3, 2025
@daniel-lxs daniel-lxs marked this as a duplicate of #4279 Jun 3, 2025
@hannesrudolph hannesrudolph added Issue - Needs Scoping Valid, but needs effort estimate or design input before work can start. and removed Issue - Unassigned / Actionable Clear and approved. Available for contributors to pick up. labels Jun 3, 2025
@Litee
Copy link

Litee commented Jun 3, 2025

I make extended thinking work for me in my own fork, but I had to deal with several mismatches between current Bedrock implementation and AWS SDK. See more details in duplicate #4279 description.

@thatseant
Copy link
Author

thatseant commented Jun 4, 2025

Great! Thanks @Litee

Interested to see this move forward.

From @Litee description in #4279:
"Update Roo-Code/src/api/providers/bedrock.ts to support extended thinking. Note that the logic there is currently using custom types modeled after AWS SDK types, but different for some reason. I already created a working prototype and I had to do significant changes in chunk streams processing to make thinking render properly. Those custom types were added by @mrubens , @hannesrudolph , so I am looking for a guidance on why those were needed, why AWS SDK types could not be used directly."

and in #1179:
"@mrubens, @hannesrudolph, you were the last contributors to /src/api/providers/bedrock.ts who added custom type definitions at the beginning of the file and used those custom types for processing incoming chunks. When I switched to types provided by AWS SDK, I immediately saw many type inconsistencies, which I had to fix in order for extended thinking to render properly. Do you remember what was the reason for defining your own types instead of using AWS SDK's?"

@Mnehmos
Copy link

Mnehmos commented Jun 6, 2025

Hey y'all jumping in here as I move down the list, I had Roo do a deep dive too. Hope it helps!

Roo Deep Dive: AWS Bedrock Extended Thinking (Revised)

1. Problem Summary

The core issue is that Roo Code does not support the "Extended Thinking" (also referred to as "reasoning") feature for Anthropic's Claude models (including Sonnet 4, Opus 4, and 3.7 Sonnet) when using AWS Bedrock as the API provider. This is a feature gap, as the underlying AWS Bedrock API does support it, and users expect this capability for complex tasks. This creates an inconsistency with the direct Anthropic provider integration, which has a visible "Enable Reasoning Mode" toggle.

Related GitHub Issues:

2. Root Cause Analysis

The investigation, combining user reports, official AWS documentation, and a codebase review, points to three primary root causes:

2.1. Missing API Payload Parameters

The current implementation for making requests to AWS Bedrock is missing critical parameters required to activate the extended thinking feature.

  • Official AWS Documentation & User Feedback: According to the AWS Bedrock User Guide and detailed user feedback, enabling extended thinking requires:

    1. Passing an additionalModelRequestFields object in the ConverseCommand or ConverseStreamCommand payload with the structure:
      {
        "thinking": {
          "type": "enabled",
          "budget_tokens": 10000 // User-configurable value
        }
      }
    2. Including the anthropic_version field in the payload (e.g., "bedrock-2023-05-31").
  • Codebase Analysis: The createMessage function in src/api/providers/bedrock.ts constructs the payload for the Bedrock API call. This function currently assembles modelId, messages, system, and inferenceConfig, but it does not include the additionalModelRequestFields object or the anthropic_version field. This is the primary reason the feature is not being activated.

2.2. Incompatible Stream Processing Logic

The stream processing logic in src/api/providers/bedrock.ts is not equipped to handle the specific event types generated by the extended thinking feature.

  • Official AWS Documentation: When streaming with extended thinking, the API sends a sequence of events including content_block_start (with content_block.type: "thinking"), content_block_delta (with delta.type: "thinking_delta"), and content_block_delta (with delta.type: "signature_delta").
  • Codebase Analysis: The current stream handling loop (lines 319-420) and the custom StreamEvent type (lines 48-109) are not designed to parse or handle these new event types. This will cause the UI to fail to render the thinking process correctly. The custom types are misaligned with the official AWS SDK and must be updated or replaced.

2.3. Incomplete Model & UI Configuration

The application lacks the necessary configuration to expose the extended thinking option to the user in the UI.

  • Model Capability Flag: The model definitions in packages/types/src/providers/bedrock.ts do not have a flag (e.g., supportsReasoningBudget) to indicate which models support this feature.
  • UI Logic: Without this flag, the frontend cannot conditionally render the "Enable Reasoning Mode" toggle and the "Max Thinking Tokens" input field for the appropriate Bedrock models.

3. Areas for Investigation & Implementation

To resolve this issue, an engineer will need to address the following areas:

3.1. Update Model Type Definitions

3.2. Modify API Request Payload

  • File: src/api/providers/bedrock.ts
  • Function: createMessage
  • Action: In the payload object, add the anthropic_version field.
  • Action: Conditionally add the additionalModelRequestFields object to the payload.
    • Condition: This should only be added if the selected model has supportsReasoningBudget: true and the user has enabled it in settings.
    • The budget_tokens value should be sourced from user configuration.
  • Action: Ensure that temperature, topP, and top_k are not sent when thinking is enabled, as they are incompatible.

3.3. Refactor Stream Processing Logic

  • File: src/api/providers/bedrock.ts
  • Action: This is the most critical part of the fix. The custom StreamEvent types (lines 48-109) must be deprecated.
  • Recommendation: Refactor the stream processing loop to use the official types directly from @aws-sdk/client-bedrock-runtime. This will involve updating the for await...of response.stream loop (lines 319-420).
  • Action: The new loop must correctly identify and handle the thinking_delta and signature_delta events, yielding them in a format the frontend can use to render the "thinking" status.
  • Action: Implement logic to handle tool use with extended thinking. This requires passing the entire, unmodified thinking block from the previous assistant message back to the API in subsequent requests to maintain reasoning continuity.

3.4. Update Frontend UI

  • Files:
    • webview-ui/src/components/settings/AutoApproveToggle.tsx (or a similar settings component for Bedrock).
  • Action: Update the UI to check for the supportsReasoningBudget flag on the selected Bedrock model.
  • Action: If the flag is true, render the "Enable Reasoning Mode" toggle and the "Max Thinking Tokens" slider/input.

4. Impact Analysis

  • User Impact: High. This will enable a key feature for users of Claude models on Bedrock, significantly improving the tool's capabilities for complex reasoning.
  • System Impact: High. The required refactoring of the stream processing and tool use logic is complex and touches a critical part of the application. There is a moderate to high risk of introducing regressions if not tested thoroughly. The changes to the API payload are straightforward, but the stream handling is not.
  • Developer Impact: Medium. The path is clear, but the implementation requires careful attention to detail, especially in the stream and tool-use handling logic.

5. Key Components for Review

The assigned engineer should pay close attention to the following files and functions during implementation and review:

@hannesrudolph
Copy link
Collaborator

Fixed in PR #4481

I've implemented comprehensive Extended Thinking support for AWS Bedrock Claude models. The solution adds reasoning budget functionality (equivalent to "Enable Reasoning Mode") rather than separate :thinking model variants.

Key Changes:

  • Added supportsReasoningBudget: true to Claude Sonnet 4, Opus 4, and 3.7 Sonnet models
  • Implemented full extended thinking support with additionalModelRequestFields.thinking parameter
  • Enhanced stream processing to handle reasoning content properly
  • Updated UI to show reasoning budget controls for supported Bedrock models
  • Added comprehensive test coverage (280 lines of tests)
  • Improved error handling and validation

Result:
Users can now enable Extended Thinking for Bedrock Claude models with the same UI controls as the direct Anthropic provider - no need for separate :thinking model variants.

PR: #4481

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Issue - Needs Scoping Valid, but needs effort estimate or design input before work can start.
Projects
Status: Issue [Needs Scoping]
5 participants