From 6a0f501b19e52ab4685eba215f7fb41c6586794f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=B6=E7=84=B6=E6=99=AF?= Date: Sat, 11 Apr 2026 03:00:26 +0800 Subject: [PATCH] fix: UserPromptSubmit hook loses prompt when user_input is list[ContentPart] In terminal mode, Shell.run_soul_command passes user_input.content (which is list[ContentPart]) to KimiSoul.run. The existing code only handled the str case, causing the hook payload's 'prompt' to always be empty. Extract text parts from ContentPart list so hooks can capture the actual user input. --- src/kimi_cli/soul/kimisoul.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/kimi_cli/soul/kimisoul.py b/src/kimi_cli/soul/kimisoul.py index e2501bf38..c3f280c73 100644 --- a/src/kimi_cli/soul/kimisoul.py +++ b/src/kimi_cli/soul/kimisoul.py @@ -480,7 +480,14 @@ async def run(self, user_input: str | list[ContentPart]): set_session_id(self._runtime.session.id) # --- UserPromptSubmit hook --- - text_input_for_hook = user_input if isinstance(user_input, str) else "" + if isinstance(user_input, str): + text_input_for_hook = user_input + else: + _parts: list[str] = [] + for _part in user_input: + if getattr(_part, "type", None) == "text": + _parts.append(getattr(_part, "text", "")) + text_input_for_hook = "".join(_parts) from kimi_cli.hooks import events hook_results = await self._hook_engine.trigger(