Skip to content
Closed
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
2 changes: 2 additions & 0 deletions packages/opencode/src/provider/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1704,6 +1704,8 @@ function reasoningEffort(model: Provider.Model, effort: string) {
}

function anthropicEffort(model: Provider.Model, effort: string) {
// K3's Anthropic-compatible endpoint exposes adaptive thinking through output_config.effort.
if (model.family === "kimi-k3") return { thinking: { type: "adaptive" }, effort }
if (["opus-4-5", "opus-4.5"].some((value) => model.api.id.includes(value))) return { effort }
if (!anthropicAdaptiveEfforts(model.api.id)) return
return {
Expand Down
14 changes: 14 additions & 0 deletions packages/opencode/test/provider/provider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1514,6 +1514,15 @@ test("models.dev reasoning options replace generated variants and unsupported op
limit: { context: 128_000, output: 64_000 },
experimental: { modes: { fast: {} } },
},
k3: {
id: "k3",
name: "Kimi K3",
family: "kimi-k3",
reasoning: true,
reasoning_options: [{ type: "effort", values: ["low", "high", "max"] }],
provider: { npm: "@ai-sdk/anthropic" },
limit: { context: 1_048_576, output: 131_072 },
},
},
} as unknown as ModelsDev.Provider

Expand All @@ -1531,6 +1540,11 @@ test("models.dev reasoning options replace generated variants and unsupported op
high: { thinkingConfig: { includeThoughts: true, thinkingLevel: "high" } },
})
expect(models["gemini-3-pro-fast"].variants).toEqual(models.override.variants)
expect(models.k3.variants).toEqual({
low: { thinking: { type: "adaptive" }, effort: "low" },
high: { thinking: { type: "adaptive" }, effort: "high" },
max: { thinking: { type: "adaptive" }, effort: "max" },
})
})

test("public provider info omits invalid models", () => {
Expand Down
17 changes: 15 additions & 2 deletions packages/opencode/test/provider/transform.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3028,8 +3028,8 @@ describe("ProviderTransform.temperature - Cohere North", () => {

describe("ProviderTransform.reasoningVariants", () => {
const model = (reasoning_options: ModelsDev.Model["reasoning_options"]) => ({ reasoning_options }) as ModelsDev.Model
const target = (npm: string, id = "test-model") =>
({ id, api: { id, npm, url: "" }, capabilities: { reasoning: true }, limit: { output: 64_000 } }) as any
const target = (npm: string, id = "test-model", family?: string) =>
({ id, family, api: { id, npm, url: "" }, capabilities: { reasoning: true }, limit: { output: 64_000 } }) as any

test("respects explicitly empty reasoning options", () => {
expect(ProviderTransform.reasoningVariants(model([]), target("@ai-sdk/openai"))).toEqual({})
Expand Down Expand Up @@ -3103,6 +3103,19 @@ describe("ProviderTransform.reasoningVariants", () => {
).toEqual({ high: { effort: "high" } })
})

test("uses adaptive effort for Kimi K3", () => {
expect(
ProviderTransform.reasoningVariants(
model([{ type: "effort", values: ["low", "high", "max"] }]),
target("@ai-sdk/anthropic", "k3", "kimi-k3"),
),
).toEqual({
low: { thinking: { type: "adaptive" }, effort: "low" },
high: { thinking: { type: "adaptive" }, effort: "high" },
max: { thinking: { type: "adaptive" }, effort: "max" },
})
})

test("leaves legacy Anthropic effort options to budget fallback", () => {
expect(
ProviderTransform.reasoningVariants(
Expand Down
Loading