fix(opencode): generate reasoning variants for all OpenRouter models. (#30332)
Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com> Co-authored-by: Aiden Cline <aidenpcline@gmail.com>
This commit is contained in:
parent
a86ecf3bba
commit
161247c70d
@ -703,12 +703,11 @@ export function variants(model: Provider.Model): Record<string, Record<string, a
|
||||
|
||||
switch (model.api.npm) {
|
||||
case "@openrouter/ai-sdk-provider":
|
||||
if (!id.includes("gpt") && !id.includes("gemini-3") && !id.includes("claude")) return {}
|
||||
return Object.fromEntries(
|
||||
(id.includes("gpt") ? openaiCompatibleReasoningEfforts(id) : OPENAI_EFFORTS).map((effort) => [
|
||||
effort,
|
||||
{ reasoning: { effort } },
|
||||
]),
|
||||
(model.api.id.startsWith("openai/") || id.includes("gpt")
|
||||
? openaiCompatibleReasoningEfforts(model.api.id)
|
||||
: WIDELY_SUPPORTED_EFFORTS
|
||||
).map((effort) => [effort, { reasoning: { effort } }]),
|
||||
)
|
||||
|
||||
case "ai-gateway-provider": {
|
||||
@ -1202,6 +1201,9 @@ export function smallOptions(model: Provider.Model) {
|
||||
return mergeDeep(base, small)
|
||||
}
|
||||
if (model.providerID === "openrouter" || model.providerID === "llmgateway") {
|
||||
if (model.providerID === "openrouter" && small.reasoning?.effort === "low") {
|
||||
return { reasoning: { effort: "none" } }
|
||||
}
|
||||
if (Object.keys(small).length === 0 && model.api.id.includes("google")) {
|
||||
return { reasoning: { enabled: false } }
|
||||
}
|
||||
|
||||
@ -2666,7 +2666,7 @@ describe("ProviderTransform.variants", () => {
|
||||
})
|
||||
|
||||
describe("@openrouter/ai-sdk-provider", () => {
|
||||
test("returns empty object for non-qualifying models", () => {
|
||||
test("returns widely supported efforts for other reasoning models", () => {
|
||||
const model = createMockModel({
|
||||
id: "openrouter/test-model",
|
||||
providerID: "openrouter",
|
||||
@ -2677,7 +2677,8 @@ describe("ProviderTransform.variants", () => {
|
||||
},
|
||||
})
|
||||
const result = ProviderTransform.variants(model)
|
||||
expect(result).toEqual({})
|
||||
expect(Object.keys(result)).toEqual(["low", "medium", "high"])
|
||||
expect(result.medium).toEqual({ reasoning: { effort: "medium" } })
|
||||
})
|
||||
|
||||
test("gpt models return OPENAI_EFFORTS with reasoning", () => {
|
||||
@ -2697,6 +2698,7 @@ describe("ProviderTransform.variants", () => {
|
||||
})
|
||||
|
||||
for (const testCase of [
|
||||
{ id: "openai/o3-mini", efforts: ["none", "minimal", "low", "medium", "high", "xhigh"] },
|
||||
{ id: "openai/gpt-5.4", efforts: ["none", "low", "medium", "high", "xhigh"] },
|
||||
{ id: "openai/gpt-5-pro", efforts: ["high"] },
|
||||
{ id: "openai/gpt-5.5-pro", efforts: ["medium", "high", "xhigh"] },
|
||||
@ -2722,7 +2724,7 @@ describe("ProviderTransform.variants", () => {
|
||||
})
|
||||
}
|
||||
|
||||
test("gemini-3 returns OPENAI_EFFORTS with reasoning", () => {
|
||||
test("gemini-3 returns widely supported efforts with reasoning", () => {
|
||||
const model = createMockModel({
|
||||
id: "openrouter/gemini-3-5-pro",
|
||||
providerID: "openrouter",
|
||||
@ -2733,7 +2735,7 @@ describe("ProviderTransform.variants", () => {
|
||||
},
|
||||
})
|
||||
const result = ProviderTransform.variants(model)
|
||||
expect(Object.keys(result)).toEqual(["none", "minimal", "low", "medium", "high", "xhigh"])
|
||||
expect(Object.keys(result)).toEqual(["low", "medium", "high"])
|
||||
})
|
||||
|
||||
test("grok-4 returns empty object", () => {
|
||||
@ -3985,6 +3987,23 @@ describe("ProviderTransform.smallOptions - gpt-5 chat/search", () => {
|
||||
}
|
||||
})
|
||||
|
||||
test("ProviderTransform.smallOptions disables OpenRouter reasoning when the weakest effort is low", () => {
|
||||
expect(
|
||||
ProviderTransform.smallOptions({
|
||||
providerID: "openrouter",
|
||||
api: {
|
||||
id: "anthropic/claude-sonnet-4.6",
|
||||
npm: "@openrouter/ai-sdk-provider",
|
||||
},
|
||||
variants: {
|
||||
low: { reasoning: { effort: "low" } },
|
||||
medium: { reasoning: { effort: "medium" } },
|
||||
high: { reasoning: { effort: "high" } },
|
||||
},
|
||||
} as any),
|
||||
).toEqual({ reasoning: { effort: "none" } })
|
||||
})
|
||||
|
||||
describe("ProviderTransform.smallOptions - google thinking controls", () => {
|
||||
const createGoogleModel = (apiId: string) => {
|
||||
const model = {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user