MoonshotAI / MoonshotAI/kimi-cli

Agent loops on same shell command; output truncated

Open
#2,142 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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:

  1. Apparent infinite loop with repeated shell commands
    When the agent is analyzing a codebase and searching for symbols (e.g., class Decompress... or def get_visible), it repeatedly issues the exact same grep command 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 with Ctrl+C.
    Screenshot evidence: the same grep -n "class Decompress ... press_submission.py -A 10 was executed ~15 times consecutively, and later grep -n "def get_visible" ... s/task/auto_sync.py -A 25 was executed another ~12 times. I had to interrupt twice with “你是不是死循环了?”.

  2. 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.

Image
What steps can reproduce the bug?
  1. Open a mid-to-large Python project in kimi-cli.
  2. Ask the agent to analyze or locate a specific class/function (e.g., “find where DecompressSubmission is defined” or “explain get_visible in auto_sync.py”).
  3. The agent starts spawning grep commands via Used Shell (...).
  4. Observe: the agent repeats the same grep command many times instead of stopping after the first successful result.
  5. 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 grep or ReadFile call 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 Shell entries and the truncation with ....

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.