Skip to content

Commit 603bd25

Browse files
committed
fix(opencode): remove model ID blocklist from reasoning variants
Use capabilities.reasoning from models.dev as the sole gate for whether a model gets reasoning effort variants, instead of hardcoding model ID exclusions. This allows openai-compatible providers like Fireworks, z-ai and deepseek to correctly send reasoning_effort.
1 parent 5eaef6b commit 603bd25

File tree

2 files changed

+22
-24
lines changed

2 files changed

+22
-24
lines changed

packages/opencode/src/provider/transform.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -404,17 +404,6 @@ export function variants(model: Provider.Model): Record<string, Record<string, a
404404

405405
const id = model.id.toLowerCase()
406406
const adaptiveEfforts = anthropicAdaptiveEfforts(model.api.id)
407-
if (
408-
id.includes("deepseek") ||
409-
id.includes("minimax") ||
410-
id.includes("glm") ||
411-
id.includes("mistral") ||
412-
id.includes("kimi") ||
413-
id.includes("k2p5") ||
414-
id.includes("qwen") ||
415-
id.includes("big-pickle")
416-
)
417-
return {}
418407

419408
// see: https://docs.x.ai/docs/guides/reasoning#control-how-hard-the-model-thinks
420409
if (id.includes("grok") && id.includes("grok-3-mini")) {
@@ -635,6 +624,9 @@ export function variants(model: Provider.Model): Record<string, Record<string, a
635624
reasoningConfig: {
636625
type: "adaptive",
637626
maxReasoningEffort: effort,
627+
...(model.api.id.includes("opus-4-7") || model.api.id.includes("opus-4.7")
628+
? { display: "summarized" }
629+
: {}),
638630
},
639631
},
640632
]),

packages/opencode/test/provider/transform.test.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2071,7 +2071,7 @@ describe("ProviderTransform.variants", () => {
20712071
expect(result).toEqual({})
20722072
})
20732073

2074-
test("deepseek returns empty object", () => {
2074+
test("deepseek with reasoning enabled returns WIDELY_SUPPORTED_EFFORTS via openai-compatible", () => {
20752075
const model = createMockModel({
20762076
id: "deepseek/deepseek-chat",
20772077
providerID: "deepseek",
@@ -2082,35 +2082,39 @@ describe("ProviderTransform.variants", () => {
20822082
},
20832083
})
20842084
const result = ProviderTransform.variants(model)
2085-
expect(result).toEqual({})
2085+
expect(Object.keys(result)).toEqual(["low", "medium", "high"])
2086+
expect(result.low).toEqual({ reasoningEffort: "low" })
2087+
expect(result.high).toEqual({ reasoningEffort: "high" })
20862088
})
20872089

2088-
test("minimax returns empty object", () => {
2090+
test("deepseek without reasoning capability returns empty object", () => {
20892091
const model = createMockModel({
2090-
id: "minimax/minimax-model",
2091-
providerID: "minimax",
2092+
id: "deepseek/deepseek-chat",
2093+
providerID: "deepseek",
2094+
capabilities: { reasoning: false },
20922095
api: {
2093-
id: "minimax-model",
2094-
url: "https://api.minimax.com",
2096+
id: "deepseek-chat",
2097+
url: "https://api.deepseek.com",
20952098
npm: "@ai-sdk/openai-compatible",
20962099
},
20972100
})
20982101
const result = ProviderTransform.variants(model)
20992102
expect(result).toEqual({})
21002103
})
21012104

2102-
test("glm returns empty object", () => {
2105+
test("glm with reasoning enabled returns WIDELY_SUPPORTED_EFFORTS via openai-compatible", () => {
21032106
const model = createMockModel({
2104-
id: "glm/glm-4",
2105-
providerID: "glm",
2107+
id: "zai-coding/glm-5.1",
2108+
providerID: "zai-coding",
21062109
api: {
2107-
id: "glm-4",
2108-
url: "https://api.glm.com",
2110+
id: "glm-5.1",
2111+
url: "https://open.bigmodel.cn/api/paas/v4",
21092112
npm: "@ai-sdk/openai-compatible",
21102113
},
21112114
})
21122115
const result = ProviderTransform.variants(model)
2113-
expect(result).toEqual({})
2116+
expect(Object.keys(result)).toEqual(["low", "medium", "high"])
2117+
expect(result.medium).toEqual({ reasoningEffort: "medium" })
21142118
})
21152119

21162120
test("mistral returns empty object", () => {
@@ -2804,12 +2808,14 @@ describe("ProviderTransform.variants", () => {
28042808
reasoningConfig: {
28052809
type: "adaptive",
28062810
maxReasoningEffort: "xhigh",
2811+
display: "summarized",
28072812
},
28082813
})
28092814
expect(result.max).toEqual({
28102815
reasoningConfig: {
28112816
type: "adaptive",
28122817
maxReasoningEffort: "max",
2818+
display: "summarized",
28132819
},
28142820
})
28152821
})

0 commit comments

Comments
 (0)