MoonshotAI / MoonshotAI/kimi-code
0.42 回归:anthropic provider 不再限制 `max_tokens`,模型配置的 `max_context_size` 被原样发出,导致上游参数校验失败
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 7.5k
- Forks
- 1.2k
- Avg merge
- 11h 53m
- Merged PRs (30d)
- 350
Description
你运行的 Kimi Code 版本是?
0.42
你使用的是哪个开放平台/订阅?
第三方模型
你使用的是哪个模型?
deepseek-flash-official
你的电脑平台是?
Darwin 25.6.0 arm64 arm
你遇到了什么问题?
升级到 0.42.0 后,type = "anthropic" 的 provider 会把模型配置里的 max_context_size 直接当作 max_tokens 发出去,不再做任何限制。
0.41.0 对同一份配置发出的是 max_tokens: 128000,0.42.0 发出的是 max_tokens: 1048576。当上游模型的 max_tokens 上限小于配置值时,请求被拒;又因为上游(或网关)返回 5xx,客户端按可重试状态码处理,连续重试 10 次、共上传约 900 KB 无效请求,持续 2 分 30 秒后才向用户报错。
复现步骤?
使用 deepseek 选择anthropic 协议 模型选择deepseek-flash-official 上下文128000
上游返回报错
{"error":{"type":"invalid_request_error","message":"Invalid max_tokens value, the valid range of max_tokens is [1, 393216] (request id: sys_202609111048570015457668268d9d6AirgWPqr)"},"type":"error"}
期望的行为是什么?
按照 0.41 版本的方案处理
补充信息
No response
Contribution
- 我愿意自己提交修复此 bug 的 PR(请先等待维护者在本 issue 中批准)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Compare the anthropic provider request construction in versions 0.41.0 and 0.42.0, using the deepseek-flash-official reproduction with context size 128000 as the starting case. Verify that max_tokens follows the 0.41 behavior, that the request is accepted by an upstream limit of 393216, and that the invalid request is no longer retried repeatedly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100