MoonshotAI / MoonshotAI/kimi-cli
Invalid tool call corrupt the whole session
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 11.4k
- Forks
- 1.3k
- Avg merge
- 9h 47m
- Merged PRs (30d)
- 2
Description
What version of Kimi Code CLI is running?
kimi, version 1.41.0
Which open platform/subscription were you using?
local vllm deployed kimi-k2.6
Which model were you using?
kimi-k2.6
What platform is your computer?
linux
What issue are you seeing?
When the model generates malformed JSON inside a tool_call.function.arguments string (e.g. a missing opening quote like description": "..."), kimi-cli writes that assistant message into session history (~/.kimi/sessions/.../context.jsonl) without validating the JSON. On the ne
xt turn, the entire message history is sent to the LLM backend. The backend (vLLM/OpenAI-compatible server) attempts to json.loads() that malformed string and returns HTTP 400. Because the poisoned message is now permanently in history, every subsequent request fails with the
same 400 error, making the session unrecoverable.
What steps can reproduce the bug?
- Start a kimi-cli session against a local vLLM/OpenAI-compatible endpoint.
- Trigger an assistant turn where the model emits a tool_call with malformed JSON in arguments. In the reported case this happened naturally during a multi-tool-call turn:
{"command": "...", "run_in_background": true, description": "mesh15k baseline without transfer"}
(missing " before description). - The client shows a parsing error for that single call, but the assistant message has already been persisted to context.jsonl.
- Type any follow-up message (e.g. continue).
- kimi-cli sends the full history to the backend → vLLM parses tool_calls[*].function.arguments as part of the OpenAI chat schema → json.loads fails → 400 BadRequest.
- Every subsequent request repeats the same 400 because the poisoned history is still being sent.
What is the expected behavior?
No response
Additional information
No response
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
Start by tracing how assistant tool-call messages are persisted to ~/.kimi/sessions/.../context.jsonl after a parsing error, then reproduce the malformed-JSON case against the local vLLM/OpenAI-compatible endpoint. Done means the invalid call is not retained in a way that makes later requests fail with the same 400 error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- linux, python
- Domain
- backend-api-design, cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100