Skip to content

Copilot harness: repository hooks never run in a trusted folder since workspace trust is forwarded to the runtime (#343403); they still run in untrusted folders #345931

Closed

Description

@andreoucostas

Does this issue occur when all extensions are disabled?: Not tested (the Copilot harness runs in the Agent Host, not the extension host).

  • VS Code Version: 1.144.1 (commit 261c84c), user setup, clean reinstall
  • OS Version: Windows 11 Pro 10.0.26300
  • Bundled Copilot runtime: copilotVersion 1.0.103-unstable.r40031404408 (from session.start in the session journal)
  • Harness: Copilot (Agent Host), default for new sessions

Summary

Repository hooks (.github/hooks/*.json, .claude/settings.json) do not run at all in Copilot-harness sessions whose working directory is trusted in VS Code. The same repository's hooks run normally when the folder is not trusted. This looks like the inverse of what #343403 intended ("In folders the user trusted in VS Code, the runtime now loads that repository's plugins, hooks, MCP servers and instructions").

User-level hooks in ~/.copilot/hooks/ still run in the trusted-folder sessions, so this is specific to repository hooks.

Steps to reproduce

  1. Create a git repository with .github/hooks/canary.json registering a command hook on sessionStart, userPromptSubmitted, preToolUse, postToolUse and agentStop that appends one line per event to a log file outside the repository.
  2. Open the folder in VS Code and trust it.
  3. In the Chat view (Copilot harness), ask the agent to create a file.
  4. Inspect the log file.
  5. Repeat with the same files reached through a path VS Code does not trust (for example a directory junction to the same folder) via a session created against that path.

Expected

Every event fires in the trusted folder (per #343403), as it did for untrusted folders.

Actual

  • Trusted folder: no repository hook runs. The Agent Host trace log shows Granting the runtime 'session' trust for trusted working directory …, and each hook phase completes in about 1 ms (Hook started: sessionStart → Hook ended … success=true) with no hook process launched. A repository preToolUse hook that should deny a write never runs, so the write succeeds.
  • Untrusted path to the same files, same VS Code instance, minutes later: no trust grant is logged, and all events fire, including the preToolUse deny.
  • Across 11 sessions (Chat view and sessions created over the Agent Host Protocol alike): untrusted 4 of 4 ran repository hooks, trusted 0 of 7.
  • The session's customizations still list the repository hook files as loaded.

Notes that may help

Happy to share trace logs (--log trace) and the session journals.

Activity

  1. vritant24 commented on Nov 20, 2026

    @vritant24
    Member

    Update: #349330 (merged) changes when the Copilot harness turns on repository hooks.

    • Repository hooks are now turned on only when the session's working folder is trusted in VS Code, and never for virtual workspaces. Before, they were turned on for every folder, which is why they ran in untrusted ones.
    • The hook files of an untrusted folder are listed in Chat Customizations with a Won't run badge.

    This covers the untrusted-folder half of this report. The other half, repository hooks not running in a trusted folder, has not been checked on Windows, where it was reported. The change was checked by hand on macOS only. Leaving this open for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions