fix(oauth): record max_output_size from custom-registry model limits - #3733
Open
gfunc wants to merge 1 commit into
Open
fix(oauth): record max_output_size from custom-registry model limits#3733gfunc wants to merge 1 commit into
gfunc wants to merge 1 commit into
Conversation
Custom-registry (api.json) imports and refreshes wrote only max_context_size into model aliases, dropping limit.output even when the registry advertises it. With no max_output_size on the alias, the completion budget falls back to the full context window, so providers that validate the output-token cap (e.g. an openai_responses gateway with a 393216 ceiling) reject the request with '400 Invalid max_tokens value'.
🦋 Changeset detectedLatest commit: 076cd1d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
Related Issue
Resolve #3732
Problem
See linked issue. In short: models imported from a custom registry (
api.json) ignore the advertisedlimit.output, so the alias never recordsmaxOutputSize. The completion-budget cap then falls back to the model's full context size and goes out as the protocol's output-token field (max_output_tokensforopenai_responses,max_completion_tokens/max_tokensforopenai,max_tokensforanthropic— which additionally falls back to a 128k provider default). Any registry model with a smaller real output cap rejects the request with a 400 (e.g. "Invalid max_output_tokens").What changed
packages/oauth/src/custom-registry.ts: readlimit.output(validated as a positive integer) from each registry model entry into the aliasmaxOutputSize— mirroring howlimit.context→maxContextSizeis already handled, and matching the existing models.dev integration's convention for the same field.packages/oauth/src/model-alias-merge.ts: addmaxOutputSizetoCUSTOM_REGISTRY_MODEL_FIELDSso registry refreshes keep the field in sync — new values applied, stale values dropped when the registry stops declaring it, useroverridespreserved.limit.output→maxOutputSizemapping and the stale-drop-on-refresh case.@moonshot-ai/kimi-code, patch).Checklist
/approveon the issue per policy).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update. (No doc update needed: the docs do not document registrylimitfields, and this change makes behavior match the data registries already advertise.)