From 6c3308aab3904b1e91ea29fba3487e77865c689b Mon Sep 17 00:00:00 2001 From: ahuang Date: Fri, 10 Apr 2026 21:28:11 +0800 Subject: [PATCH] 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. --- src/shared/model-capabilities/runtime-model-readers.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/shared/model-capabilities/runtime-model-readers.ts b/src/shared/model-capabilities/runtime-model-readers.ts index a7b740f32..3dc96b14d 100644 --- a/src/shared/model-capabilities/runtime-model-readers.ts +++ b/src/shared/model-capabilities/runtime-model-readers.ts @@ -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 }