fix(provider): widen Kimi anthropic-SDK thinking match to K2.x#739
Conversation
Cherry-pick from upstream anomalyco/opencode #23696 (commit 58232d896, 2026-04-21). Without this, Kimi for Coding K2.6 (k2p6) on the Anthropic SDK path never gets `thinking` enabled, the request is rejected by Moonshot's coding endpoint, and the user is stuck in a 10-attempt retry loop showing "The engine is currently overloaded, please try again later". Root cause: - `kimi-for-coding` uses `@ai-sdk/anthropic` but Kimi is not an Anthropic model. Moonshot's coding endpoint requires `thinking: enabled` on K2.x reasoning models or it returns a misleading overload-style error. - The existing transform only matched K2.5 ids (`k2p5`, `kimi-k2.5`, `kimi-k2p5`). K2.6 (`k2p6`) had no transform and went out unmodified. Change boundary: - transform.ts: substring match widened from `k2p5` -> `k2p` and from `kimi-k2.5` -> `kimi-k2.` in two places (variants() and options()). Now covers K2.5, K2.6, and future K2.x without further edits. - transform.test.ts: update the existing "Kimi anthropic thinking" block to assert K2.5 and K2.6 both get thinking enabled, while `kimi-k2-preview`, `kimi-k2`, and `kimi-k2-thinking` still don't. Out of scope: - This PR does not touch the OpenAI-compatible Kimi paths (volcengine plan, moonshot.cn, moonshot.ai). Those already have their own reasoning_content handling.
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
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.
Code Review
This pull request generalizes the matching logic for Kimi K2 models by replacing specific version strings like 'k2p5' with broader patterns such as 'k2p' and 'kimi-k2.', and updates the test suite to include additional K2.x variants. The reviewer recommends using explicit regular expressions instead of broad string inclusion checks to ensure more robust model identification and avoid unintended matches.
|
Re Gemini review on These two hunks are an intentional verbatim cherry-pick of upstream anomalyco/opencode commit The false-positive surface Gemini is worried about is bounded by what Not actioning the suggestion. Resolving the threads. |
Summary
Widen the
transform.tssubstring match that enablesthinkingon Kimi models served over the Anthropic SDK path, so Kimi K2.6 (k2p6) is covered the same way K2.5 already is. Cherry-pick from upstream anomalyco/opencode commit58232d896(PR #23696, 2026-04-21).Why
Upstream widened the Anthropic-SDK Kimi match from K2.5-only to all
k2.xids a month ago. PawWork missed that sync, so on the Anthropic-SDK Kimi path (kimi-for-codingprovider), K2.6 requests went out without thethinkingblock that Moonshot's coding endpoint expects on reasoning models. This is a latent protocol-level gap on a paid Kimi tier.Note on scope: a user-reported "death loop on Kimi for Coding K2.6" arrived at the same time, and this PR was initially expected to fix it. End-to-end testing on a real Kimi for Coding plan account showed that the death-loop symptom is actually
HTTP 429 + rate_limit_errorfrom Moonshot side (a quota / rate-limit issue, not a protocol issue). Builds on this branch send the correctthinkingblock but still hit 429 when the account is rate-limited. So this PR fixes a real protocol gap but is not the fix for the rate-limit report; that needs separate work on retry behavior and error messaging.Related Issue
No GitHub issue. The rate-limit UX follow-up will be tracked separately.
Human Review Status
Pending. A human should make the final merge decision after reviewing the final diff and verification evidence.
Review Focus
58232d896exactly (k2p5->k2p,kimi-k2.5->kimi-k2.). The intent is to stay sync-friendly, not to micro-optimize the match shape.kimi-k2-preview,kimi-k2,kimi-k2-thinking) are the only K2-family ids in our snapshot that should still be excluded.Risk Notes
kimi-for-codingpermodels-snapshot.js. OpenAI-compatible Kimi paths (volcengine plan, moonshot.cn, moonshot.ai) are untouched.kimi-k2-thinkingreturns reasoning content by design and intentionally stays out of this branch; covered by the negative test.How To Verify
Targeted local checks from the worktree:
Manual desktop verification on a real Kimi for Coding K2.6 account confirmed the request body now includes
thinking: { type: enabled, budget_tokens: 16000 }on this branch. Server-side rate-limit behavior is out of scope for this PR.Screenshots or Recordings
Not applicable; provider-layer change with no UI surface.
Checklist
bug,enhancement,task, ordocumentation), at least one primary routing label (app,ui,platform,harness, orci), and exactly one priority label (P0toP3), or I requested maintainer labelingdev, and my PR title and commit messages use Conventional Commits in English