opencode icon indicating copy to clipboard operation
opencode copied to clipboard

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

Open arfadex opened this issue 6 days ago • 1 comments

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

arfadex avatar Jan 08 '26 17:01 arfadex

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] avatar Jan 08 '26 17:01 github-actions[bot]