Skip to content

fix: extract text from ContentPart list for UserPromptSubmit hook prompt#1781

Open
Sibuxiangx wants to merge 1 commit intoMoonshotAI:mainfrom
Sibuxiangx:fix/user-prompt-submit-hook-empty-prompt
Open

fix: extract text from ContentPart list for UserPromptSubmit hook prompt#1781
Sibuxiangx wants to merge 1 commit intoMoonshotAI:mainfrom
Sibuxiangx:fix/user-prompt-submit-hook-empty-prompt

Conversation

@Sibuxiangx
Copy link
Copy Markdown

@Sibuxiangx Sibuxiangx commented Apr 7, 2026

Problem

The UserPromptSubmit hook event always sends an empty string for the prompt field when the user input comes from the shell UI.

Root cause: In kimisoul.py, user_input passed to run() is typed as str | list[ContentPart]. The shell UI always passes list[ContentPart], but the hook code only extracted text for the str case:

text_input_for_hook = user_input if isinstance(user_input, str) else ""

Fix

Use Message.extract_text() to properly extract text from list[ContentPart], consistent with how text_input is extracted just a few lines later in the same method:

if isinstance(user_input, str):
    text_input_for_hook = user_input
else:
    text_input_for_hook = Message(role="user", content=user_input).extract_text(" ").strip()

Testing

  • All 34 existing hook tests pass
  • Manually verified: hook now receives {"prompt": "hello this is a test prompt for hook"} instead of {"prompt": ""}

Fixes #1779


Open with Devin

When user_input is a list[ContentPart] (which is the normal case from the
shell UI), the UserPromptSubmit hook was passing an empty string for the
prompt field. This fix uses Message.extract_text() to properly extract the
text content, consistent with how text_input is extracted a few lines later.

Fixes MoonshotAI#1779
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes the UserPromptSubmit hook payload so the prompt field contains the actual user-entered text when the shell UI submits input as list[ContentPart] (instead of always sending an empty string).

Changes:

  • Extract text_input_for_hook from list[ContentPart] via Message.extract_text(" ").strip().
  • Keep str inputs unchanged while correctly populating the hook’s matcher_value and prompt payload for shell-originated inputs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] UserPromptSubmit hook event sends empty prompt field

2 participants