fix(agent): resolve kimi-k3 context window to 1M in fallback table - #67874
Closed
ericmourant wants to merge 1 commit into
Closed
ericmourant wants to merge 1 commit into
ericmourant wants to merge 1 commit into
Conversation
The DEFAULT_CONTEXT_LENGTHS catch-all "kimi": 262144 (written for the K2 generation) was the only Kimi entry, so longest-prefix matching resolved kimi-k3 to 256K. For configurations whose base_url does not reach a models.dev provider entry (e.g. provider=kimi-for-coding with base_url=https://api.moonshot.ai/v1), the fallback won and Hermes budgeted/compacted at a quarter of K3's actual 1M-token window. Add "kimi-k3": 1048576 ahead of the catch-all, matching models.dev (kimi-for-coding/k3, moonshotai/kimi-k3, moonshotai-cn/kimi-k3 all report context=1048576). Verified with agent.model_metadata.get_model_context_length: pre-patch: 262144 post-patch: 1048576
Collaborator
|
Resolved on main via PR #68108, which salvaged the materially identical earlier submission #67685 (first-submitted 2026-07-19) with that author's attribution preserved. Note the final landed value is 1,048,576 (1 Mi, matching models.dev / OpenRouter live metadata and the endpoint-scoped override) rather than 1,000,000. Thanks for the contribution — the independent confirmation was useful. |
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.
Motivation
Kimi K3 (Moonshot AI, 2.8T MoE) ships with a 1M-token context window — models.dev agrees:
kimi-for-coding/k3,moonshotai/kimi-k3, andmoonshotai-cn/kimi-k3all reportcontext: 1048576.However,
DEFAULT_CONTEXT_LENGTHSinagent/model_metadata.pyhad only the K2-generation catch-all"kimi": 262144. Longest-prefix matching resolveskimi-k3→kimi→ 256K, so for configurations where the models.dev provider lookup misses — e.g.provider: kimi-for-codingwithbase_url: https://api.moonshot.ai/v1— the stale fallback wins and Hermes budgets/compacts at a quarter of K3's actual working memory.Change
One line:
"kimi-k3": 1048576ahead of the"kimi"catch-all (longest-first matching makes it win). Fallback-table only; no change to live-metadata resolution paths.Verification
kimi-k2.6and other K2-family ids still resolve via thekimicatch-all to 262144, unchanged.Risk
None identified — additive, more-specific fallback entry; live metadata (models.dev / provider endpoints) still takes precedence where available.