Skip to content

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

Merged
sailist merged 1 commit into
MoonshotAI:mainfrom
gfunc:main
Oct 29, 2026
Merged

sailist merged 1 commit into
MoonshotAI:mainfrom
gfunc:main

Conversation

@gfunc

@gfunc gfunc commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

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.context → maxContextSize 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.output → maxOutputSize 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.)

@changeset-bot

changeset-bot Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0f48e45

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

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'.
@sailist
sailist merged commit 990580d into MoonshotAI:main Oct 29, 2026
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 4, 2026
The behaviour of MoonshotAI#4421 has been in the requester since 94397aa, but its
suite still asserted only that the lowered system message lost its
`tools` field, which a message kept in place would also satisfy. Assert
instead that no system message survives and the history keeps its
length, and rename the case after what it protects.

Also settle ten ledger rows that were already implemented here: MoonshotAI#3733,
MoonshotAI#4413, MoonshotAI#4418, MoonshotAI#4421, MoonshotAI#4435, MoonshotAI#4460, MoonshotAI#4465, MoonshotAI#4516, MoonshotAI#4523, MoonshotAI#4532 and the
MoonshotAI#4558 test calibration, each with a probe over the suite that pins it.
Two rows carried a probe without a test-name selector (MoonshotAI#4557, MoonshotAI#4558),
which aborted `--verify` for every other row; MoonshotAI#4557 is a changelog sync
and now carries a manual probe.
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"

2 participants