fix: treat zero limit.output as unknown to enable fallback to bundled…#3316
Open
ahuangsnail wants to merge 1 commit intocode-yeongyu:devfrom
Open
fix: treat zero limit.output as unknown to enable fallback to bundled…#3316ahuangsnail wants to merge 1 commit intocode-yeongyu:devfrom
ahuangsnail wants to merge 1 commit intocode-yeongyu:devfrom
Conversation
… 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.
Contributor
|
All contributors have signed the CLA. Thank you! ✅ |
There was a problem hiding this comment.
No issues found across 1 file
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Auto-approved: Fixes maxOutputTokens errors by treating non-positive limits as unknown, allowing fallback to bundled snapshots. Logic is sound and carries no regression risk.
|
Tested locally and fixes #3247 |
Author
|
I have read the CLA Document and I hereby sign the CLA |
Author
|
recheck |
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
maxOutputTokens must be >= 1error when using custom OpenAI-compatible providers (e.g., infini-ai) that don't return model limitslimit.outputvalues as unknown to enable fallback to bundled snapshot with correct limitsreadRuntimeModelLimitOutputbehavior with the nullish coalescing fallback chain inget-model-capabilities.tsChanges
readRuntimeModelLimitOutput()insrc/shared/model-capabilities/runtime-model-readers.ts:readNumber(limit.output)to check for positive values onlyundefinedfor 0 or negative values instead of passing them through??operator ingetModelCapabilities()to fall through to bundled snapshot entriesScreenshots
Testing