fix: add kimi/moonshot to Anthropic tool thinking history normalizer#3377
Merged
farion1231 merged 2 commits intoMay 31, 2026
Merged
Conversation
Kimi's Anthropic-compatible endpoint requires reasoning_content in assistant tool call messages when thinking is enabled, same as DeepSeek. The is_reasoning_content_compatible_identifier already included kimi/moonshot but is_anthropic_tool_thinking_history_identifier was missing them, causing 400 errors on multi-turn conversations with tool calls. Closes farion1231#3351 Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Contributor
Author
|
补充一下验证细节:这个 bug 是在 Claude Desktop 环境下复现并修复验证的,和 Claude Code 客户端无关。 本地验证(Claude Desktop):
Issue 下已有两位用户(@SODAGARY、@Gitniubro)确认遇到了相同问题,影响面不止我一人。 改动仅 6 行,补充 |
Owner
|
非常感谢!我马上review
Haoyu Wang ***@***.***> 于2026年5月31日周日 14:50写道:
… *Neon-Wang* left a comment (farion1231/cc-switch#3377)
<#3377 (comment)>
补充一下验证细节:这个 bug 是在 *Claude Desktop* 环境下复现并修复验证的,和 Claude Code 客户端无关。
*本地验证(Claude Desktop):*
- 配置 Kimi Code 供应商,API 格式选 Anthropic Messages (原生),启用 thinking
- 在 Claude Desktop 中进行多轮对话并触发 tool call,不再返回 400 thinking is enabled
but reasoning_content is missing
- DeepSeek 路径回归测试正常,不受影响
Issue ***@***.*** ***@***.***
<https://github.com/Gitniubro>)确认遇到了相同问题,影响面不止我一人。
改动仅 6 行,补充 kimi / moonshot 到 is_anthropic_tool_thinking_history_identifier
以与 is_reasoning_content_compatible_identifier 保持一致。风险极低,烦请 @farion1231
<https://github.com/farion1231> @yovinchen <https://github.com/yovinchen>
帮忙 review 🙏
—
Reply to this email directly, view it on GitHub
<#3377?email_source=notifications&email_token=AKW3RFH2XTIIGM4OQVEBO6T45PI4FA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTINJYGU4TQMJSGIZ2M4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-4585981223>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AKW3RFCWOIMQXYSXRB7ABKD45PI4FAVCNFSM6AAAAACZTU4LDOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DKOBVHE4DCMRSGM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Owner
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Replace the two separately-maintained vendor identifier lists with one shared REASONING_VENDOR_HINTS constant and a single is_reasoning_vendor_identifier predicate. The Anthropic tool-thinking-history matcher and the openai_chat reasoning_content matcher previously kept independent lists, which is exactly how kimi/moonshot ended up in one but not the other (farion1231#3351). A single source of truth keeps the two from drifting apart again. Also add a Kimi regression test for the Anthropic tool-history normalization path.
2 tasks
gfunc
pushed a commit
to gfunc/cc-switch
that referenced
this pull request
Jun 19, 2026
…arion1231#3377) * fix: add kimi/moonshot to Anthropic tool thinking history normalizer Kimi's Anthropic-compatible endpoint requires reasoning_content in assistant tool call messages when thinking is enabled, same as DeepSeek. The is_reasoning_content_compatible_identifier already included kimi/moonshot but is_anthropic_tool_thinking_history_identifier was missing them, causing 400 errors on multi-turn conversations with tool calls. Closes farion1231#3351 Co-Authored-By: Claude Sonnet 4.6 <[email protected]> * refactor: unify reasoning vendor hints into a single SSOT list Replace the two separately-maintained vendor identifier lists with one shared REASONING_VENDOR_HINTS constant and a single is_reasoning_vendor_identifier predicate. The Anthropic tool-thinking-history matcher and the openai_chat reasoning_content matcher previously kept independent lists, which is exactly how kimi/moonshot ended up in one but not the other (farion1231#3351). A single source of truth keeps the two from drifting apart again. Also add a Kimi regression test for the Anthropic tool-history normalization path. --------- Co-authored-by: Claude Sonnet 4.6 <[email protected]> Co-authored-by: Jason <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
is_anthropic_tool_thinking_history_identifier中补充kimi和moonshot的匹配,使其与is_reasoning_content_compatible_identifier保持一致api.kimi.com/coding)在 thinking 启用 + 多轮 tool call 对话时返回 400 的问题Root cause:
is_anthropic_tool_thinking_history_identifieronly matcheddeepseek/mimo/xiaomimimo, missingkimi/moonshot. Kimi's Anthropic-compatible endpoint has the same requirement as DeepSeek — assistant tool call messages must include a thinking block when thinking is enabled.Closes #3351
Test plan
Anthropic Messages (原生),启用 thinking400 thinking is enabled but reasoning_content is missing🤖 Generated with Claude Code