UserPromptSubmit hooks not fired when user sends message mid-turn (regression)
Description
UserPromptSubmit hooks are completely skipped when the user sends a message while the agent is actively generating (mid-turn). The message is delivered to the agent as an interrupt, but no hooks fire. This appears to be a regression — it previously worked.
Steps to reproduce
- Configure a
UserPromptSubmithook (command or HTTP type):
{
"hooks": {
"UserPromptSubmit": [{
"hooks": [{
"type": "http",
"url": "http://127.0.0.1:9801/UserPromptSubmit",
"timeout": 180000
}]
}]
}
}
- Start a session and give the agent a long-running task (e.g., reading multiple files)
- While the agent is working (mid-turn, making tool calls), type and send a new message
- Observe: the message appears as an interrupt to the agent, but
UserPromptSubmithooks never fire
Evidence
Server-side logging on the hook HTTP endpoint shows:
- Normal prompts (agent idle):
HTTP BATCH UserPromptSubmit:*appears in logs, all hooks execute - Mid-turn messages: Zero
UserPromptSubmitentries in logs. OnlyPreToolUseandPostToolUsebatches continue from the current turn
The message is delivered to the agent via a <system-reminder> containing "The user sent a new message while you were working: ..." — but this bypasses all hook processing.
Impact
Any functionality that relies on UserPromptSubmit silently fails for mid-turn messages:
- Prompt parsing (e.g., extracting structured task commands from user input)
- Intent classification (determining if user wants investigation vs. implementation)
- Context injection (attaching external data/queue events to the prompt)
- Prompt validation/gating (blocking or modifying prompts before the agent sees them)
This is particularly problematic because users naturally send follow-up instructions while the agent is working. All hook-based processing for these messages is lost.
Expected behavior
UserPromptSubmit hooks should fire for every user-submitted message, regardless of whether the agent is idle or mid-turn. The hook output (additionalContext, systemMessage, etc.) should be attached to the message when it's delivered to the agent.
Environment
- Claude Code version: 2.1.69
- Platform: Windows 11 + WSL2
- Hook type tested: HTTP (
type: "http")
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗