[FEATURE] add agent_type field to PreToolUse hook

Resolved 💬 3 comments Opened Dec 27, 2025 by tyler-rt Closed Dec 30, 2025

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet
  • [x] This is a single feature request (not multiple features)

Problem Statement

I need to gate ToolUse differently depending on the subagent that is running (eg a python-coder subagent shouldn't be able to write to a test*.py file, but python-test subagent can write to it).

Proposed Solution

If the PreToolUse hook had the same agent_type field as SubagentStart then this would be easy to implement.

Alternative Solutions

right now i do a messy pattern of capturing which subagent is running via SubagentStart, and then reading this in my PreToolUse hook

  "hooks": {
    "SubagentStart": [
      {
        "matcher": "*",
        "hooks": [
          {
            "type": "command",
            "command": "sh -c 'cat; printf \"\\n\"' >> .claude/subagents.jsonl"
          }
        ]
      }
    ]
}

this is fragile.

Priority

Medium - Would be very helpful

Feature Category

Developer tools/SDK

Use Case Example

_No response_

Additional Context

_No response_

View original on GitHub ↗

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