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
17 changes: 15 additions & 2 deletions packages/opencode/src/provider/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ export function variants(model: Provider.Model): Record<string, Record<string, a
if (!model.capabilities.reasoning) return {}

const id = model.id.toLowerCase()
const pid = model.providerID.toLowerCase()
const adaptiveEfforts = anthropicAdaptiveEfforts(model.api.id)
if (
id.includes("deepseek") ||
Expand All @@ -515,8 +516,20 @@ export function variants(model: Provider.Model): Record<string, Record<string, a
id.includes("k2p5") ||
id.includes("qwen") ||
id.includes("big-pickle")
)
return {}
) {
// Custom providers may proxy these models — only exclude built-in providers
// where the providerID matches the model family.
const isBuiltIn =
(id.includes("deepseek") && pid.includes("deepseek")) ||
(id.includes("minimax") && pid.includes("minimax")) ||
(id.includes("glm") && pid.includes("glm")) ||
(id.includes("mistral") && pid.includes("mistral")) ||
(id.includes("kimi") && pid.includes("kimi")) ||
(id.includes("k2p5") && pid.includes("k2p5")) ||
(id.includes("qwen") && pid.includes("qwen")) ||
(id.includes("big-pickle") && pid.includes("big-pickle"))
if (isBuiltIn) return {}
}

// see: https://docs.x.ai/docs/guides/reasoning#control-how-hard-the-model-thinks
if (id.includes("grok") && id.includes("grok-3-mini")) {
Expand Down
71 changes: 71 additions & 0 deletions packages/opencode/test/provider/transform.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2720,6 +2720,77 @@ describe("ProviderTransform.variants", () => {
expect(result.low).toEqual({ reasoningEffort: "low" })
expect(result.high).toEqual({ reasoningEffort: "high" })
})

test("custom provider with deepseek model ID returns variants", () => {
const model = createMockModel({
id: "my-provider/deepseek-v4-pro",
providerID: "my-provider",
api: {
id: "deepseek-v4-pro",
url: "https://my-api.example.com",
npm: "@ai-sdk/openai-compatible",
},
})
const result = ProviderTransform.variants(model)
expect(Object.keys(result)).toEqual(["low", "medium", "high"])
expect(result.low).toEqual({ reasoningEffort: "low" })
})

test("custom provider with minimax model ID returns variants", () => {
const model = createMockModel({
id: "my-provider/minimax-text-01",
providerID: "my-provider",
api: {
id: "minimax-text-01",
url: "https://my-api.example.com",
npm: "@ai-sdk/openai-compatible",
},
})
const result = ProviderTransform.variants(model)
expect(Object.keys(result)).toEqual(["low", "medium", "high"])
})

test("custom provider with glm model ID returns variants", () => {
const model = createMockModel({
id: "my-provider/glm-4",
providerID: "my-provider",
api: {
id: "glm-4",
url: "https://my-api.example.com",
npm: "@ai-sdk/openai-compatible",
},
})
const result = ProviderTransform.variants(model)
expect(Object.keys(result)).toEqual(["low", "medium", "high"])
})

test("custom provider with qwen model ID returns variants", () => {
const model = createMockModel({
id: "my-provider/qwen-max",
providerID: "my-provider",
api: {
id: "qwen-max",
url: "https://my-api.example.com",
npm: "@ai-sdk/openai-compatible",
},
})
const result = ProviderTransform.variants(model)
expect(Object.keys(result)).toEqual(["low", "medium", "high"])
})

test("custom provider with kimi model ID returns variants", () => {
const model = createMockModel({
id: "my-provider/kimi-latest",
providerID: "my-provider",
api: {
id: "kimi-latest",
url: "https://my-api.example.com",
npm: "@ai-sdk/openai-compatible",
},
})
const result = ProviderTransform.variants(model)
expect(Object.keys(result)).toEqual(["low", "medium", "high"])
})
})

describe("@ai-sdk/azure", () => {
Expand Down
Loading