Hooks: distinguish subagent events from main agent events
Problem
When using hooks on Stop, Notification, and PermissionRequest events, there is no way to distinguish whether the event was triggered by the main agent or a subagent (spawned via the Agent tool).
This is particularly annoying for the Stop event: if you have a notification sound configured to alert you when Claude is done, it fires for every subagent completion — not just when the main agent finishes and actually needs your attention.
Current behavior
All hook events fire identically for both the main agent and subagents. There is no matcher value, environment variable, or metadata in the hook input JSON to filter on.
Suggested solution
One or more of:
- Separate event types — e.g.,
SubagentStop,SubagentNotification,SubagentPermissionRequestso users can configure them independently - Metadata in hook input — include a field like
"is_subagent": trueor"agent_type": "subagent"in the JSON passed to hook commands, so hooks can filter programmatically - Matcher support — allow matchers like
subagent/mainto filter within the existing event types
Use case
I have a Stop hook that plays a notification sound and shows a macOS notification so I know when Claude needs my attention. With subagents, the sound plays dozens of times during a single task — once for each subagent that completes — making it effectively useless as a signal.
The PermissionRequest and Notification hooks are less affected since those subagent events do require user action, but the ability to distinguish would still be useful (e.g., different sounds for subagent vs main agent).
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗