[BUG] Agent hook on PreToolUse fails with "Messages are required for agent hooks"

Resolved 💬 3 comments Opened Apr 14, 2026 by kerstin97 Closed Apr 17, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

An agent type hook configured on PreToolUse fails immediately with an error.

What Should Happen?

The agent hook runs and executes the prompt with tool access.

Error Messages/Logs

Error: `Messages are required for agent hooks. This is a bug.`

Steps to Reproduce

Add this to .claude/settings.json:

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "agent",
            "if": "Bash(git commit:*)",
            "timeout": 120,
            "model": "claude-sonnet-4-6",
            "statusMessage": "Checking spec files...",
            "prompt": "Run git diff --cached --name-only and report what files are staged."
          }
        ]
      }
    ]
  }
}

Then trigger a git commit via Claude Code. The hook fires but immediately errors.

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.107

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

VS Code integrated terminal

Additional Information

_No response_

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗