MoonshotAI / MoonshotAI/kimi-cli
[Bug] Background auto-trigger permanently stops after 3 consecutive LLM timeouts, leaving long-running tasks unproced
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 11.4k
- Forks
- 1.3k
- Avg merge
- 9h 47m
- Merged PRs (30d)
- 2
Description
Problem
When a long-running background Bash task completes, the shell auto-triggers a foreground Soul run to process its results.
If this LLM request fails with APITimeoutError 3 times in a row, the shell permanently stops listening for background completions:
_MAX_BG_AUTO_TRIGGER_FAILURES = 3
This creates a hard stop.
As a result:
- A test running overnight completes successfully.
- The LLM request to analyze the results times out, often due to large accumulated output/context.
- After 3 timeouts, Kimi never retries.
- The user comes back to find
Request timed outspam and zero progress, even though the task finished hours ago.
Root Cause
From source analysis, in src/kimi_cli/ui/shell/__init__.py, the main loop does:
if bg_auto_failures >= _MAX_BG_AUTO_TRIGGER_FAILURES:
result = await idle_events.get()
At this point, the shell only waits for manual/user idle events and no longer listens for background completions.
There is no time-based recovery. Once 3 failures occur, the only way to resume is manual user input.
Suggested Fix
Add a cooldown timer.
After hitting the max failures, stop auto-triggering for a configurable duration, for example 10 minutes, then reset the counter and resume listening:
_BG_FAILURE_COOLDOWN_S = 600 # 10 minutes
Example logic:
if bg_auto_failures >= _MAX_BG_AUTO_TRIGGER_FAILURES:
if time.monotonic() - bg_last_failure_time > _BG_FAILURE_COOLDOWN_S:
bg_auto_failures = 0
result = await bg_watcher.wait_for_next(idle_events)
else:
result = await idle_events.get()
This matches the behavior of other agentic CLIs, such as Claude Code's periodic progress checks.
Environment
kimi-cliversion:1.41.0- OS: Windows 10/11
- Model:
kimi-for-coding/k2.6
Workaround
We applied the above patch locally and confirmed that it works.
The patch is minimal, around 6 lines changed, and does not affect normal operation.
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 in src/kimi_cli/ui/shell/init.py at the background auto-trigger failure counter and the branch that waits on idle_events after three failures. Add the cooldown behavior described in the issue, then verify that background completions are ignored during the cooldown and listened for again afterward.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100