Skip to content

Agent loops on same shell command; output truncated #2142

@yangliping

Description

@yangliping

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions