MoonshotAI / MoonshotAI/kimi-cli
Windows Shell Commands Failing - PowerShell subprocess handling bug in Kimi CLI
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.17.0
Which open platform/subscription were you using?
Kimi For Coding
Which model were you using?
agent (kimi-for-coding, thinking)
What platform is your computer?
Microsoft Windows NT 10.0.26200.0 x64 (Windows 11)
What issue are you seeing?
When using the Shell tool to run commands on Windows, all shell commands timeout (after 60s) and fail with:
SetValueInvocationException: Exception setting "CursorPosition": "The handle is invalid."
This occurs because Kimi CLI runs PowerShell without the -NoProfile flag, causing the user's PowerShell profile
to be loaded. If the profile contains UI-related commands like:
$RawUI.CursorPosition = @{X=0;Y=0}
They fail in Kimi CLI's non-interactive environment where no console window handle exists.
This bug makes the Shell tool completely unusable on Windows for affected users, which is critical functionality.
The issue appears to be that Kimi CLI's Shell tool runs PowerShell without the -NoProfile flag (kimi_cli/tools/ shell/__init__.py line 127). The user's PowerShell profile contains UI commands that fail in Kimi CLI's non-interactive subprocess environment.
What steps can reproduce the bug?
- Start Kimi CLI on Windows
- Run any shell command, e.g.,
echo "hello" - Command hangs for 60 seconds then times out with "The handle is invalid" error
What is the expected behavior?
Tool call Shell commands should work on Windows using kimi-cli and the Kimi extension for visual studio code.
Additional information
PowerShell 7.5.4
SetValueInvocationException:
Line |
3 | $RawUI.CursorPosition = @{X=0;Y=0}
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Exception setting "CursorPosition": "The handle is invalid."
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
Inspect kimi_cli/tools/shell/init.py around line 127, where PowerShell is started without the -NoProfile flag. Reproduce the non-interactive Windows shell failure with a profile containing the shown CursorPosition command, then verify that a simple command such as echo "hello" completes without timing out or producing the handle error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell, python
- Domain
- cli, operating-systems
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 50/100