fix(models): preserve explicitly configured maxTokens when window-capping - #63
Merged
Merged
Conversation
…ping PR #59 window-caps every built model's maxTokens at its context window, which silently discards an explicitly configured model.maxTokens — home, project, and runtime settings all get reset to the window. Preserve the explicit cap and apply the window value only for the default/unset case: - "Unset" is detected by value (maxTokens === built-in default), not by config source: ensureKimiCodeConfig materializes the full default config (including maxTokens: 32000) into the home config file, so source tracking reports "home" for users who never set the field and would defeat the window-cap for them. - A cap already equal to the context window is also treated as unset: buildKimiModelFromConfig caps before discovery runs, so applyKimiOAuthExtrasToModel captures the window-tracked state before extras grow the window, and only then re-caps maxTokens to the new window. Explicit caps survive discovery unchanged. Known edges (documented in code): an explicit 32000 is indistinguishable from a materialized default and gets the window cap; an explicit value equal to the window is treated as window-tracked. Stacked on #59.
Contributor
CI summary
|
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.
Stacked on #59 — merge after it
#59 is from a fork, so its branch can't be a PR base here; this PR targets
mainand its diff will shrink to the single fix commit once #59 merges.What
#59 window-caps every built model's
maxTokensat its context window viawithWindowCappedMaxTokens, which silently discards an explicitly configuredmodel.maxTokens— home, project, and runtime settings all get reset to the window. This PR preserves the explicit cap and applies the window value only for the default/unset case.How
maxTokens=== built-in default 32000), not by config source:ensureKimiCodeConfigmaterializes the full default config (includingmaxTokens) into the home config file, so source tracking reportshomefor users who never set the field — source-based detection would defeat the window-cap for exactly the users it targets.buildKimiModelFromConfigcaps before discovery runs, soapplyKimiOAuthExtrasToModelcaptures the window-tracked state before extras grow the window, and only re-capsmaxTokensto the new window when it was tracking. Explicit caps survive discovery unchanged.Known edges (documented in code)
maxTokens: 32000is indistinguishable from a materialized default and gets the window cap — acceptable, since that is the intended new default behavior.Tests
Two new cases: explicit cap preserved at build time, and preserved when discovery grows the window.
tsc --noEmit,oxlint, and the full suite pass (235/235).Summary by cubic
Preserves explicitly configured max tokens when window-capping models, so user-set limits are not overwritten. The window cap now applies only when the value is unset (default) or already tracking the window.
Written for commit e622aa9. Summary will update on new commits.