fix(kimi-code): correct maxTokens defaults and add server-side override - #1217
Conversation
Fixes Zoo-Code-Org#1215 - Update kimiCodeDefaultModelInfo.maxTokens from 32768 to 131072 - Add kimiCodeModelDefaults for per-model fallback values - Add max_tokens to kimiCodeModelSchema for server response parsing - Override maxTokens in mapKimiCodeModel: server > model-default > global-default - Add 4 new tests for maxTokens override and fallback behavior
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughKimi Code now uses 131,072-token defaults, parses optional server-provided ChangesKimi Code max token handling
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
src/api/providers/fetchers/__tests__/kimi-code.spec.tsESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox. src/api/providers/fetchers/kimi-code.tsESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/api/providers/fetchers/__tests__/kimi-code.spec.ts`:
- Around line 1-2: Update the fallback assertions in the kimi-code tests around
the cases at lines 124-134 to use independent fixture values for the documented
model defaults, rather than kimiCodeModelDefaults or
kimiCodeDefaultModelInfo.maxTokens. Remove those production-constant imports if
they are no longer used, while preserving the existing fallback behavior checks.
In `@src/api/providers/fetchers/kimi-code.ts`:
- Line 15: Update the max_tokens schema in the Kimi Code response validation to
require positive integers by adding integer validation before the existing
positivity and optional checks. Add a rejection test covering a fractional
max_tokens value and ensure mapKimiCodeModel does not receive it as
ModelInfo.maxTokens.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 072dd6a8-85c9-4888-bf7b-29f3278580fb
📒 Files selected for processing (3)
packages/types/src/providers/kimi-code.tssrc/api/providers/fetchers/__tests__/kimi-code.spec.tssrc/api/providers/fetchers/kimi-code.ts
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
- Replace production constant imports in tests with hardcoded fixture values - Add .int() validation to max_tokens Zod schema - Add fractional max_tokens rejection test - Export kimiCodeModelSchema for test access
|
@taltas I am so sorry! I didn't know how to handle the changes in my fork, so I made a mistake. Could you please check/help again? |
Summary
Fixes #1215
Kimi Code OAuth provider displayed incorrect Max Output values (32,768) for all models. According to Kimi's official documentation, the correct default for
kimi-k3is 131,072.Root Cause
Three issues in the codebase:
kimiCodeDefaultModelInfo.maxTokenswas hardcoded to32_768instead of131_072/modelsAPI response didn't includemax_tokensfield (silently stripped)mapKimiCodeModel()overrodecontextWindowfrom server but notmaxTokensChanges (3 files, +47/-1)
packages/types/src/providers/kimi-code.tsmaxTokensto131_072, addkimiCodeModelDefaultsfor per-model fallbacksrc/api/providers/fetchers/kimi-code.tsmax_tokensto Zod schema, override inmapKimiCodeModel()src/api/providers/fetchers/__tests__/kimi-code.spec.tsFallback Chain
This ensures automatic updates when the server provides
max_tokens, with per-model and global fallbacks.Verification
Summary by CodeRabbit
New Features
Bug Fixes