GeezerVison is showing github.com — Support adaptive thinking for Claude Opus 4.6 · Issue #12485 · anomalyco/opencode
Support adaptive thinking for Claude Opus 4.6 #12485DescriptionAnthropic has deprecated thinking.type: "enabled" with budget_tokens on Opus 4.6 and will remove it in a future release. The recommended replacement is adaptive thinking:
{
"thinking": { "type": "adaptive" },
"output_config": { "effort": "high" }
}
Docs: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking
Currently variants() in transform.ts uses the deprecated config for all Anthropic models, including Opus 4.6:
high: { thinking: { type: "enabled", budgetTokens: ... } },
max: { thinking: { type: "enabled", budgetTokens: ... } },
A few things to consider:
- Only Opus 4.6 supports adaptive — older models still need
type: "enabled"
effort: "max" is Opus 4.6 exclusive
maxOutputTokens() assumes a known budgetTokens for the subtraction — adaptive doesn't have one
- Depends on
@ai-sdk/anthropic supporting type: "adaptive" upstream
Reacted by mungo, Motonari Tsuzuki, nil0ft, Chris Yang, fynn, Oscar Serna, Aiden Kim, Kush Patel, Jaakko Sirén, Stephen Haberman and 3 more ActivityBouquetAntoine commented on Feb 6, 2026 OpenCode currently depends on @ai-sdk/anthropic v2.x. Simply bumping the dependency to v3.x and rebuilding isn't enough — there are several breaking changes in the SDK that need to be addressed in the codebase.
Below is a summary of every breaking change identified so far, tried different fixes in my codebase but that's a lot of work.
1. finishReason format change
v2.x returns a plain string:
finishReason: "end_turn" | "tool_use" | "stop_sequence" | ...
v3.x returns an object with unified and raw properties:
finishReason: {
unified: "stop" | "tool-calls" | "error" | "other" | ...
raw: string | undefined
}
2. usage token counts format change
v2.x returns flat numbers:
usage: {
inputTokens: 1234,
outputTokens: 567,
cachedInputTokens: 100,
reasoningTokens: 200,
}
v3.x returns nested objects:
usage: {
inputTokens: { total: 1234, noCache: 1034, cacheRead: 200 },
outputTokens: { total: 567, text: undefined },
reasoningTokens: 200, // may also be an object
}
3. New providerOptions schema (thinking / effort)
v2.x supports a limited thinking config:
thinking: {
type: "enabled" | "disabled",
budgetTokens?: number,
}
// No "effort" field
v3.x adds an adaptive mode and a new top-level effort field:
thinking: {
type: "adaptive" | "enabled" | "disabled",
budgetTokens?: number, // only required when type is "enabled"
}
effort: "low" | "medium" | "high" | "max" // NEW
Fix
Update config schema validation (e.g. Zod schemas or type definitions) to accept the new "adaptive" type and the effort field.
Problem is that we probably need to update all ai-sdk to last version for compatibility across models avarayr commented on Feb 6, 2026 I was able to temporarily hack this to work until fix is in place.
Note: this is not a long term solution, just an unblocker until this issue is fixed.
// File: ~/.opencode/plugins/adaptiveThinking.ts
export const adaptiveThinking: import("@opencode-ai/plugin").Plugin =
async () => ({
loader: async () => {
return {
fetch: async (url: RequestInfo | URL, init?: RequestInit) => {
const body = init?.body
? JSON.parse(init.body as string)
: undefined;
if (body?.thinking?.budget_tokens === -1) {
body.thinking = { type: "adaptive" };
return fetch(url, { ...init, body: JSON.stringify(body) });
}
return fetch(url, init);
},
};
},
},
// Shim: rewrite adaptive -> enabled with sentinel budget so SDK Zod passes,
// then the custom fetch above detects budget_tokens:-1 and patches to adaptive.
"chat.params": async (_input, output) => {
if (output.options?.thinking?.type === "adaptive") {
output.options.thinking = { type: "enabled", budgetTokens: -1 };
}
},
});
// File: ~/.config/opencode/opencode.jsonc
{
"plugin": [
"file:///Users/<USERNAME>/.opencode/plugin/adaptiveThinking.ts",
],
"provider": {
"anthropic": { // <-- replace with your provider of choice
"models": {
"claude-opus-4-6@20260205": { // might need replacement based on provider
"id": "claude-opus-4-6",
"name": "Claude Opus 4.6",
"family": "claude-opus",
"attachment": true,
"reasoning": true,
"tool_call": true,
"temperature": true,
"knowledge": "2025-05",
"release_date": "2026-02-05",
"last_updated": "2026-02-05",
"modalities": {
"input": [
"text",
"image",
"pdf"
],
"output": [
"text"
]
},
"open_weights": false,
"cost": {
"input": 5,
"output": 25,
"cache_read": 0.5,
"cache_write": 6.25,
"context_over_200k": {
"input": 10,
"output": 37.5,
"cache_read": 1,
"cache_write": 12.5
}
},
"limit": {
"context": 200000,
"output": 128000
},
"variants": {
"adaptive": {
"thinking": {
"type": "adaptive" // special case handled by plugin
}
},
"high": {
"thinking": {
"type": "enabled",
"budgetTokens": 16000
}
},
"max": {
"thinking": {
"type": "enabled",
"budgetTokens": 128000
}
}
}
}
}
}
},
}BouquetAntoine commented on Feb 6, 2026 github-actions commented on Apr 8, 2026 To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|