PostToolUse:Write hook error: 'Messages are required for agent hooks. This is a bug.' with CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1
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
- Run Claude Code 2.1.109 on macOS with
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1set in the shell environment. - Let the agent write to its auto-memory system (e.g., update a user-profile memory file via
Edit). - Observe the banner:
Read 1 file, recalled 1 memory, wrote 2 memories (ctrl+o to expand)— followed by twoPostToolUse: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) andStop(shell-command). No user-configuredPostToolUse:Writehook. 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.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗