From 478463df56f80b48cd1b27ee059193d0d7222233 Mon Sep 17 00:00:00 2001 From: qiaozongming Date: Thu, 18 Jun 2026 19:05:50 +0800 Subject: [PATCH] fix: allow custom providers to switch reasoning effort for proxied models --- packages/opencode/src/provider/transform.ts | 17 ++++- .../opencode/test/provider/transform.test.ts | 71 +++++++++++++++++++ 2 files changed, 86 insertions(+), 2 deletions(-) diff --git a/packages/opencode/src/provider/transform.ts b/packages/opencode/src/provider/transform.ts index 009b8fba..bfe1d1f7 100644 --- a/packages/opencode/src/provider/transform.ts +++ b/packages/opencode/src/provider/transform.ts @@ -505,6 +505,7 @@ export function variants(model: Provider.Model): Record { 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", () => {