Preflight Checklist
What's Wrong?
UserPromptSubmit hooks fire when a Task tool (subagent) completes, not just when the user submits a prompt. The hook output is displayed alongside the agent completion message in the UI.
Example output showing the bug:
Agent "Explore getAllObjectIds implementation" completed.
⎿ UserPromptSubmit hook succeeded: REMINDER: Use run_in_background: true for Task and Bash tool calls when the operation may take time and does not need immediate output.
The UserPromptSubmit hook should only fire when I (the user) submit a prompt, not when an internal subagent finishes.
What Should Happen?
UserPromptSubmit should fire only when the user submits a prompt, per the documentation:
"Fires when you submit a prompt, before Claude processes it"
Agent/Task completion should not trigger this hook. SubagentStop exists for that purpose.
Error Messages/Logs
No errors - the hook executes successfully, but at the wrong time.
Steps to Reproduce
- Add a
UserPromptSubmit hook to ~/.claude/settings.json:
{
"hooks": {
"UserPromptSubmit": [
{
"hooks": [
{
"type": "command",
"command": "echo 'This should only appear on user prompt submission'"
}
]
}
]
}
}
- Start Claude Code
- Ask Claude to perform a task that spawns a subagent (e.g., "Search the codebase for X" which triggers an Explore agent)
- Observe the output when the subagent completes
- Bug: The
UserPromptSubmit hook output appears after the agent completion message
Claude Model
Opus 4.5
Is this a regression?
I don't know
Last Working Version
No response
Claude Code Version
2.1.1
Platform
Claude Max subscription
Operating System
macOS
Terminal/Shell
Ghostty
Additional Information
Possibly related issues:
This may be related to the underlying architecture where all agents share the same session context, causing hook events to fire incorrectly or be attributed to the wrong event source.
Preflight Checklist
What's Wrong?
UserPromptSubmithooks fire when a Task tool (subagent) completes, not just when the user submits a prompt. The hook output is displayed alongside the agent completion message in the UI.Example output showing the bug:
The
UserPromptSubmithook should only fire when I (the user) submit a prompt, not when an internal subagent finishes.What Should Happen?
UserPromptSubmitshould fire only when the user submits a prompt, per the documentation:Agent/Task completion should not trigger this hook.
SubagentStopexists for that purpose.Error Messages/Logs
No errors - the hook executes successfully, but at the wrong time.
Steps to Reproduce
UserPromptSubmithook to~/.claude/settings.json:{ "hooks": { "UserPromptSubmit": [ { "hooks": [ { "type": "command", "command": "echo 'This should only appear on user prompt submission'" } ] } ] } }UserPromptSubmithook output appears after the agent completion messageClaude Model
Opus 4.5
Is this a regression?
I don't know
Last Working Version
No response
Claude Code Version
2.1.1
Platform
Claude Max subscription
Operating System
macOS
Terminal/Shell
Ghostty
Additional Information
Possibly related issues:
This may be related to the underlying architecture where all agents share the same session context, causing hook events to fire incorrectly or be attributed to the wrong event source.