Skip to content

[Bug] 子代理(subagent)工具调用不触发 PermissionRequest/PreToolUse hooks(双层失效) #603

Closed as not planned

Description

@Fanshb

问题描述

Agent 工具派发的子代理(subagent)内部的工具调用(Bash/Read 等)不触发 PermissionRequest 层 hooks,也不触发 PreToolUse 层 hooks——两层治理(权限自动审批/命令形态闸)对子代理全部失效,权限请求直达用户弹窗。

复现步骤

  1. 注册一个 PermissionRequest 或 PreToolUse hook(如向日志追加一行记录载荷);
  2. 主会话调用任意 Bash 命令 → hook 正常触发;
  3. 通过 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

Activity

  1. github-actions commented on Sep 11, 2026

    @github-actions

    👋 感谢你的反馈,我们已经收到。

    • 维护者看到后会尽快回复你。
    • 状态保持为 status: 待评估,你可以随时补充信息。
    • 信息不全时我们会打上 needs: 更多信息 标签并 @ 你。

    👋 Thanks — we've received your issue.

    • A maintainer will get back to you as soon as we can.
    • Status stays at status: 待评估 (Triage); feel free to add context.
    • If we need more details, we'll add needs: 更多信息 and ping you.
  2. panda920 commented on Oct 11, 2026

    @panda920
    Collaborator

    感谢反馈!这条与 #361 说的是同一件事,我们合并到 #361 统一跟进,后续进展会在那边同步。

    本 issue 先关闭,欢迎到 #361 补充信息或点 👍。


    Thanks for the report! This is the same as #361, so we're tracking it there and will post updates in that thread.

    Closing this one as a duplicate — feel free to add details or a 👍 on #361.

  3. added
    duplicate
    on Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicatepriority: P2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions