MoonshotAI / MoonshotAI/kimi-cli
ToolSearch / MCP tool_reference messages poison session on api.kimi.com/coding/ and cause persistent HTTP 400 invalid_request_error
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 11.4k
- Forks
- 1.3k
- Avg merge
- 9h 47m
- Merged PRs (30d)
- 2
Description
Description
When using the Anthropic-compatible Kimi Code endpoint at https://api.kimi.com/coding/, sessions appear to break permanently after ToolSearch introduces MCP tool_reference messages into the conversation context.
The provider then starts returning:
HTTP 400
invalid_request_error: Invalid request Error
Once the session contains tool_reference content, follow-up requests continue to fail until a new session is started.
This looks like a provider-side schema / content-type compatibility issue rather than a generic tool failure.
What version of Kimi Code CLI is running?
Observed across:
2.1.1232.1.138
Which open platform/subscription were you using?
api.kimi.com/coding/ (Kimi Code subscription / Anthropic-compatible endpoint)
Which model were you using?
Kimi Code model via api.kimi.com/coding/.
What platform is your computer?
macOS / Darwin arm64
What issue are you seeing?
A failing session and a healthy session were compared side by side.
Problematic session:
- Real API 400 errors:
5 - ToolSearch calls:
1 - MCP
tool_referencemessages: present - Native tools like Agent/Bash: normal
- Claude Code version: issue persisted from
2.1.123to2.1.138
Healthy session:
- Real API 400 errors:
0 - ToolSearch calls:
0 - MCP
tool_referencemessages: absent - Native tools like Agent/Bash: normal
- Claude Code version:
2.1.138
Suspected failure chain:
- Assistant calls ToolSearch
- ToolSearch returns 3 MCP Playwright tool references
- Those
tool_referenceitems are added to the conversation context - The provider gateway encounters an unsupported / unrecognized content type while parsing the request
- The request fails with HTTP 400
invalid_request_error - Because the bad content remains in context, follow-up requests continue to fail
What steps can reproduce the bug?
- Use
https://api.kimi.com/coding/in an Anthropic-compatible coding client - Start a fresh session
- Invoke ToolSearch so the tool returns MCP tool references
- Let those
tool_referencemessages enter the conversation history - Send the next normal assistant/user turn
- Observe
HTTP 400 invalid_request_error: Invalid request Error
What is the expected behavior?
The provider should either:
- fully support
tool_reference/ MCP-related message content in the conversation schema, or - safely ignore / normalize unsupported content instead of permanently poisoning the session.
A session should not become unrecoverable just because ToolSearch returned MCP references.
Additional information
What seems ruled out:
- Not ordinary tool usage in general, because native tools continued to work in healthy sessions
- Not purely a client-version issue, because the correlation is with
tool_referencepresence, not just CLI version
Please investigate:
- schema compatibility for
tool_referencecontent inapi.kimi.com/coding/ - provider gateway parsing for MCP-related message content
- fallback behavior for unknown content types
- support status for ToolSearch / MCP /
tool_referenceunder the Anthropic-compatible endpoint
I can provide redacted logs / context snippets if needed.
中文补充:
当 ToolSearch / MCP 返回的 tool_reference 被写入上下文后,api.kimi.com/coding/ 后续请求会开始持续返回 400,像是 provider 网关不认识这种消息内容类型。一旦上下文被污染,这个 session 基本就废掉了,只能开新 session。这个问题在未触发 ToolSearch 的新 session 中不会出现。
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
No files or tests are named. Start by reproducing the issue against https://api.kimi.com/coding/ with a fresh session, invoking ToolSearch and then sending a normal turn; compare the request context with a healthy session. Done means the resulting session no longer persistently returns HTTP 400 after MCP tool_reference messages are present.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 42/100