fix(provider): keep budget variants distinct

This commit is contained in:
Aiden Cline 2026-07-01 11:18:35 -05:00
commit 3e9cbc9178
2 changed files with 21 additions and 1 deletions

View file

@ -615,8 +615,9 @@ function reasoningBudgetVariants(
) {
const max = Math.max(1, Math.min(budget.max ?? 31_999, maxOutputTokens(model) - 1))
const min = Math.min(budget.min ?? 1, max)
const high = Math.max(min, max > 16_000 ? 16_000 : Math.ceil(max / 2))
return {
high: make(Math.max(min, Math.min(16_000, max))),
high: make(high),
max: make(max),
}
}

View file

@ -3072,6 +3072,25 @@ describe("ProviderTransform.variants", () => {
expect(result.max).toEqual({ thinkingConfig: { includeThoughts: true, thinkingBudget: 31999 } })
})
test("reasoning_options budget tokens keep high and max distinct below the default cap", () => {
const result = ProviderTransform.variants(
createMockModel({
id: "google/gemini-small-budget",
providerID: "google",
api: {
id: "gemini-small-budget",
url: "https://generativelanguage.googleapis.com",
npm: "@ai-sdk/google",
},
reasoning_options: [{ type: "budget_tokens", min: 128, max: 8000 }],
}),
)
expect(result).toEqual({
high: { thinkingConfig: { includeThoughts: true, thinkingBudget: 4000 } },
max: { thinkingConfig: { includeThoughts: true, thinkingBudget: 8000 } },
})
})
test("reasoning_options ignore toggle-only models", () => {
const result = ProviderTransform.variants(
createMockModel({