Skip to content

UserPromptSubmit Hook stdout is silently discarded — no way to inject prompt e nhancements #2304

@gg159753

Description

@gg159753

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?

  1. Configure a UserPromptSubmit hook in ~/.kimi/config.toml:
    [[hooks]]
    event = "UserPromptSubmit"
    command = "python ~/.kimi/hooks/kimi_mem_hooks.py"
    timeout = 15

  2. 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)

  1. Run kimi and send any message.
  2. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions