claude-code - 💡(How to fix) Fix Include teammate_name in all hook events for native agent teams [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#45329Fetched 2026-04-09 08:07:53
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Author
Timeline (top)
labeled ×3commented ×1cross-referenced ×1

Root Cause

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.

Fix Action

Fix / Workaround

Current workaround

Code Example

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

---

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

---

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

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

extent analysis

TL;DR

To fix the issue, modify the native agent teams implementation to include teammate_name in the stdin JSON for all hook events fired from teammate sessions.

Guidance

  • Verify that the session_id in teammate hook events is unique per teammate and can be used to map to teammate_name if available.
  • Consider modifying the plugin-level hooks to store the teammate_name from the TeammateIdle event in the lead session and use it to attribute tool calls to specific teammates.
  • Investigate why agent frontmatter hooks do not propagate to native teammates and if this can be changed to provide an alternative solution.
  • Evaluate the current workaround that parses ateam agents-start --agent <name> from Bash tool_input and consider improving it to make it more robust and less application-specific.

Example

No code snippet is provided as the issue does not contain enough information to create a specific example.

Notes

The provided information suggests that the issue is specific to the native agent teams implementation and the plugin-level hooks. The solution may require modifications to the underlying implementation or the plugin code.

Recommendation

Apply a workaround, such as improving the current parsing of ateam agents-start --agent <name> from Bash tool_input, until a more robust solution can be implemented. This is because the issue is specific to the native agent teams implementation and may require significant changes to fix.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

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": "..." }
}

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING