Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/opus-4-8-adaptive-thinking.md
Original file line number Diff line number Diff line change
@@ -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.
6 changes: 5 additions & 1 deletion packages/opencode/src/plugin/github-copilot/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
16 changes: 12 additions & 4 deletions packages/opencode/src/provider/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
Expand Down Expand Up @@ -780,9 +782,11 @@ export function variants(model: Provider.Model): Record<string, Record<string, a
if (adaptiveEfforts) {
let efforts = [...adaptiveEfforts]
if (model.providerID === "github-copilot") {
if (model.api.id.includes("opus-4.7")) {
// kilocode_change start - treat opus-4.8 like opus-4.7
if (model.api.id.includes("opus-4.7") || model.api.id.includes("opus-4.8")) {
efforts = ["medium"]
}
// kilocode_change end
// Efforts currently supported are: low, medium, high
efforts = efforts.filter((v) => v !== "max" && v !== "xhigh")
}
Expand All @@ -792,9 +796,11 @@ export function variants(model: Provider.Model): Record<string, Record<string, a
{
thinking: {
type: "adaptive",
...(model.api.id.includes("opus-4-7") || model.api.id.includes("opus-4.7")
// kilocode_change start - treat opus-4.8 like opus-4.7
...(["opus-4-7", "opus-4.7", "opus-4-8", "opus-4.8"].some((v) => model.api.id.includes(v))
? { display: "summarized" }
: {}),
// kilocode_change end
},
effort,
},
Expand Down Expand Up @@ -827,9 +833,11 @@ export function variants(model: Provider.Model): Record<string, Record<string, a
reasoningConfig: {
type: "adaptive",
maxReasoningEffort: effort,
...(model.api.id.includes("opus-4-7") || model.api.id.includes("opus-4.7")
// kilocode_change start - treat opus-4.8 like opus-4.7
...(["opus-4-7", "opus-4.7", "opus-4-8", "opus-4.8"].some((v) => model.api.id.includes(v))
? { display: "summarized" }
: {}),
// kilocode_change end
},
},
]),
Expand Down
46 changes: 45 additions & 1 deletion packages/opencode/test/kilocode/transform-opus-4.7.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function mockModel(overrides: Partial<any> = {}): 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: {
Expand Down Expand Up @@ -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: {
Expand Down
Loading