Include teammate_name in all hook events for native agent teams

Resolved 💬 3 comments Opened Apr 8, 2026 by queso Closed Apr 12, 2026

Problem

When using native agent teams (CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1), plugin-level hooks (hooks.json) fire for all sessions including teammates. However, PreToolUse, PostToolUse, Stop, and other standard hook events do not include teammate_name (or any teammate identifier) in the stdin JSON when fired from a teammate's session.

The only hook event that carries teammate_name is TeammateIdle, and that fires in the lead session, not the teammate's session — so it can't be used to map teammate session IDs to names.

This makes it impossible for plugin hooks to attribute tool calls to specific teammates. All teammate activity gets lumped under the lead agent.

Current behavior

TeammateIdle stdin (lead session):

{
  "session_id": "lead-session-id",
  "hook_event_name": "TeammateIdle",
  "teammate_name": "implementer",
  "team_name": "my-team"
}

PreToolUse stdin (teammate session):

{
  "session_id": "teammate-session-id",
  "hook_event_name": "PreToolUse",
  "tool_name": "Bash",
  "tool_input": { "command": "..." }
}

No teammate_name, no agent_type, no way to identify which teammate this is.

Expected behavior

All hook events fired from a teammate session should include teammate_name in the stdin JSON:

{
  "session_id": "teammate-session-id",
  "hook_event_name": "PreToolUse",
  "teammate_name": "implementer",
  "team_name": "my-team",
  "tool_name": "Bash",
  "tool_input": { "command": "..." }
}

Use case

We're building the A(i)-Team, a Claude Code plugin for parallel agent orchestration that transforms PRDs into working code through a TDD pipeline with specialized agents (QA engineer, implementer, reviewer, investigator, etc.). We need per-agent telemetry — token usage, tool call counts, timing — to understand pipeline performance and costs. Without teammate identification in hook events, all telemetry collapses into the lead agent.

Tracking issue on our side: theaiteam-dev/the-ai-team-plugin#31

Current workaround

We parse ateam agents-start --agent <name> from Bash tool_input on the first tool call to self-register the session→agent mapping. This works because our agents always run a CLI command with --agent as their first action, but it's fragile and application-specific.

Additional context

  • Agent frontmatter hooks (defined in agents/*.md) do not appear to propagate to native teammates — only plugin-level hooks fire
  • The session_id in teammate hook events IS unique per teammate (not the lead's), so adding teammate_name alongside it would fully solve the problem
  • This also affects PostToolUse, Stop, PostToolUseFailure, and any other standard hook events

View original on GitHub ↗

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