MoonshotAI / MoonshotAI/kimi-cli
Agent loops on same shell command; output truncated
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.40.0
Which open platform/subscription were you using?
Kimi Code
Which model were you using?
kimi-for-coding
What platform is your computer?
Darwin 25.4.0 arm64 arm
What issue are you seeing?
I’m encountering two related issues recently:
-
Apparent infinite loop with repeated shell commands
When the agent is analyzing a codebase and searching for symbols (e.g.,class Decompress...ordef get_visible), it repeatedly issues the exact samegrepcommand dozens of times. Even after the command has already returned results, the agent continues to execute identical queries in a loop until I manually interrupt it withCtrl+C.
Screenshot evidence: the samegrep -n "class Decompress ... press_submission.py -A 10was executed ~15 times consecutively, and latergrep -n "def get_visible" ... s/task/auto_sync.py -A 25was executed another ~12 times. I had to interrupt twice with “你是不是死循环了?”. -
Command/response content truncated
Starting from a recent version, the CLI no longer displays the full content of commands or their outputs. Long paths and arguments are collapsed into...(e.g.,grep -n "class Decompress ... press_submission.py -A 10), making it impossible to see exactly which file is being queried or what the full output was. This significantly hinders debugging when the agent misbehaves.
What steps can reproduce the bug?
- Open a mid-to-large Python project in
kimi-cli. - Ask the agent to analyze or locate a specific class/function (e.g., “find where
DecompressSubmissionis defined” or “explainget_visibleinauto_sync.py”). - The agent starts spawning
grepcommands viaUsed Shell (...). - Observe: the agent repeats the same
grepcommand many times instead of stopping after the first successful result. - Observe: the command string itself is truncated with
...in the terminal UI, so the full path/arguments are hidden.
What is the expected behavior?
- Deduplication / loop prevention: After a
greporReadFilecall returns valid data, the agent should use that information to proceed with the task, rather than re-issuing the identical command indefinitely. - Full content display: The CLI should show the complete command string and its full output (or at least provide a
--verbose/debug flag to do so), as it did in earlier versions.
Additional information
- The issue happens intermittently but has become frequent recently.
- I have already tried interrupting the session (
Interrupted by user), but the agent resumes the same loop when a similar query context is given. - Screenshots attached showing the repeated
Used Shellentries and the truncation with....
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
Reproduce the repeated grep behavior and truncated command display in kimi-cli using a mid-to-large Python project, then trace the shell-command execution and terminal rendering paths. Done means identical commands no longer loop after valid results, and commands and outputs are fully visible or available through a verbose/debug option.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- ai, cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100