What version of Kimi Code CLI is running?
1.17.0
Which open platform/subscription were you using?
Moonshot AI Open Platform
Which model were you using?
kimi-2.5
What platform is your computer?
Linux 6.1.158 x86_64 unknown
What issue are you seeing?
When the LLM generates tool_call.function.arguments containing literal control characters (e.g. unescaped newlines in multi-line git commit messages), json.loads() raises a JSONDecodeError because Python's JSON parser rejects unescaped control characters (U+0000 through U+001F) by default.
This causes a cascade of failures:
- Tool execution fails —
json.loads() in toolset.py:123 and simple.py:122 raises JSONDecodeError
- Session history is poisoned — the malformed arguments string is persisted to the context file
- Session becomes irrecoverable — on restore,
json.loads(line) in context.py:40 fails, and on every subsequent API call _convert_message() sends the malformed arguments back to the API, which returns HTTP 400
What steps can reproduce the bug?
- Start a kimi-cli session
- Ask the LLM to run a shell command that includes a multi-line string, e.g.:
Run: git commit -m "feat: add feature
This is a multi-line
commit message"
- The LLM generates a
Shell tool call with literal newlines in the JSON arguments string
- Observe the error:
ERROR: Error parsing JSON arguments: Invalid control character at: line 1 column 264 (char 263)
- The session is now broken — resuming it will fail with the same error or HTTP 400
What is the expected behavior?
No response
Additional information
Example trace
{
"role": "assistant",
"content": [],
"tool_calls": [
{
"type": "function",
"id": "functions.Shell:22",
"function": {
"name": "Shell",
"arguments": "{\"command\": \"git commit -m \\\"feat: add feature\n\nMulti-line message\\\"\"}"
}
}
]
}
{
"role": "tool",
"content": "<system>ERROR: Error parsing JSON arguments: Invalid control character at: line 1 column 264 (char 263)</system>",
"tool_call_id": "functions.Shell:22"
}
What version of Kimi Code CLI is running?
1.17.0
Which open platform/subscription were you using?
Moonshot AI Open Platform
Which model were you using?
kimi-2.5
What platform is your computer?
Linux 6.1.158 x86_64 unknown
What issue are you seeing?
When the LLM generates
tool_call.function.argumentscontaining literal control characters (e.g. unescaped newlines in multi-line git commit messages),json.loads()raises aJSONDecodeErrorbecause Python's JSON parser rejects unescaped control characters (U+0000 through U+001F) by default.This causes a cascade of failures:
json.loads()intoolset.py:123andsimple.py:122raisesJSONDecodeErrorjson.loads(line)incontext.py:40fails, and on every subsequent API call_convert_message()sends the malformed arguments back to the API, which returns HTTP 400What steps can reproduce the bug?
Shelltool call with literal newlines in the JSON arguments stringWhat is the expected behavior?
No response
Additional information
Example trace
{ "role": "assistant", "content": [], "tool_calls": [ { "type": "function", "id": "functions.Shell:22", "function": { "name": "Shell", "arguments": "{\"command\": \"git commit -m \\\"feat: add feature\n\nMulti-line message\\\"\"}" } } ] }{ "role": "tool", "content": "<system>ERROR: Error parsing JSON arguments: Invalid control character at: line 1 column 264 (char 263)</system>", "tool_call_id": "functions.Shell:22" }