Include agent_id in all hook event inputs

Resolved 💬 3 comments Opened Feb 26, 2026 by christopher-buss Closed Mar 2, 2026

Problem

Hook common input fields (session_id, transcript_path, cwd, permission_mode, hook_event_name) don't include an agent_id. The agent_id is only available in SubagentStart and SubagentStop events.

This makes it impossible to enforce per-agent policies in PreToolUse/PostToolUse hooks. Subagents share the parent's session_id, so there's no way to distinguish which agent triggered a hook.

Use case

I have a PreToolUse hook (tdd-guard) that blocks edits to certain files unless a skill was invoked first. I want this enforced per-agent — each subagent should independently invoke the skill. Currently, if the parent invokes it, all subagents pass the guard because they share the same session_id.

Proposal

Add agent_id to the common input fields for all hook events. For the parent/root agent, this could be null or a stable identifier. For subagents, it should match the agent_id from SubagentStart.

{
  "session_id": "abc123",
  "agent_id": "agent-def456",
  "transcript_path": "...",
  "cwd": "...",
  "permission_mode": "default",
  "hook_event_name": "PreToolUse",
  "tool_name": "Edit",
  "tool_input": { ... }
}

View original on GitHub ↗

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