Skip to content

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

Description

@barrelc

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions