Skip to content

fix(oauth): record max_output_size from custom-registry model limits - #3733

Open
gfunc wants to merge 1 commit into
MoonshotAI:mainfrom
gfunc:main
Open

fix(oauth): record max_output_size from custom-registry model limits#3733
gfunc wants to merge 1 commit into
MoonshotAI:mainfrom
gfunc:main

Conversation

@gfunc

@gfunc gfunc commented Sep 11, 2026

Copy link
Copy Markdown

Related Issue

Resolve #3732

Problem

See linked issue. In short: models imported from a custom registry (api.json) ignore the advertised limit.output, so the alias never records maxOutputSize. 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_tokens for openai_responses, max_completion_tokens/max_tokens for openai, max_tokens for anthropic — 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: read limit.output (validated as a positive integer) from each registry model entry into the alias maxOutputSize — mirroring how limit.contextmaxContextSize is already handled, and matching the existing models.dev integration's convention for the same field.
  • packages/oauth/src/model-alias-merge.ts: add maxOutputSize to CUSTOM_REGISTRY_MODEL_FIELDS so registry refreshes keep the field in sync — new values applied, stale values dropped when the registry stops declaring it, user overrides preserved.
  • Tests: cover the limit.outputmaxOutputSize mapping and the stale-drop-on-refresh case.
  • Changeset included (@moonshot-ai/kimi-code, patch).

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PR — awaiting the maintainer's /approve on the issue per policy).
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update. (No doc update needed: the docs do not document registry limit fields, and this change makes behavior match the data registries already advertise.)

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-bot

changeset-bot Bot commented Sep 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 076cd1d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Custom registry ignores advertised limit.output — providers reject requests with 400 "Invalid max_tokens"

1 participant