diff --git a/.changeset/opus-4-8-adaptive-thinking.md b/.changeset/opus-4-8-adaptive-thinking.md new file mode 100644 index 00000000000..30b7026287b --- /dev/null +++ b/.changeset/opus-4-8-adaptive-thinking.md @@ -0,0 +1,5 @@ +--- +"@kilocode/cli": patch +--- + +Fix Claude Opus 4.8 reasoning on Amazon Bedrock by treating it as an adaptive thinking model like Opus 4.7. This resolves the "thinking.type.enabled is not supported for this model" error and exposes the full low/medium/high/xhigh/max reasoning effort range. diff --git a/packages/opencode/src/plugin/github-copilot/models.ts b/packages/opencode/src/plugin/github-copilot/models.ts index acccf146d0f..286e7dc59e0 100644 --- a/packages/opencode/src/plugin/github-copilot/models.ts +++ b/packages/opencode/src/plugin/github-copilot/models.ts @@ -125,7 +125,11 @@ function build(key: string, remote: Item, url: string, prev?: Model): Model { variants[effort] = { thinking: { type: "adaptive", - ...(model.api.id.includes("opus-4.7") ? { display: "summarized" } : {}), + // kilocode_change start - treat opus-4.8 like opus-4.7 + ...(model.api.id.includes("opus-4.7") || model.api.id.includes("opus-4.8") + ? { display: "summarized" } + : {}), + // kilocode_change end }, effort, } diff --git a/packages/opencode/src/provider/transform.ts b/packages/opencode/src/provider/transform.ts index ab7a81ec818..e6f157c18e8 100644 --- a/packages/opencode/src/provider/transform.ts +++ b/packages/opencode/src/provider/transform.ts @@ -542,9 +542,11 @@ function openaiReasoningEfforts(apiId: string, releaseDate: string): string[] | } function anthropicAdaptiveEfforts(apiId: string): string[] | null { - if (["opus-4-7", "opus-4.7"].some((v) => apiId.includes(v))) { + // kilocode_change start - treat opus-4.8 like opus-4.7 + if (["opus-4-7", "opus-4.7", "opus-4-8", "opus-4.8"].some((v) => apiId.includes(v))) { return ["low", "medium", "high", "xhigh", "max"] } + // kilocode_change end if (["opus-4-6", "opus-4.6", "sonnet-4-6", "sonnet-4.6"].some((v) => apiId.includes(v))) { return ["low", "medium", "high", "max"] } @@ -780,9 +782,11 @@ export function variants(model: Provider.Model): Record v !== "max" && v !== "xhigh") } @@ -792,9 +796,11 @@ export function variants(model: Provider.Model): Record model.api.id.includes(v)) ? { display: "summarized" } : {}), + // kilocode_change end }, effort, }, @@ -827,9 +833,11 @@ export function variants(model: Provider.Model): Record model.api.id.includes(v)) ? { display: "summarized" } : {}), + // kilocode_change end }, }, ]), diff --git a/packages/opencode/test/kilocode/transform-opus-4.7.test.ts b/packages/opencode/test/kilocode/transform-opus-4.7.test.ts index 66c9b1d850e..af26d4163f8 100644 --- a/packages/opencode/test/kilocode/transform-opus-4.7.test.ts +++ b/packages/opencode/test/kilocode/transform-opus-4.7.test.ts @@ -30,7 +30,7 @@ function mockModel(overrides: Partial = {}): any { } } -describe("ProviderTransform.variants - Claude Opus 4.7", () => { +describe("ProviderTransform.variants - Claude Opus 4.7 / 4.8", () => { test("opus-4-7 returns adaptive thinking variants including xhigh (native anthropic)", () => { const model = mockModel({ api: { @@ -75,6 +75,50 @@ describe("ProviderTransform.variants - Claude Opus 4.7", () => { }) }) + test("opus-4-8 returns adaptive thinking variants including xhigh (native anthropic)", () => { + const model = mockModel({ + api: { + id: "claude-opus-4-8", + url: "https://api.anthropic.com", + npm: "@ai-sdk/anthropic", + }, + }) + const result = ProviderTransform.variants(model) + expect(Object.keys(result)).toEqual(["low", "medium", "high", "xhigh", "max"]) + expect(result.xhigh).toEqual({ + thinking: { type: "adaptive", display: "summarized" }, + effort: "xhigh", + }) + }) + + test("opus-4.8 dot-form returns adaptive thinking variants via @ai-sdk/gateway", () => { + const model = mockModel({ + id: "anthropic/claude-opus-4-8", + api: { + id: "anthropic/claude-opus-4.8", + url: "https://gateway.ai", + npm: "@ai-sdk/gateway", + }, + }) + const result = ProviderTransform.variants(model) + expect(Object.keys(result)).toEqual(["low", "medium", "high", "xhigh", "max"]) + }) + + test("opus-4-8 on bedrock returns adaptive reasoningConfig with xhigh", () => { + const model = mockModel({ + api: { + id: "anthropic.claude-opus-4-8", + url: "https://bedrock.amazonaws.com", + npm: "@ai-sdk/amazon-bedrock", + }, + }) + const result = ProviderTransform.variants(model) + expect(Object.keys(result)).toEqual(["low", "medium", "high", "xhigh", "max"]) + expect(result.xhigh).toEqual({ + reasoningConfig: { type: "adaptive", maxReasoningEffort: "xhigh", display: "summarized" }, + }) + }) + test("opus-4-6 keeps original adaptive efforts without xhigh", () => { const model = mockModel({ api: {