AWS Bedrock Claude extended thinking uses wrong API format (reasoningConfig instead of thinking.budget_tokens) #4447

Closed
opened 2026-02-16 17:43:48 -05:00 by yindo · 1 comment
Owner

Originally created by @arfadex on GitHub (Jan 8, 2026).

Originally assigned to: @thdxr on GitHub.

Summary

OpenCode's AWS Bedrock provider sends reasoningConfig.maxReasoningEffort for extended thinking, but AWS Bedrock Claude models require thinking.budget_tokens. This causes the Ctrl+T thinking toggle and --variant flag to have no effect.

Problem

When using AWS Bedrock Claude models (e.g., amazon-bedrock/anthropic.claude-opus-4-5-20251101-v1:0), toggling thinking with Ctrl+T between low/medium/high does nothing because the wrong API format is sent.

What OpenCode sends:

{
  "reasoningConfig": {
    "type": "enabled",
    "maxReasoningEffort": "low" | "medium" | "high"
  }
}

What AWS Bedrock actually requires:

{
  "thinking": {
    "type": "enabled",
    "budget_tokens": 10000
  }
}

Confirmed via Testing

Tested with CLI:

opencode run "What is 27 * 453?" --model "amazon-bedrock/anthropic.claude-opus-4-5-20251101-v1:0" --variant "high" --format json

Output shows "reasoning":0 - no reasoning tokens used:

{"type":"step_finish",...,"tokens":{"input":332,"output":16,"reasoning":0,...}}

Config workaround also doesn't work because the provider transform overrides it:

{
  "provider": {
    "amazon-bedrock": {
      "models": {
        "anthropic.claude-opus-4-5-20251101-v1:0": {
          "options": {
            "thinking": {
              "type": "enabled",
              "budgetTokens": 32000
            }
          }
        }
      }
    }
  }
}

Root Cause

In packages/opencode/src/provider/transform.ts, the variants function for @ai-sdk/amazon-bedrock returns:

reasoningConfig: {
  type: "enabled",
  maxReasoningEffort: effort,  // "low", "medium", "high"
}

But AWS Bedrock's Messages API for Claude extended thinking requires the thinking object with budget_tokens (a number), not maxReasoningEffort (a string).

AWS Documentation Reference

From AWS Bedrock Extended Thinking Docs:

To turn on extended thinking, add a thinking object, with the thinking parameter set to enabled and the budget_tokens set to a specified token budget for extended thinking.

Supported models:

  • anthropic.claude-opus-4-5-20251101-v1:0
  • anthropic.claude-sonnet-4-5-20250929-v1:0
  • anthropic.claude-haiku-4-5-20251001-v1:0
  • anthropic.claude-opus-4-20250514-v1:0
  • anthropic.claude-sonnet-4-20250514-v1:0
  • anthropic.claude-3-7-sonnet-20250219-v1:0

Proposed Fix

Update the variants function for @ai-sdk/amazon-bedrock to use the same format as Anthropic direct:

// For amazon-bedrock, use thinking.budgetTokens like Anthropic
case "@ai-sdk/amazon-bedrock":
  return {
    low: {
      thinking: { type: "enabled", budgetTokens: 10000 }
    },
    medium: {
      thinking: { type: "enabled", budgetTokens: 32000 }
    },
    high: {
      thinking: { type: "enabled", budgetTokens: 80000 }
    },
    max: {
      thinking: { type: "enabled", budgetTokens: 128000 }
    }
  }

Environment

  • Model: amazon-bedrock/anthropic.claude-opus-4-5-20251101-v1:0
  • OpenCode version: latest
  • AWS Region: (varies)

Impact

  • Ctrl+T toggle: Does nothing for Bedrock models
  • --variant flag: Does nothing for Bedrock models
  • Config workaround: Overridden by provider transform
  • Result: Extended thinking is completely broken for all AWS Bedrock Claude models
Originally created by @arfadex on GitHub (Jan 8, 2026). Originally assigned to: @thdxr on GitHub. ## Summary OpenCode's AWS Bedrock provider sends `reasoningConfig.maxReasoningEffort` for extended thinking, but AWS Bedrock Claude models require `thinking.budget_tokens`. This causes the Ctrl+T thinking toggle and `--variant` flag to have no effect. ## Problem When using AWS Bedrock Claude models (e.g., `amazon-bedrock/anthropic.claude-opus-4-5-20251101-v1:0`), toggling thinking with Ctrl+T between low/medium/high does nothing because the wrong API format is sent. ### What OpenCode sends: ```json { "reasoningConfig": { "type": "enabled", "maxReasoningEffort": "low" | "medium" | "high" } } ``` ### What AWS Bedrock actually requires: ```json { "thinking": { "type": "enabled", "budget_tokens": 10000 } } ``` ## Confirmed via Testing Tested with CLI: ```bash opencode run "What is 27 * 453?" --model "amazon-bedrock/anthropic.claude-opus-4-5-20251101-v1:0" --variant "high" --format json ``` Output shows `"reasoning":0` - no reasoning tokens used: ```json {"type":"step_finish",...,"tokens":{"input":332,"output":16,"reasoning":0,...}} ``` **Config workaround also doesn't work** because the provider transform overrides it: ```json { "provider": { "amazon-bedrock": { "models": { "anthropic.claude-opus-4-5-20251101-v1:0": { "options": { "thinking": { "type": "enabled", "budgetTokens": 32000 } } } } } } } ``` ## Root Cause In `packages/opencode/src/provider/transform.ts`, the `variants` function for `@ai-sdk/amazon-bedrock` returns: ```typescript reasoningConfig: { type: "enabled", maxReasoningEffort: effort, // "low", "medium", "high" } ``` But AWS Bedrock's Messages API for Claude extended thinking requires the `thinking` object with `budget_tokens` (a number), not `maxReasoningEffort` (a string). ## AWS Documentation Reference From [AWS Bedrock Extended Thinking Docs](https://docs.aws.amazon.com/bedrock/latest/userguide/claude-messages-extended-thinking.html): > To turn on extended thinking, add a `thinking` object, with the `thinking` parameter set to enabled and the `budget_tokens` set to a specified token budget for extended thinking. Supported models: - `anthropic.claude-opus-4-5-20251101-v1:0` - `anthropic.claude-sonnet-4-5-20250929-v1:0` - `anthropic.claude-haiku-4-5-20251001-v1:0` - `anthropic.claude-opus-4-20250514-v1:0` - `anthropic.claude-sonnet-4-20250514-v1:0` - `anthropic.claude-3-7-sonnet-20250219-v1:0` ## Proposed Fix Update the `variants` function for `@ai-sdk/amazon-bedrock` to use the same format as Anthropic direct: ```typescript // For amazon-bedrock, use thinking.budgetTokens like Anthropic case "@ai-sdk/amazon-bedrock": return { low: { thinking: { type: "enabled", budgetTokens: 10000 } }, medium: { thinking: { type: "enabled", budgetTokens: 32000 } }, high: { thinking: { type: "enabled", budgetTokens: 80000 } }, max: { thinking: { type: "enabled", budgetTokens: 128000 } } } ``` ## Environment - Model: `amazon-bedrock/anthropic.claude-opus-4-5-20251101-v1:0` - OpenCode version: latest - AWS Region: (varies) ## Impact - **Ctrl+T toggle**: Does nothing for Bedrock models - **--variant flag**: Does nothing for Bedrock models - **Config workaround**: Overridden by provider transform - **Result**: Extended thinking is completely broken for all AWS Bedrock Claude models
yindo closed this issue 2026-02-16 17:43:48 -05:00
Author
Owner

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

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

  • #6886: Gemini 3 models hang due to conflicting thinkingConfig in smallOptions() - Similar pattern of incorrect thinking configuration in packages/opencode/src/provider/transform.ts

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 8, 2026): This issue might be a duplicate of existing issues. Please check: - #6886: Gemini 3 models hang due to conflicting thinkingConfig in smallOptions() - Similar pattern of incorrect thinking configuration in `packages/opencode/src/provider/transform.ts` Feel free to ignore if none of these address your specific case.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#4447