Skip to content

Native ZCode Agent does not trigger hooks configured in ~/.zcode/cli/config.json #32

Description

@laozhouxingke

Problem

When using ZCode Agent (the native built-in agent), lifecycle hooks configured under hooks.events in ~/.zcode/cli/config.json are never triggered.

Config used

{
  "hooks": {
    "enabled": true,
    "timeoutMs": 60000,
    "maxOutputBytes": 32768,
    "events": {
      "UserPromptSubmit": [
        {
          "matcher": "",
          "hooks": [
            {
              "type": "command",
              "command": "node",
              "args": ["/path/to/hook.js"]
            }
          ]
        }
      ]
    }
  }
}

The hook script writes to a debug log on entry (before any stdin read), so if it were invoked at all, the log would appear. After multiple ZCode Agent sessions with prompts and tool use, the log file is never written.

What was also tried

  • Registering hooks via the plugin system (~/.zcode/cli/plugins/) — same result, hooks not triggered for ZCode Agent sessions
  • Hook command executes correctly when invoked manually via PowerShell

Expected behavior

Hooks in hooks.events should fire for ZCode Agent sessions (SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, Stop, etc.) the same way they work for external CLI subagents.

Question

Is this a known limitation? Is there a supported way to receive lifecycle events from ZCode Agent sessions externally (e.g., a local HTTP/WebSocket API, IPC, or log file)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions