Hooks: distinguish subagent events from main agent events

Resolved 💬 2 comments Opened Mar 12, 2026 by leeuweriq Closed Mar 12, 2026

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:

  1. Separate event types — e.g., SubagentStop, SubagentNotification, SubagentPermissionRequest so users can configure them independently
  2. Metadata in hook input — include a field like "is_subagent": true or "agent_type": "subagent" in the JSON passed to hook commands, so hooks can filter programmatically
  3. Matcher support — allow matchers like subagent / main to 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).

View original on GitHub ↗

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