-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: override Kimi-K2 context window to 131K to match OpenRouter advertised specs #6760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…rtised specs - OpenRouter API returns 63K for moonshotai/kimi-k2 but their website shows 131K - Added manual override in parseOpenRouterModel to set correct context window - Added test to verify the override works correctly Fixes #6759
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wrote this code 5 minutes ago and already forgot why maxTokens uses the original value.
| // Should override to 131K (131072) instead of using the API's 63K | ||
| expect(result.contextWindow).toBe(131072) | ||
| // Max tokens should be calculated as 20% of context window | ||
| expect(result.maxTokens).toBe(Math.ceil(63000 * 0.2)) // Still uses original for maxTokens calculation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this intentional? The test comment mentions "Still uses original for maxTokens calculation", but it might be confusing that the context window is overridden to 131K while maxTokens remains based on the original 63K (20% of 63K = 12,600). Consider either:
- Using 20% of the new 131K context window for consistency
- Adding a comment in the implementation explaining why maxTokens uses the original value
| } | ||
|
|
||
| // Override kimi-k2 context window to match OpenRouter's advertised 131K | ||
| // The API returns 63K but the website shows 131K |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be helpful to add a link to the OpenRouter website page as a reference? For example:
| // The API returns 63K but the website shows 131K | |
| // Override kimi-k2 context window to match OpenRouter's advertised 131K | |
| // The API returns 63K but the website shows 131K | |
| // See: https://openrouter.ai/moonshotai/kimi-k2 |
|
|
||
| // Override kimi-k2 context window to match OpenRouter's advertised 131K | ||
| // The API returns 63K but the website shows 131K | ||
| if (id === "moonshotai/kimi-k2") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider moving this override closer to other model-specific overrides (lines 236-248) for better code organization and consistency with the existing pattern.
Summary
This PR fixes the context window discrepancy for the Kimi-K2 model in RooCode. While OpenRouter's API returns 63K for the context window, their website advertises 131K. This PR adds a manual override to ensure users get the full advertised context window.
Problem
context_length: 63000formoonshotai/kimi-k2Solution
parseOpenRouterModelfunction to set the context window to 131072 (131K) for themoonshotai/kimi-k2modelTesting
Fixes #6759
Important
Overrides
moonshotai/kimi-k2model context window to 131072 inparseOpenRouterModelto match advertised 131K, with a new test verifying the change.moonshotai/kimi-k2model context window to 131072 inparseOpenRouterModelto match advertised 131K.openrouter.spec.tsto verify context window override formoonshotai/kimi-k2.This description was created by
for a324a9d. You can customize this summary. It will automatically update as commits are pushed.