Skip to content

fix: add kimi/moonshot to Anthropic tool thinking history normalizer#3377

Merged
farion1231 merged 2 commits into
farion1231:mainfrom
Neon-Wang:fix/kimi-anthropic-tool-thinking-history
May 31, 2026
Merged

fix: add kimi/moonshot to Anthropic tool thinking history normalizer#3377
farion1231 merged 2 commits into
farion1231:mainfrom
Neon-Wang:fix/kimi-anthropic-tool-thinking-history

Conversation

@Neon-Wang

@Neon-Wang Neon-Wang commented May 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • is_anthropic_tool_thinking_history_identifier 中补充 kimimoonshot 的匹配,使其与 is_reasoning_content_compatible_identifier 保持一致
  • 修复 Kimi Anthropic 兼容端点(api.kimi.com/coding)在 thinking 启用 + 多轮 tool call 对话时返回 400 的问题

Root cause: is_anthropic_tool_thinking_history_identifier only matched deepseek/mimo/xiaomimimo, missing kimi/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

  • 配置 Kimi Code 供应商,API 格式选 Anthropic Messages (原生),启用 thinking
  • 进行多轮对话并触发 tool call,确认不再返回 400 thinking is enabled but reasoning_content is missing
  • 回归测试:确认 DeepSeek/Mimo 路径不受影响

🤖 Generated with Claude Code

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]>
@Neon-Wang

Copy link
Copy Markdown
Contributor Author

补充一下验证细节:这个 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 下已有两位用户(@SODAGARY@Gitniubro)确认遇到了相同问题,影响面不止我一人。

改动仅 6 行,补充 kimi / moonshotis_anthropic_tool_thinking_history_identifier 以与 is_reasoning_content_compatible_identifier 保持一致。风险极低,烦请 @farion1231 @yovinchen 帮忙 review 🙏

@farion1231

farion1231 commented May 31, 2026 via email

Copy link
Copy Markdown
Owner

@farion1231

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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.

@farion1231 farion1231 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

非常感谢您的贡献!

@farion1231
farion1231 merged commit e02a276 into farion1231:main May 31, 2026
3 checks passed
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: Kimi Anthropic-compatible endpoint missing from tool thinking history normalization

2 participants