Feature request: PostToolUse hook support for SendMessage (inter-agent communication logging)
Problem
When using agent teams, there's no way to observe or log inter-agent communication. SendMessage is not in the list of tools that fire PostToolUse hooks.
Currently hookable tools: Bash, Edit, Write, Read, Glob, Grep, Agent, WebFetch, WebSearch, AskUserQuestion, ExitPlanMode, MCP tools.
SendMessage is missing from this list.
Use Case
We run a team of 7 specialized agents (analysts, engineers, PM, architect) that communicate via SendMessage. We want to:
- Audit trail: Log all inter-agent messages to a shared file (like a team Slack channel)
- Observability: See what agents are telling each other without reading each agent's full output
- Debugging: When an agent acts on bad advice from another agent, trace the communication chain
- Cross-team synthesis: A "solutions engineer" agent reviews the chat log to find patterns
Current Workaround
We instruct every agent to manually append messages to a team/chat.md file before calling SendMessage. This works but is fragile — agents sometimes forget, and the format isn't guaranteed.
Proposed Solution
Add SendMessage to the list of tools that fire PreToolUse and PostToolUse hooks. The hook input should include:
{
"tool_name": "SendMessage",
"tool_input": {
"to": "agent-name-or-id",
"message": "the message content"
}
}
This would allow a simple hook like:
{
"event": "PostToolUse",
"if": { "tool_name": "SendMessage" },
"handler": {
"type": "command",
"command": "bash -c 'cat /dev/stdin | jq -r \"\\\"**\\(.tool_input.from // \\\"Agent\\\")**: @\\(.tool_input.to) \\(.tool_input.message)\\\"\" >> team/chat.md'"
}
}
Environment
- Claude Code CLI
- Using agent teams with 7 custom agents defined in
.claude/agents/ - Agents actively communicate via
SendMessageduring analysis and implementation workflows
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗