PreToolUse hooks do not fire for sub-agent (Agent tool) Bash calls

Resolved 💬 3 comments Opened May 20, 2026 by lbzepoqo Closed May 24, 2026

Feature Type

New feature request

Description

PreToolUse hooks configured in ~/.claude/settings.json fire correctly for the main conversation's Bash tool calls, but do not fire for Bash calls made by sub-agents spawned via the Agent tool.

This means any preprocessing or output filtering applied by hooks (e.g., token optimization proxies, security wrappers, logging) is silently bypassed when work is delegated to sub-agents — which is the recommended pattern for complex tasks.

Reproduction

  1. Configure a PreToolUse hook on Bash in ~/.claude/settings.json:
{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "echo 'hook fired' >> /tmp/hook-log.txt"
          }
        ]
      }
    ]
  }
}
  1. Run a Bash command directly in the main conversation → hook fires, line appears in /tmp/hook-log.txt
  1. Spawn a sub-agent via the Agent tool that runs Bash commands (e.g., find, grep, ls) → hook does not fire, no new lines in log

Use Case

I use RTK (Rust Token Killer), a token-optimized CLI proxy that filters verbose command output to reduce token consumption by 40-90%. It's configured as a PreToolUse hook that rewrites Bash commands through the proxy.

When the main agent delegates exploration or implementation to sub-agents (the recommended pattern per CLAUDE.md), all sub-agent Bash calls bypass RTK entirely. In a typical research session, sub-agents run 50-100+ find/grep/ls commands — all unfiltered, consuming full tokens.

This applies to any PreToolUse hook, not just RTK: security wrappers, audit loggers, command rewriters, etc.

Expected Behavior

PreToolUse (and PostToolUse) hooks should fire for sub-agent tool calls, same as for the main conversation. Either:

  1. Default propagation — hooks fire for all tool calls regardless of agent depth (preferred, least surprising)
  2. Opt-in propagation — a propagateToSubagents: true flag on hook definitions
  3. SubagentStart hook support — allow SubagentStart hooks to register PreToolUse hooks for the sub-agent's lifetime

Current Workaround

No clean workaround exists. Options considered:

  • Manually prefixing rtk in every agent prompt — fragile, adds prompt overhead, agents forget
  • Avoiding sub-agents for Bash-heavy work — defeats the purpose of delegation
  • Using MCP tools instead of Bash — not always possible, doesn't help non-MCP hooks

Related Issues

  • #46696 — Sub-agents not inheriting environment variables (same root cause: sub-agent isolation)
  • #5812 — Hooks bridging context between sub-agents and parent (closed, different scope)
  • #29068 — Including agent_id in hook event inputs (closed, related)

Environment

  • Linux (WSL2), Claude Code with Agent tool
  • PreToolUse hook configured in ~/.claude/settings.json
  • Sub-agents spawned via Agent tool (Explore, Plan, general-purpose types)

View original on GitHub ↗

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