MoonshotAI / MoonshotAI/kimi-cli

UserPromptSubmit hook receives empty prompt when user_input is list[ContentPart]

Open Beginner friendly
#2,148 0 comments 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.41.0

Which open platform/subscription were you using?

kimi

Which model were you using?

kimi-k2.6

What platform is your computer?

Microsoft Windows NT 10.0.26200.0 x64

What issue are you seeing?

Bug: UserPromptSubmit hook receives empty prompt when user_input is list[ContentPart]
The UserPromptSubmit hook receives an empty prompt field when the user's input is formatted as a list of ContentPart o
bjects (which is the default for all messages).
Root cause in kimi_cli/soul/kimisoul.py line 601:
text_input_for_hook = user_input if isinstance(user_input, str) else ""
When user_input is list[ContentPart], it becomes "" and the hook receives empty prompt.
Expected: extract text from ContentPart list like it's done later:
user_message = Message(role="user", content=user_input)
text_input = user_message.extract_text(" ").strip()
Actual hook payload:
{
"hook_event_name": "UserPromptSubmit",
"session_id": "...",
"cwd": "...",
"prompt": ""
}

What steps can reproduce the bug?
  1. Configure a UserPromptSubmit hook in ~/.kimi/config.toml
  2. Start Kimi CLI and send any message
  3. Check the hook's stdin — prompt field is always empty
    What is the expected behavior?
    The hook should receive the actual text content of the user's message, extracted from ContentPart objects.
    Additional information
    • Environment: kimi-cli v1.41.0, Windows 11, Python 3.13
    • This affects the Beta hooks system introduced in v1.28.0
    • The matcher_value parameter also receives empty string, making regex matching ineffective
What is the expected behavior?

No response

Additional information

No response

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

Start in kimi_cli/soul/kimisoul.py around line 601, where text_input_for_hook is prepared, and compare it with the later Message.extract_text(" ").strip() path. Ensure UserPromptSubmit receives the extracted text for list[ContentPart] input and that matcher_value uses the same text. Done means the hook payload contains the user's message instead of an empty prompt.

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
82/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.