fix(provider): force openai reasoning variants

This commit is contained in:
Aiden Cline
2026-06-30 21:42:19 -05:00
parent 3f0f90e94e
commit 1cb7b81552
2 changed files with 68 additions and 5 deletions
+13 -4
View File
@@ -1136,6 +1136,15 @@ const SLUG_OVERRIDES: Record<string, string> = {
}
export function providerOptions(model: Provider.Model, options: { [x: string]: any }) {
const usesOpenAIReasoningGate =
model.api.npm === "@ai-sdk/openai" ||
model.api.npm === "@ai-sdk/azure" ||
model.api.npm === "@ai-sdk/amazon-bedrock/mantle"
const normalized =
usesOpenAIReasoningGate && options.reasoningEffort !== undefined && options.forceReasoning === undefined
? { ...options, forceReasoning: true }
: options
if (model.api.npm === "@ai-sdk/gateway") {
// Gateway providerOptions are split across two namespaces:
// - `gateway`: gateway-native routing/caching controls (order, only, byok, etc.)
@@ -1145,8 +1154,8 @@ export function providerOptions(model: Provider.Model, options: { [x: string]: a
const i = model.api.id.indexOf("/")
const rawSlug = i > 0 ? model.api.id.slice(0, i) : undefined
const slug = rawSlug ? (SLUG_OVERRIDES[rawSlug] ?? rawSlug) : undefined
const gateway = options.gateway
const rest = Object.fromEntries(Object.entries(options).filter(([k]) => k !== "gateway"))
const gateway = normalized.gateway
const rest = Object.fromEntries(Object.entries(normalized).filter(([k]) => k !== "gateway"))
const has = Object.keys(rest).length > 0
const result: Record<string, any> = {}
@@ -1180,9 +1189,9 @@ export function providerOptions(model: Provider.Model, options: { [x: string]: a
// providerOptions["openai"], but OpenAIResponsesLanguageModel checks
// "azure" first. Pass both so model options work on either code path.
if (model.api.npm === "@ai-sdk/azure") {
return { openai: options, azure: options }
return { openai: normalized, azure: normalized }
}
return { [key]: options }
return { [key]: normalized }
}
export function maxOutputTokens(model: Provider.Model, outputTokenMax = OUTPUT_TOKEN_MAX): number {