claude-code - 💡(How to fix) Fix SessionStart hooks crash when dispatcher routes through prompt-hook path expecting ToolUseContext

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

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. 3. Observe the hook error in output 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. 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.

Root Cause

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.

Fix Action

Fix / Workaround

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.

SessionStart hooks should execute without errors. They don't involve tool use, so the dispatcher should not require ToolUseContext.

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.

Code Example

{
     "hooks": {
       "SessionStart": [
         {
           "type": "command",
           "command": "echo '{\"systemMessage\": \"hello\"}'",
           "timeout": 5000
         }
       ]
     }
   }
RAW_BUFFERClick to expand / collapse

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

  1. Register a SessionStart hook in ~/.claude/settings.json:
    {
      "hooks": {
        "SessionStart": [
          {
            "type": "command",
            "command": "echo '{\"systemMessage\": \"hello\"}'",
            "timeout": 5000
          }
        ]
      }
    }
  2. Start a new Claude Code session
  3. 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.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

SessionStart hooks should execute without errors. They don't involve tool use, so the dispatcher should not require ToolUseContext.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix SessionStart hooks crash when dispatcher routes through prompt-hook path expecting ToolUseContext