[Bug] 子代理(subagent)工具调用不触发 PermissionRequest/PreToolUse hooks(双层失效)
Open
Nobody has claimed this yet.
priority: P2
- Dominant language
- No language data
- Stars
- 22
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
问题描述
Agent 工具派发的子代理(subagent)内部的工具调用(Bash/Read 等)不触发 PermissionRequest 层 hooks,也不触发 PreToolUse 层 hooks——两层治理(权限自动审批/命令形态闸)对子代理全部失效,权限请求直达用户弹窗。
复现步骤
- 注册一个 PermissionRequest 或 PreToolUse hook(如向日志追加一行记录载荷);
- 主会话调用任意 Bash 命令 → hook 正常触发;
- 通过 Agent 工具派发一个会执行 Bash 命令的子代理 → hook 零触发(同形态命令)。
实测证据
- PermissionRequest 层:主会话 104 次触发 vs 子代理 0 次(探针台账);
- PreToolUse 层:入口探针法,子代理执行 Bash 命令窗口(7.3 秒·1 次调用)探针零记录,主会话同命令即时记录;
- 另注意到两层载荷结构不一致:PreToolUse 载荷约 20 个字段(含 session_id/transcript_path/permission_mode/toolCallId),PermissionRequest 载荷仅 hookEventName/toolName/toolInput 三字段——后者无会话上下文可供 hook 判定。
期望行为
子代理工具调用纳入两层 hook 派发(或提供 subagent 专属事件),并统一两层载荷的会话上下文字段。
环境
ZCode 3.11.2 · Windows 10 26100 · GLM-5.3
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the reported comparison: run an equivalent Bash command in the main session and through an Agent-dispatched subagent, while recording PermissionRequest and PreToolUse hook events. Done means subagent tool calls reach both hook layers, or a documented subagent-specific event exists, with the needed session context available in the payload.
Written by the indexing model from the issue text.
Assessment
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100