microsoft / microsoft/vscode

Agent Host doesn't discover hooks from installed plugins (discoverHooks() lacks a plugin search root)

Open
#330,114 0 comments 0 reactions 1 assignee Claimed by @connor4312 View on GitHub
Dominant language
TypeScript
Stars
193k
Forks
42.4k
PR merge metrics
PR metrics pending

Description

- Copilot Chat Extension Version: 0.60.0
- VS Code Version: 1.132.0
- OS Version: macOS 26.5.2 (build 25F84)
- Feature (e.g. agent/edit/ask mode): Agent Host session (background/autonomous agent mode) — the "Agent Customizations for Copilot [Agent Host]" panel
- Selected model (e.g. GPT 4.1, Claude 3.7 Sonnet): N/A — this is an infrastructure-level customization discovery bug, not model-dependent
- Logs: see "Root Cause" section below; sourced from a `Developer: Export Agent Host Debug Logs...` bundle (`Agent Host.log`) and the synced plugin cache under `~/Library/Application Support/Code/agentPlugins/`

## Description

The Agent Host's hook discovery doesn't look inside installed plugin directories, so hooks shipped by an installed Copilot/Claude-format plugin (`hooks.json` at the plugin root, or `hooks/hooks.json`) never surface in an Agent Host session — even though the same plugin's skills, agents, and MCP servers are discovered correctly.

Copilot CLI, using the identical installed plugin files, loads the plugin's hooks correctly. Only the VS Code Agent Host is affected.

## Steps to Reproduce

1. Install a Copilot/Claude-format plugin under `~/.copilot/installed-plugins///` that ships a root `hooks.json` (or `hooks/hooks.json`) alongside `skills/` and `agents/` directories.
2. Enable the plugin in VS Code Copilot and open an Agent Host session.
3. Open the Agent Customizations for Copilot panel → Hooks page.
4. Compare against a Copilot CLI session using the same installed plugin.

**Expected:** the plugin's hooks appear in the Agent Host's Hooks list, matching what Copilot CLI shows.

**Actual:** the Agent Host's Hooks list only shows user-level hooks (`~/.copilot/hooks/*.json`); hooks shipped by installed plugins are absent. The same session correctly reports the plugin's skills and agents.

Does this issue occur when all extensions are disabled?: N/A — the discovery scanner in question is native VS Code platform code (`src/vs/platform/agentHost/node/copilot/sessionCustomizationDiscovery.ts`), not an extension.

## Root Cause

In [`src/vs/platform/agentHost/node/copilot/sessionCustomizationDiscovery.ts`](https://github.com/microsoft/vscode/blob/main/src/vs/platform/agentHost/node/copilot/sessionCustomizationDiscovery.ts), each customization type is discovered very differently:

- `discoverAgents()` and `discoverSkills()` delegate to the Copilot SDK's own RPCs (`client.rpc.agents.discover(...)`, `client.rpc.skills.discover(...)`) — the same plugin-aware discovery Copilot CLI uses internally. This is why plugin skills/agents show up correctly.
- `discoverHooks()` does **not** call into the SDK. It's a separate, hand-rolled scanner (`_scanForHooks` / `_discoverHookRoot` / `_discoverFixedHookFiles`) that only walks a hardcoded `searchRoots` list:

```ts
workspace: [{ path: ['.github', 'hooks'], recursive: true, type: DiscoveredType.Hook }]
user: [{ path: ['.copilot', 'hooks'], recursive: true, type: DiscoveredType.Hook }]
fixedDiscoveryFiles:
workspace: .github/copilot/settings.json, .github/copilot/settings.local.json,
.claude/settings.json, .claude/settings.local.json
user: (none for hooks)
```

There is no entry anywhere for an installed plugin's `hooks.json` / `hooks/hooks.json` (e.g. `~/.copilot/installed-plugins///`). This makes it structurally impossible for `discoverHooks()` to find plugin-shipped hooks — it was never extended to look inside plugin install directories, unlike the agent/skill discovery paths.

I verified this independently at the filesystem level by pulling a `Developer: Export Agent Host Debug Logs...` bundle and inspecting the synced plugin cache under `~/Library/Application Support/Code/agentPlugins///`: `hooks.json` is present there and correctly formed (the `AgentPluginManager` sync/symlink-dereference is fine). `Agent Host.log` shows explicit `AgentPluginManager` sync activity and `MCP server 'x' loaded/inventory` log lines for the same plugin, but zero hook-loading activity anywhere for it — consistent with `discoverHooks()` simply never scanning that directory.

## Suggested Fix

In `sessionCustomizationDiscovery.ts`, either:
- Add search roots covering installed-plugin hook files (mirroring wherever the plugin manager materializes synced plugins) to `discoverHooks()`'s scanner, or
- Route hook discovery through the Copilot SDK's own discovery RPC (if/when one exists for hooks), the same way `discoverAgents()`/`discoverSkills()` already do.

## Environment

- VS Code Copilot Chat, Agent Host session type (Copilot CLI unaffected)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.