Skip to content

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

Closed

Description

@xxtitan

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

Activity

  1. github-actions commented on Jan 26, 2026

    @github-actions
    Contributor

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

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

  2. xxtitan commented on Jan 26, 2026

    @xxtitan
    Author

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions