github / github/copilot-cli

Plugin-defined preToolUse hooks (hooks.json) do not fire - neither in main session nor subagents

Ouverte
#2,540 7 commentaires 4 réactions 0 personnes assignées Voir sur GitHub
area:agents area:plugins area:sessions
Langage dominant
Shell
Étoiles
11.2k
Forks
1.9k
Merge moyen
14 h 16 min
PR mergées (30 j)
6

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

1. Install a local plugin that defines a `preToolUse` hook in `hooks.json`:
```json
{
"version": 1,
"hooks": {
"preToolUse": [
{
"type": "command",
"bash": "./scripts/guardrails.sh",
"cwd": ".",
"timeoutSec": 10
}
]
}
}
```
2. The plugin's `plugin.json` references it with `"hooks": "hooks.json"`
3. The guardrails script outputs `{"permissionDecision": "deny", ...}` for matching commands (verified by running the script manually with piped JSON input)
4. Start a session in a project that has this plugin installed
5. Run a bash command that should be blocked (e.g., one containing `ghe-config-apply`)
6. **Result:** Command executes without any hook intervention
7. 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.path` in config.json `installed_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: #2392 (subagent hook enforcement), #2349 (hook allow short-circuit), #1730 (sessionStart hooks)

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez par suivre comment plugin.json référence hooks.json et comment les hooks preToolUse définis par les plugins sont chargés avant les appels d’outils. Reproduisez le problème avec le plugin local et guardrails.sh, puis comparez ce chemin avec les hooks définis dans config.json et avec une commande exécutée à la fois dans la session principale et dans un sous-agent de tâche. Le travail est terminé lorsque le hook du plugin s’exécute et que sa décision de deny bloque les commandes correspondantes dans les deux contextes.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
shell
Domaine
cli
Type d'issue
Bug
Difficulté
3/5
Temps estimé
1-2 jours
Activité
Calme
Clarté
Plutôt claire
Accessibilité débutants
48/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.