[harness] PostToolUse hooks run synchronously for subagents with no agent or worktree context; a per-edit test hook starved a builder for two hours
Context. Solo-operator project using Claude Code (desktop app, Windows 11) with a lead session on Claude Fable 5.1 orchestrating Opus 5.5 / Sonnet subagents (in-process, worktree-isolated), ~40 project hooks in settings.json. Measured 2026-09-28; numbers are from tool output. No secrets or private paths.
Finding. PostToolUse hooks configured for the session run for every subagent's tool call too, synchronously, and the hook payload carries no field naming the agent, its type or its worktree. A per-edit test hook (a pytest subset after every Edit/Write under one package path) ran after each of a builder subagent's edits inside its isolated worktree, about six minutes per edit, so the subagent spent most of two hours inside hooks. The hook could only scope itself by parsing the file path for the worktree directory.
Evidence (measured). The subagent's own progress report named the ~6 min per edit; the hook's path filter matched every file under the package; the fix was a worktree-path check in the hook script (self-tested with an envelope file). After the fix the subagent's transcript showed the skip line 16 times in the first minute and grew 84 KB in that minute, against 12.8 KB per minute over the prior two hours. A census of the session's 40 hooks found one test-running hook and one lint hook.
Minimal reproduction. Configure a PostToolUse hook on Edit that sleeps 60 s; dispatch a worktree-isolated subagent that makes 20 edits; time it, then try to skip the hook for that subagent only.
Ask. (1) Include agent id, agent type and worktree path in every hook payload. (2) A per-agent-type or per-dispatch hook policy (run / skip / async) in the agent definition or the Agent call. (3) An async mode for advisory PostToolUse hooks so a long check never blocks the model's next tool call.