Skip to content

Trusted project hooks never fire for subagent or workflow-agent tool calls (3.14.3) #841

Closed as not planned

Description

@tigran-fig

Environment

  • ZCode 3.14.3 (build 3.14.3.7762), macOS arm64; bundled CLI reports zcode 0.16.9.
  • Project hooks enabled in .zcode/config.json (hooks.enabled: true), trust granted via hooks trust grant --workspace … --all-current --bundle-digest … (status shows workspace_hooks_trusted_persistent).

What happens

Trusted project hooks fire for the main session's own tool calls only. They never fire for tool calls made by:

  1. Agent-tool subagents — a dispatched general-purpose subagent running Bash produces zero hook entries (no second session_id, no agent_type anywhere in the log).
  2. Dynamic-workflow agents (CreateWorkflow runs) — a one-agent workflow whose actor runs git config --get user.name via Bash was allowed through, while the identical command in the main session is refused by the same trusted PreToolUse guard. The actor's session produced zero hook entries.

A probe logger on every event recorded 164/164 entries from the main session id across a session that included both subagent dispatches and two workflow runs. The CreateWorkflow submission itself is hooked (tool_name: "CreateWorkflow"), so the main-session tool surface is covered — only the child runtimes are not.

Additionally, SessionStart and UserPromptSubmit hooks configured identically in the same trusted project config never fired in a fresh session (0 entries each), while PreToolUse, PostToolUse and Stop all fired normally. Session was yolo mode.

Reproduction

  1. Put a process hook on PreToolUse (all tools) in <workspace>/.zcode/config.json that appends its stdin payload to a log file; hooks.enabled: true.
  2. Grant trust; open a fresh session in that workspace.
  3. Run any Bash command → log entry appears with the main session_id.
  4. Dispatch a subagent that runs one Bash command → no entry.
  5. Run a one-agent CreateWorkflow script whose agent runs one Bash command → no entry from the agent's session.

Expectation

Child runtimes (subagent_child, workflow_child) should run their tool calls through the same trusted configured hook runner as the main session. The source appears to intend this: apps/zcode-cli/packages/core/src/runtime/helpers/runtime-tools.ts (initializeRuntimeTooling / createRuntimeHookRunner) builds a ConfiguredHookRunner for every AgentRuntime when config.hooks?.enabled || deps.workspaceHookSnapshot, gated by workspaceHookAdmission — so this reads like incomplete plumbing (for example, workspaceHookSnapshot/executionPort not being passed to child runtimes) rather than a design decision.

Impact

Hooks cannot enforce any safety policy on dispatched work, which blocks porting hook-guarded workflows (start-up canaries, git-mutation guards) to dynamic workflows and subagents.

Activity

  1. github-actions commented on Sep 27, 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. neudysrd commented on Oct 4, 2026

    @neudysrd

    Hitting the same thing on 3.14.4 (Linux x64). I spent some time in the shipped CLI bundle (resources/glm/zcode.cjs, build of 2026-09-28) to see where it breaks, and found a few things that might help whoever picks this up. To be clear, this comes from reading the code; I haven't run a patched build.

    For subagents it's not only project hooks. The subagent_child runtime gets a hand-built config with no hooks key, and its deps include neither hookRunner nor workspaceHookSnapshot. So user hooks in ~/.zcode/cli/config.json and plugin hooks don't fire for subagent tool calls either. That matches what I see in practice: our plugin's PreToolUse guard catches things in the main session and never anything a subagent does.

    Workflow actors look like a separate case. Both kinds spread the parent's runtime config (let{systemPrompt:t,...n}=e.deps.runtimeConfig): the /expert and saved-workflow children (createWorkflowChildRuntime), and the CreateWorkflow actors. So user and plugin hooks should reach them. Only the trusted workspace snapshot is missing, which lines up with your report. Actor session ids are built from dwf-<runId>-<actorRef>. The fix is probably different for each kind.

    Even once hooks fire, PreToolUse won't say which agent is calling. The subagent sets agentName: `zcode-${t.agentType}`, and agent_type is mapped from it for SessionStart and Stop, but the PreToolUse payload never gets it. Anything per-agent, like "only the committer agent may git commit", needs agent_type there, plus the parent session id asked for in #236.

    Removing tools doesn't work as a stopgap. I looked at disallowedTools: [Read], so subagents would have to go through a bounded reader instead. The tool does disappear, even in yolo mode. But then Edit and Write refuse any existing file with File has not been read yet. Read it first before writing to it., and a cat through Bash doesn't count as a read. So an agent without Read can't edit at all.

    For a sense of impact: in our measurements, around 89% of the whole-file-read volume our output-size guard would block comes from subagents. Today the guard sees about a tenth of it.

    Happy to test a build if that helps.

  3. 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.

  4. 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