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
4 changes: 2 additions & 2 deletions packages/opencode/src/provider/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,6 @@ export function variants(model: Provider.Model): Record<string, Record<string, a
if (
id.includes("deepseek") ||
id.includes("minimax") ||
id.includes("glm") ||
id.includes("mistral") ||
id.includes("kimi") ||
id.includes("k2p5") ||
Expand Down Expand Up @@ -828,7 +827,8 @@ export function options(input: {

if (
["zai", "zhipuai"].some((id) => input.model.providerID.includes(id)) &&
input.model.api.npm === "@ai-sdk/openai-compatible"
input.model.api.npm === "@ai-sdk/openai-compatible" &&
input.model.capabilities.reasoning
) {
result["thinking"] = {
type: "enabled",
Expand Down
37 changes: 31 additions & 6 deletions packages/opencode/test/provider/transform.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,27 @@ describe("ProviderTransform.options - zai/zhipuai thinking", () => {
clear_thinking: false,
})
})

test(`${providerID} should NOT set thinking cfg for non-reasoning model`, () => {
const result = ProviderTransform.options({
model: {
...createModel(providerID),
capabilities: {
temperature: true,
reasoning: false,
attachment: true,
toolcall: true,
input: { text: true, audio: false, image: false, video: false, pdf: false },
output: { text: true, audio: false, image: false, video: false, pdf: false },
interleaved: false,
},
},
sessionID,
providerOptions: {},
})

expect(result.thinking).toBeUndefined()
})
}
})

Expand Down Expand Up @@ -2099,18 +2120,22 @@ describe("ProviderTransform.variants", () => {
expect(result).toEqual({})
})

test("glm returns empty object", () => {
test("glm via openai-compatible returns reasoning efforts", () => {
const model = createMockModel({
id: "glm/glm-4",
providerID: "glm",
id: "zai-coding-plan/glm-4.7",
providerID: "zai-coding-plan",
api: {
id: "glm-4",
url: "https://api.glm.com",
id: "glm-4.7",
url: "https://open.bigmodel.cn/api/paas/v4",
npm: "@ai-sdk/openai-compatible",
},
})
const result = ProviderTransform.variants(model)
expect(result).toEqual({})
expect(result).toEqual({
low: { reasoningEffort: "low" },
medium: { reasoningEffort: "medium" },
high: { reasoningEffort: "high" },
})
})

test("mistral returns empty object", () => {
Expand Down
Loading