-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Plugin-defined preToolUse hooks (hooks.json) do not fire - neither in main session nor subagents #2540
Copy link
Copy link
Open
Labels
area:agentsSub-agents, fleet, autopilot, plan mode, background agents, and custom agentsSub-agents, fleet, autopilot, plan mode, background agents, and custom agentsarea:pluginsPlugin system, marketplace, hooks, skills, extensions, and custom agentsPlugin system, marketplace, hooks, skills, extensions, and custom agentsarea:sessionsSession management, resume, history, session picker, and session stateSession management, resume, history, session picker, and session state
Description
Describe the bug
preToolUse hooks defined in a plugin's hooks.json file are never executed. The hooks don't fire in the main agent session or in subagents spawned via the task tool.
This is distinct from #2392, which reports that config.json-defined hooks work in the main session but not subagents. In our case, plugin-sourced hooks don't fire anywhere.
Affected version
1.0.18 (macOS)
Steps to reproduce the behavior
- Install a local plugin that defines a
preToolUsehook inhooks.json:{ "version": 1, "hooks": { "preToolUse": [ { "type": "command", "bash": "./scripts/guardrails.sh", "cwd": ".", "timeoutSec": 10 } ] } } - The plugin's
plugin.jsonreferences it with"hooks": "hooks.json" - The guardrails script outputs
{"permissionDecision": "deny", ...}for matching commands (verified by running the script manually with piped JSON input) - Start a session in a project that has this plugin installed
- Run a bash command that should be blocked (e.g., one containing
ghe-config-apply) - Result: Command executes without any hook intervention
- Manually running the same script with the same input correctly returns a deny decision
Expected behavior
Plugin-defined preToolUse hooks should be loaded and executed for all tool calls, the same way config.json-defined hooks are.
Additional context
- macOS, zsh, Copilot CLI 1.0.18
- Plugin installed via local path (
source.pathin config.jsoninstalled_plugins) - The plugin's skills load and work correctly - only hooks are not firing
- Tested with two separate local plugins, both define preToolUse hooks in hooks.json, neither fires
- Related: preToolUse hooks are not enforced in subagents #2392 (subagent hook enforcement), preToolUse hook returning 'allow' should short-circuit built-in tool dialogs like exit_plan_mode #2349 (hook allow short-circuit), sessionStart hook in .github/hooks/ does not fire in Copilot CLI (v0.0.420) #1730 (sessionStart hooks)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area:agentsSub-agents, fleet, autopilot, plan mode, background agents, and custom agentsSub-agents, fleet, autopilot, plan mode, background agents, and custom agentsarea:pluginsPlugin system, marketplace, hooks, skills, extensions, and custom agentsPlugin system, marketplace, hooks, skills, extensions, and custom agentsarea:sessionsSession management, resume, history, session picker, and session stateSession management, resume, history, session picker, and session state
Type
Fields
Give feedbackNo fields configured for issues without a type.