fix: treat zero limit.output as unknown to enable fallback to bundled snapshot

When a custom OpenAI-compatible provider does not return model limits,
its provider-models.json cache entries have limit.output = 0. The nullish
coalescing operator (??) does not fallback on 0 since it is not undefined,
causing maxOutputTokens to stay at 0 and triggering the AI SDK error:
"maxOutputTokens must be >= 1".

By returning undefined for 0 or negative values, the ?? in
get-model-capabilities.ts correctly falls through to the bundled snapshot
which contains the correct output limits.
This commit is contained in:
ahuang
2026-04-10 21:28:11 +08:00
parent b7ca40f646
commit 6c3308aab3
@@ -186,5 +186,7 @@ export function readRuntimeModelLimitOutput(
return undefined
}
return readNumber(limit.output)
const output = readNumber(limit.output)
// Treat 0 or negative as unknown so ?? fallback to bundled snapshot works
return output && output > 0 ? output : undefined
}