AWS Bedrock Claude models with Inference Profile ARNs fail to trigger Extended Thinking (Reasoning) #7586

Closed
opened 2026-02-16 18:07:39 -05:00 by yindo · 2 comments
Owner

Originally created by @xxtitan on GitHub (Jan 25, 2026).

Originally assigned to: @thdxr on GitHub.

Description

Summary

When using self-deployed Claude models or models accessed via AWS Bedrock Inference Profiles, the reasoning (extended thinking) configuration fails to apply correctly. The core issue is that the provider transformation logic fails to identify the model as an Anthropic-based model when the model ID is an ARN, causing it to apply incorrect parameters meant for Amazon Nova models.

Example Configuration

"models": {
  "claude-sonnet-4.5": {
    "id": "arn:aws:bedrock:us-west-2:xxxxxxxxxxxx:application-inference-profile/xxxxxxxxxxxx",
    "name": "Claude Sonnet 4.5",
    "attachment": true,
    "reasoning": true,
    "temperature": true,
    "tool_call": true,
    "release_date": "2025-09-29",
    "modalities": {
      "input": ["text", "image"],
      "output": ["text"]
    }
  }
}

Error Logs

Running the model with reasoning enabled results in a 400 Bad Request from the Bedrock API:

opencode run "hello" --model bedrock/claude-sonnet-4.5 --variant low --format json
{
  "type": "error",
  "timestamp": 1769399812748,
  "error": {
    "name": "APIError",
    "data": {
      "message": "undefined: The model returned the following errors: reasoningConfig: Extra inputs are not permitted",
      "statusCode": 400,
      "responseBody": "{\"message\":\"The model returned the following errors: reasoningConfig: Extra inputs are not permitted\"}",
      "metadata": {
        "url": "https://bedrock-runtime.us-west-2.amazonaws.com/model/arn%3Aaws%3Abedrock%3Aus-west-2%3Axxxxxxxxxxxx%3Aapplication-inference-profile%2Fxxxxxxxxxxxx/converse-stream"
      }
    }
  }
}

Root Cause

  1. ID Detection Failure: In packages/opencode/src/provider/transform.ts, the logic only checks if model.api.id contains the string "anthropic".
  2. Incorrect Parameter Mapping: For Bedrock Inference Profile ARNs, this check fails. The system then defaults to applying maxReasoningEffort (the parameter used for Amazon Nova models).
  3. API Validation Error: Claude models on Bedrock require budgetTokens and do not support maxReasoningEffort. Providing the Nova parameter results in the Extra inputs are not permitted error from the Bedrock API.

Relevant Code

File: packages/opencode/src/provider/transform.ts
Lines: 440–471

case "@ai-sdk/amazon-bedrock":
  // Logic only checks for "anthropic" in model.api.id
  if (model.api.id.includes("anthropic")) {
    return {
      // ... correct budgetTokens config ...
    }
  }

  // Fallback for Nova models: this is what gets applied incorrectly to Claude ARNs
  return Object.fromEntries(
    WIDELY_SUPPORTED_EFFORTS.map((effort) => [
      effort,
      { reasoningConfig: { type: "enabled", maxReasoningEffort: effort } },
    ]),
  )

Suggested Fix

The detection logic should be improved to recognize Claude models even when they are addressed via ARNs by checking for both "claude" and "anthropic" in the ID.

Proposed Change:

if (
  model.api.id.includes("anthropic") ||
  model.api.id.includes("claude") ||
  model.id.toLowerCase().includes("anthropic") ||
  model.id.toLowerCase().includes("claude")
) {
  // Use budgetTokens configuration
}

Plugins

No response

OpenCode version

v1.1.36

Steps to reproduce

  1. Configure a Claude model in the opencode environment using an AWS Bedrock Inference Profile ARN as the id.
  2. Ensure reasoning: true is set in the model configuration.
  3. Execute a command that triggers reasoning, for example:
    opencode run "Your prompt here" --model bedrock/claude-sonnet-4.5 --variant low
    
  4. Observe that the request fails with a ValidationException (400) because the system incorrectly sends maxReasoningEffort instead of budgetTokens.

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Originally created by @xxtitan on GitHub (Jan 25, 2026). Originally assigned to: @thdxr on GitHub. ### Description ## Summary When using self-deployed Claude models or models accessed via **AWS Bedrock Inference Profiles**, the reasoning (extended thinking) configuration fails to apply correctly. The core issue is that the provider transformation logic fails to identify the model as an Anthropic-based model when the model ID is an ARN, causing it to apply incorrect parameters meant for Amazon Nova models. ## Example Configuration ```json "models": { "claude-sonnet-4.5": { "id": "arn:aws:bedrock:us-west-2:xxxxxxxxxxxx:application-inference-profile/xxxxxxxxxxxx", "name": "Claude Sonnet 4.5", "attachment": true, "reasoning": true, "temperature": true, "tool_call": true, "release_date": "2025-09-29", "modalities": { "input": ["text", "image"], "output": ["text"] } } } ``` ## Error Logs Running the model with reasoning enabled results in a `400 Bad Request` from the Bedrock API: ```bash opencode run "hello" --model bedrock/claude-sonnet-4.5 --variant low --format json ``` ```json { "type": "error", "timestamp": 1769399812748, "error": { "name": "APIError", "data": { "message": "undefined: The model returned the following errors: reasoningConfig: Extra inputs are not permitted", "statusCode": 400, "responseBody": "{\"message\":\"The model returned the following errors: reasoningConfig: Extra inputs are not permitted\"}", "metadata": { "url": "https://bedrock-runtime.us-west-2.amazonaws.com/model/arn%3Aaws%3Abedrock%3Aus-west-2%3Axxxxxxxxxxxx%3Aapplication-inference-profile%2Fxxxxxxxxxxxx/converse-stream" } } } } ``` ## Root Cause 1. **ID Detection Failure**: In `packages/opencode/src/provider/transform.ts`, the logic only checks if `model.api.id` contains the string `"anthropic"`. 2. **Incorrect Parameter Mapping**: For Bedrock Inference Profile ARNs, this check fails. The system then defaults to applying `maxReasoningEffort` (the parameter used for Amazon Nova models). 3. **API Validation Error**: Claude models on Bedrock require `budgetTokens` and do not support `maxReasoningEffort`. Providing the Nova parameter results in the `Extra inputs are not permitted` error from the Bedrock API. ## Relevant Code File: `packages/opencode/src/provider/transform.ts` Lines: 440–471 ```typescript case "@ai-sdk/amazon-bedrock": // Logic only checks for "anthropic" in model.api.id if (model.api.id.includes("anthropic")) { return { // ... correct budgetTokens config ... } } // Fallback for Nova models: this is what gets applied incorrectly to Claude ARNs return Object.fromEntries( WIDELY_SUPPORTED_EFFORTS.map((effort) => [ effort, { reasoningConfig: { type: "enabled", maxReasoningEffort: effort } }, ]), ) ``` ## Suggested Fix The detection logic should be improved to recognize Claude models even when they are addressed via ARNs by checking for both `"claude"` and `"anthropic"` in the ID. **Proposed Change:** ```typescript if ( model.api.id.includes("anthropic") || model.api.id.includes("claude") || model.id.toLowerCase().includes("anthropic") || model.id.toLowerCase().includes("claude") ) { // Use budgetTokens configuration } ``` ### Plugins _No response_ ### OpenCode version v1.1.36 ### Steps to reproduce 1. Configure a Claude model in the `opencode` environment using an **AWS Bedrock Inference Profile ARN** as the `id`. 2. Ensure `reasoning: true` is set in the model configuration. 3. Execute a command that triggers reasoning, for example: ```bash opencode run "Your prompt here" --model bedrock/claude-sonnet-4.5 --variant low ``` 4. Observe that the request fails with a `ValidationException (400)` because the system incorrectly sends `maxReasoningEffort` instead of `budgetTokens`. ### Screenshot and/or share link _No response_ ### Operating System _No response_ ### Terminal _No response_
yindo added the bug label 2026-02-16 18:07:39 -05:00
yindo closed this issue 2026-02-16 18:07:39 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 25, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #2746: AWS Bedrock Custom Inference Profiles Not Supported - While this issue deals with different problems (auth/permissions), it's related to the same underlying limitation with Bedrock Inference Profile ARN support. Your issue reveals that even when the authentication works, the provider transformation logic fails to correctly identify Claude models when accessed via ARNs.

Feel free to ignore if this doesn't address your specific case.

@github-actions[bot] commented on GitHub (Jan 25, 2026): This issue might be a duplicate of existing issues. Please check: - #2746: AWS Bedrock Custom Inference Profiles Not Supported - While this issue deals with different problems (auth/permissions), it's related to the same underlying limitation with Bedrock Inference Profile ARN support. Your issue reveals that even when the authentication works, the provider transformation logic fails to correctly identify Claude models when accessed via ARNs. Feel free to ignore if this doesn't address your specific case.
Author
Owner

@xxtitan commented on GitHub (Jan 26, 2026):

Update:

I’ve discovered that when using application-inference-profile instances, the @ai-sdk/amazon-bedrock provider may also ignore the high-level reasoningConfig parameters.

I was able to resolve this by using additionalModelRequestFields to manually inject the native Bedrock parameters (using snake_case) into the request:

"options": {
  "reasoningConfig": {},
  "additionalModelRequestFields": {
    "reasoning_config": {
      "type": "enabled",
      "budget_tokens": 8192
    }
  }
}

This ensures the reasoning_config is correctly passed to the Bedrock Converse API even if the SDK's automatic mapping fails for ARN-based model IDs.

@xxtitan commented on GitHub (Jan 26, 2026): **Update:** I’ve discovered that when using `application-inference-profile` instances, the `@ai-sdk/amazon-bedrock` provider may also ignore the high-level `reasoningConfig` parameters. I was able to resolve this by using `additionalModelRequestFields` to manually inject the native Bedrock parameters (using snake_case) into the request: ```json "options": { "reasoningConfig": {}, "additionalModelRequestFields": { "reasoning_config": { "type": "enabled", "budget_tokens": 8192 } } } ``` This ensures the `reasoning_config` is correctly passed to the Bedrock Converse API even if the SDK's automatic mapping fails for ARN-based model IDs.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#7586