MoonshotAI / MoonshotAI/kimi-cli
UserPromptSubmit Hook stdout is silently discarded — no way to inject prompt e nhancements
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 CLI version: 1.43.0
Which open platform/subscription were you using?
/login
Which model were you using?
kimi-for-coding
What platform is your computer?
No response
What issue are you seeing?
The UserPromptSubmit Hook currently only supports block/allow decisions. Any s
tdout output from an allow hook is completely ignored by the engine, making it
impossible for hooks to modify the prompt or inject contextual information (e.
g., memory retrieval, RAG context) before the turn starts.
What steps can reproduce the bug?
-
Configure a UserPromptSubmit hook in ~/.kimi/config.toml:
[[hooks]]
event = "UserPromptSubmit"
command = "python ~/.kimi/hooks/kimi_mem_hooks.py"
timeout = 15 -
Create a hook script that queries an external memory service and prints enh
ed prompt to stdout:
#!/usr/bin/env python3
import json, sys
data = json.loads(sys.stdin.read())
prompt = data.get("prompt", "")
Query memory service and enhance prompt
memory = "【相关记忆】用户喜欢打篮球【/相关记忆】"
enhanced = f"{memory}\n\n{prompt}"
Try to return enhanced prompt
print(enhanced, flush=True)
- Run kimi and send any message.
- Observe that the hook is triggered (visible in logs), but the memory conten
ever reaches the LLM context.
What is the expected behavior?
When a UserPromptSubmit hook returns with action: allow, Kimi CLI should consu
me the stdout output and prepend/append it to the user prompt before sending t
o the LLM.
Desired protocol (one of):
• Option A: Hook prints plain text → Kimi CLI prepends it to the prompt as a s
tem/context message.
• Option B: Hook outputs modified JSON with an updated prompt or messages fiel
→ Kimi CLI replaces the original input data.
• Option C: Support a new inject action type that allows hooks to inject messa
s into the current turn.
Actual Behavior
Additional information
No response
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
The issue names no repository file or test; start by tracing UserPromptSubmit hook handling from the CLI entry point and review the protocol described in the issue. Resolve which stdout or structured-output contract is intended, then verify that the sample hook's output reaches the LLM prompt while existing allow/block behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100