PostToolUse:Write hook error: 'Messages are required for agent hooks. This is a bug.' with CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1

Resolved 💬 4 comments Opened Apr 15, 2026 by daggy72 Closed Apr 23, 2026

Summary

After every Write or Edit tool call that triggers auto-memory, two identical errors appear:

⎿  PostToolUse:Write hook error
⎿  Failed to run: Messages are required for agent hooks. This is a bug.

The memory writes themselves succeed (the banner reports "wrote N memories" correctly, and the files do land on disk) — only the post-write telemetry step fails.

Reproduction

  1. Run Claude Code 2.1.109 on macOS with CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 set in the shell environment.
  2. Let the agent write to its auto-memory system (e.g., update a user-profile memory file via Edit).
  3. Observe the banner: Read 1 file, recalled 1 memory, wrote 2 memories (ctrl+o to expand) — followed by two PostToolUse:Write hook error / Messages are required for agent hooks. This is a bug. lines.

The error text "This is a bug." is presumably generated by the harness itself, which strongly suggests this is an internal invariant violation — the agent-hook runner is being invoked without the required messages field populated.

Environment

  • Claude Code: 2.1.109
  • OS: macOS (Darwin 25.4.0, Apple Silicon / M-series)
  • Shell: zsh
  • Relevant env var: CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1
  • User-configured hooks: only PreToolUse:Skill (a shell-command hook) and Stop (shell-command). No user-configured PostToolUse:Write hook. The failing hook appears to be an internal/experimental one tied to the auto-memory pipeline.

Expected

Either:

  • The post-memory-write hook runs silently (no error), or
  • If it genuinely cannot run, it fails silently rather than surfacing an internal "This is a bug." message to the user twice per memory write.

Workaround

Ignoring the banner works — memory writes still happen. Alternatively, unsetting CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS avoids the code path entirely (at the cost of whatever that experimental flag enables).

Additional context

Happy to provide more detail on request — e.g., exact error timing relative to tool output, or a full session transcript with memory file changes reproduced.

View original on GitHub ↗

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