Agent hooks fail: Messages are required for agent hooks
Resolved 💬 3 comments Opened Apr 13, 2026 by Yanir-D Closed Apr 16, 2026
Bug Description
Agent hooks of "type": "agent" configured in PreToolUse fail with the error:
PreToolUse:Bash hook error
Failed to run: Messages are required for agent hooks. This is a bug.
The error message itself acknowledges this is a bug ("This is a bug").
Steps to Reproduce
- Configure an agent hook in settings.json:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "agent",
"if": "Bash(gh pr-create:*)",
"prompt": "Review the PR before creation...",
"model": "claude-sonnet-4-6",
"timeout": 180,
"statusMessage": "Pre-PR architectural review..."
}
]
}
]
}
}
(Note: the actual if pattern uses pr create with a space — adjusted here to avoid triggering commit hooks in this issue body)
- During a conversation, trigger a PR creation command
- The agent hook fires but immediately fails with the error above
Expected Behavior
The agent hook should receive the conversation messages and execute the sub-agent review as configured.
Actual Behavior
The hook errors with "Messages are required for agent hooks. This is a bug." The underlying tool call still executes successfully — the hook error is non-blocking — but the agent-based review never runs.
Environment
- Claude Code version: 2.1.104
- OS: macOS (Darwin 24.2.0)
- Shell: zsh
Additional Context
- The error appears to originate from the agent hook runner not receiving/passing conversation messages to the sub-agent
- Other hook types (
"type": "command") on the same matcher work fine - The
"if"conditional pattern matching works correctly (hook only fires on PR creation commands) - The hook is non-blocking, so the tool call succeeds despite the error
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗