PreToolUse hook input missing agent_id for tmux/pane-based teammates
Summary
For PreToolUse hooks fired by teammate (Agent-tool) tool calls, the hook input includes agent_id when the teammate runs in in-process mode, but omits agent_id when the teammate runs in tmux/pane-based mode. Same teammate, same Agent invocation, same hook script — different payload depending on teammateMode.
This breaks hook scripts that branch on agent_id to distinguish main-agent vs subagent calls.
Repro
Hook script (force_background_bash.py, registered for PreToolUse on Bash):
import json, sys
data = json.load(sys.stdin)
is_main = not data.get("agent_id") # documented contract: agent_id set only for subagent calls
# ... applies different rules based on is_main
Spawn the same teammate via Agent (with team_name/name) and have them run a Bash call.
| Mode | agent_id in hook input | Hook treats teammate as |
|---|---|---|
| In-process (no tmux) | present | subagent |
| Pane-based (tmux) | absent | main agent |
Concrete observed effect with the hook above:
- In-process teammate: Bash with
timeout: 35000runs synchronously (subagent rules — no auto-promote); explicitrun_in_background: trueis blocked. - Pane-based teammate (tmux): same Bash call gets auto-promoted to background (main-agent rules); explicit
run_in_background: trueis allowed.
Expected
agent_id semantics in PreToolUse hook input should be consistent across teammate spawn modes — a teammate is a teammate regardless of whether the harness chose in-process or pane-based execution.
Related
- #29068 (closed) — added
agent_idto common hook input - #24175 (closed/stale) — lifecycle hook firing inconsistency between in-process and pane-based teammates. This issue is narrower: PreToolUse does fire in both modes here, but with different payloads.
Environment
- Claude Code 2.1.119
- Linux
- Reproduces with a vanilla
Agentcall usingteam_name/nameand aPreToolUsehook readingagent_idfrom stdin.
🤖 Generated with Claude Code
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗