SessionStart hooks crash when dispatcher routes through prompt-hook path expecting ToolUseContext
Bug
SessionStart hooks error out because the hook dispatcher routes them through the prompt-hook code path, which expects a ToolUseContext that doesn't exist for SessionStart events.
Steps to reproduce
- Register a SessionStart hook in
~/.claude/settings.json:
``json``
{
"hooks": {
"SessionStart": [
{
"type": "command",
"command": "echo '{\"systemMessage\": \"hello\"}'",
"timeout": 5000
}
]
}
}
- Start a new Claude Code session
- Observe the hook error in output
Expected behavior
SessionStart hooks should execute without errors. They don't involve tool use, so the dispatcher should not require ToolUseContext.
Actual behavior
The dispatcher routes SessionStart hooks through the prompt-hook path, which expects tool context. Since SessionStart hooks fire before any tools are invoked, there is no ToolUseContext available, causing an error.
Environment
- Claude Code: 2.1.109
- OS: macOS (Darwin arm64)
Notes
Despite the error, the hooks still appear to execute and their output reaches Claude's context (the systemMessage content is injected). The error seems to be a non-fatal code path issue in the dispatcher rather than a complete failure, but it generates noise on every session start.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗