Repository navigation
agentHost: list custom agent hooks and skip them in untrusted folders - #349332
Merged
Vritant Bhardwaj (vritant24) merged 2 commits intoNov 20, 2026
Merged
Conversation
Vritant Bhardwaj (vritant24)
force-pushed
the
dev/vritant24/hooks-custom-agents
branch
2 times, most recently
from
November 19, 2026 22:20
de2fd07 to
9854ccf
Compare
Vritant Bhardwaj (vritant24)
force-pushed
the
dev/vritant24/hooks-custom-agents
branch
from
November 19, 2026 22:46
9854ccf to
0e633de
Compare
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Untrusted agent hooks can bypass trust checks, and deleting an agent-hook row can remove the entire agent file.
5 open issues
Preserve source-folder trust when bundling and forwarding agents · New Check hook trust per agent root and refresh on trust changes · New Prevent agent-hook deletion from removing the entire agent file · New Mark blocked hooks from every working directory · New Show only hooks supported and received by the runtime · New
What changed in this PR
Adds workspace-trust enforcement and Chat Customizations visibility for hooks declared in Copilot custom agent files.
Changes:
- Filters agent hooks during session launch while keeping the agent available.
- Lists agent-declared hooks and marks hooks blocked by folder trust.
- Adds tests for launch filtering, blocked-hook discovery, and hook listing.
| File | Description |
|---|---|
src/vs/workbench/contrib/chat/test/browser/agentSessions/agentCustomizationItemProvider.test.ts |
Tests agent-hook listing through a remote URI mapper. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentCustomizationItemProvider.ts |
Creates hook rows from agent frontmatter and suppresses active rows for blocked agents. |
src/vs/platform/agentHost/test/node/sessionCustomizationDiscovery.test.ts |
Tests discovery of untrusted agent files containing hooks. |
src/vs/platform/agentHost/test/node/copilotSessionLauncher.test.ts |
Tests trust-based filtering of workspace-agent hooks. |
src/vs/platform/agentHost/node/copilot/sessionCustomizationDiscovery.ts |
Publishes blocked-hook entries for untrusted agent files. |
src/vs/platform/agentHost/node/copilot/copilotSessionLauncher.ts |
Applies hook filtering when preparing runtime agent definitions. |
src/vs/platform/agentHost/node/copilot/copilotPluginConverters.ts |
Adds hook detection and optional hook inclusion during conversion. |
Review effort: Max
Vritant Bhardwaj (vritant24)
marked this pull request as ready for review
November 19, 2026 23:38
The Copilot runtime runs the `hooks:` of a custom agent file while that agent is selected. Chat Customizations did not list these hooks, and VS Code passed them to the runtime for agent files in untrusted folders. Chat Customizations now lists each agent's hooks as running while that agent is active, and hooks of agent files in an untrusted workspace folder are not passed to the runtime and are shown as "Won't run until you trust this folder". Co-authored-by: Copilot <[email protected]>
…trusted The folder an agent came from is not always known: agents copied from other locations, or taken from another chat, live outside the session's folders, so checking the agent's own path let their hooks run in an untrusted folder. Custom agent hooks are now sent only when every session folder is trusted, and a session restarts when the trust of any of its folders changes. Chat Customizations lists agents that declare hooks as not running whenever a session folder is untrusted, and badges every agent hook row in that case. It lists agent hooks only for the Copilot runtime, since other runtimes ignore them, and deleting an agent hook row explains that it is edited in the agent file instead of deleting the file. Co-authored-by: Copilot <[email protected]>
Vritant Bhardwaj (vritant24)
force-pushed
the
dev/vritant24/hooks-custom-agents
branch
from
November 20, 2026 00:07
e58727c to
a9e0f8c
Compare
Dmitriy Vasyura (dmitrivMS)
approved these changes
Nov 20, 2026
Vritant Bhardwaj (vritant24)
deleted the
dev/vritant24/hooks-custom-agents
branch
November 20, 2026 00:31
11 tasks
Closed
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


What this changes
A custom agent file can declare
hooks:, and the Copilot runtime runs them while that agent is selected. Chat Customizations did not list these hooks, and VS Code passed them to the runtime even when the session's folder was untrusted.How to test
.github/agents/reviewer.agent.mdwith ahooks:section that declares asessionStarthook appending a line to a file.Validation
./scripts/test.sh --reporter dot --run src/vs/platform/agentHost/test/node/copilotSessionLauncher.test.ts --run src/vs/platform/agentHost/test/node/sessionCustomizationDiscovery.test.ts --run src/vs/platform/agentHost/test/node/copilotAgent.test.ts --run src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts --run src/vs/workbench/contrib/chat/test/browser/agentSessions/agentCustomizationItemProvider.test.ts --run src/vs/workbench/contrib/chat/test/browser/aiCustomization/customizationMigration.test.ts: passed (3,275 passing)./scripts/test.sh --reporter dot --timeout 180000 --run src/vs/platform/agentHost/test/node/providerIntegration/copilotCustomizations.integrationTest.ts --run src/vs/platform/agentHost/test/node/copilotSdkCustomizationDiscovery.integrationTest.ts: passed (13 passing)./scripts/test-agent-host-e2e.sh --grep "customization discovery|custom agent|hook": passed (20 passing)pnpm run typecheck-clientand oxlint: passedKnown gaps