Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Jul 15, 2025

This PR fixes the issue where the moonshotai/kimi-k2-instruct model was causing 400 errors due to max_tokens exceeding the API limit.

Changes Made

  1. Updated model configuration: Changed moonshotai/kimi-k2-instruct maxTokens from 8192 to 16384 to match the actual API limit
  2. Added validation in BaseOpenAiCompatibleProvider: Ensures that max_tokens never exceeds the model's configured limit, even when users override with modelMaxTokens
  3. Fixed TypeScript types: Added proper type checking to handle nullish values for maxTokens

Problem Solved

  • Prevents 400 errors: "max_tokens must be less than or equal to 16384"
  • Ensures user-configured modelMaxTokens values are capped at the model's actual API limits
  • Maintains backward compatibility while preventing API errors

Testing

  • All existing tests pass
  • TypeScript compilation successful
  • Linting passes

Fixes #5729


Important

Fixes max_tokens limit issue for moonshotai/kimi-k2-instruct model by updating configuration and adding validation in BaseOpenAiCompatibleProvider.

  • Behavior:
    • Updated maxTokens for moonshotai/kimi-k2-instruct in groq.ts from 8192 to 16384.
    • Added validation in BaseOpenAiCompatibleProvider to cap max_tokens at model's API limit.
  • TypeScript:
    • Improved type checking for maxTokens to handle nullish values.
  • Testing:
    • All existing tests pass.
    • TypeScript compilation and linting successful.

This description was created by Ellipsis for ebd6aec. You can customize this summary. It will automatically update as commits are pushed.

Roo Code added 2 commits July 15, 2025 09:17
- Update moonshotai/kimi-k2-instruct maxTokens from 8192 to 16384 to match API limit
- Add validation in BaseOpenAiCompatibleProvider to ensure max_tokens never exceeds model limits
- Prevent 400 error when users set modelMaxTokens above API constraints

Fixes #5729
- Add proper type checking for modelMaxTokens to handle nullish values
- Ensure Math.min only receives number types
@roomote roomote bot requested review from cte, jr and mrubens as code owners July 15, 2025 09:20
@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. bug Something isn't working labels Jul 15, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jul 15, 2025
@valuin
Copy link

valuin commented Jul 15, 2025

+1 facing this issue ty for the PR

@mrubens
Copy link
Collaborator

mrubens commented Jul 15, 2025

Fixed in another way

@mrubens mrubens closed this Jul 15, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jul 15, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Jul 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:S This PR changes 10-29 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

moonshotai/kimi-k2-instruct model issue

4 participants