Skip to content

Forward VS Code workspace trust to the Copilot runtime - #343403

Merged
Vritant Bhardwaj (vritant24) merged 2 commits into
mainfrom
agents/forward-workspace-trust-to-copilot-runtime
Oct 22, 2026
Merged

Vritant Bhardwaj (vritant24) merged 2 commits into
mainfrom
agents/forward-workspace-trust-to-copilot-runtime

Conversation

@vritant24

@vritant24 Vritant Bhardwaj (vritant24) commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Refs #341618 (TPI), #342508

Problem

A repository's .github/copilot/settings.json can enable plugins, and the Copilot runtime also loads repository hooks, MCP servers and instructions. It does this only for folders it considers trusted. The agent host never passed VS Code's Workspace Trust to the runtime, so trusting a folder in VS Code had no effect there. As a result, TPI #341618 fails: after trusting the folder, context-engineering never auto-installs.

Changes

When the agent host creates a Copilot SDK session whose working directory is trusted, it now passes trustWorkingDirectory: 'session'.

  • Trusted means the folder is equal to or under a trusted URI in the workspaceTrust root config (ignoring path case where the file system does), or any folder when Workspace Trust is disabled. The check is now one shared helper, isAgentHostWorkspaceTrusted, used by the Copilot launcher, the Codex agent and the prewarmer.
  • Create only. The SDK rejects the grant on resume. A resume that falls back to a create gets it.
  • No grant for untrusted folders, workspace-less (scratch) sessions or non-file working directories.
  • Never 'user'. It writes to the runtime's own config.json, where VS Code can't revoke it.
  • Worktrees: a worktree that the agent host creates on the first send inherits its repository's trust. The client only trusts the worktree after the session reports it, which is after the SDK session is created, so the launcher applies the inheritance itself.
  • Prewarmed sessions record the grant they were created with. If trust changes before the first send, the session is discarded (workspaceTrustChanged) and the send starts cold.

Behavior after merge

In folders the user trusted in VS Code, the runtime now loads that repository's plugins, hooks, MCP servers and instructions for the session. It also auto-installs plugins the repository enables, saved as globally disabled. Untrusted folders behave as before, and nothing is added to the runtime's persisted trusted-folder list.

Runtime notes

  • Auto-install needs github/copilot-agent-runtime#27676, which makes the installer honor the session grant. The pinned SDK 1.0.25 behaves the same as runtime main in the end-to-end run below. With the pre-fix 1.0.24 runtime, nothing breaks, but only already-installed repository plugins are enabled; no new ones install.
  • 'user' trust is avoided. Besides persisting, a session created with it got no background plugins, because the installer planned before the grant was applied.
  • No trust on resume. Reopened sessions (for example after a reload) can't receive the grant, and trust changes don't reach a session that's already running. The runtime needs an API to set or update session trust; this is still an open question on the runtime side.

How to test

Follow TPI #341618: open a repository whose .github/copilot/settings.json enables context-engineering@awesome-copilot, trust it, start a Copilot session in the Agents window, and check that the plugin and its three skills appear within 60 seconds.

Validation

  • npm run test-node -- --run src/vs/platform/agentHost/test/node/copilotSessionLauncher.test.ts --run src/vs/platform/agentHost/test/common/agentHostWorkspaceTrust.test.ts --run src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts --run src/vs/platform/agentHost/test/node/codex/codexCreateChat.test.ts --run src/vs/platform/agentHost/test/node/codex/codexPrewarmEviction.test.ts: passed (1787).

  • npm run test-node -- --run src/vs/platform/agentHost/test/node/copilotAgent.test.ts: passed (876), including the 3 new trust tests.

  • npm run eslint -- <changed files>: passed.

  • npm run typecheck-client: one error, in src/vs/workbench/test/browser/componentFixtures/chat/tabbedModelPicker.fixture.ts (autoModelFusion). This PR doesn't touch that file.

  • End to end (local scratch integration test, not committed): the real CopilotAgent and launcher against a real runtime with an offline file:// marketplace. In a trusted folder and in a first-send worktree, the plugin installs (globally disabled), its skill reaches the next turn's prompt, and trust is not persisted. In an untrusted folder, nothing installs.

    Runtime Grant Installed
    main with Suggest widget should reflow when window size changes #27676 sent yes
    Pinned SDK 1.0.25 sent yes
    main removed no
    Pre-fix 1.0.24 sent no
  • TPI Test: Repository settings auto-install a plugin only after folder trust #341618 steps 1 and 5–7 (step 4's reply came from a stubbed model) were run through the agent host with the pinned runtime, the TPI's exact settings.json and the real github/awesome-copilot marketplace. Untrusted: nothing installs after 15s. Trusted: one context-engineering row appears in about 11s and context-map, refactor-plan and what-context-needed load. An empty folder doesn't load them. With the grant removed, nothing installs within 60s. The Customizations UI and the trust and reload dialogs were not tested here.

A repository's .github/copilot/settings.json can enable plugins, hooks, MCP
servers and instructions that the Copilot runtime honours only for trusted
folders. The agent host never told the runtime about VS Code's Workspace
Trust, so trusting a folder in VS Code had no effect there.

When the agent host creates a Copilot SDK session whose working directory
is trusted under the forwarded `workspaceTrust` root config, it now passes
`trustWorkingDirectory: 'session'`:

- Trusted means equal to or under a trusted URI (ignoring path case where
  the file system does), or every folder when Workspace Trust is disabled.
  The check is shared with the Codex agent and the prewarmer through
  isAgentHostWorkspaceTrusted.
- Create only: the SDK rejects the grant on resume. A resume that falls
  back to a create gets it.
- No grant for workspace-less (scratch) sessions, non-file working
  directories, or untrusted folders.
- Never 'user': it persists into the runtime's own config, where VS Code
  can't revoke it.
- A worktree that Agent Host creates on the first send inherits its
  repository's trust. The client only trusts the worktree after the
  session reports it, which happens after the SDK session is created.
- A pre-warmed session records the grant it was created with. If trust
  changes before the first send, it is discarded (workspaceTrustChanged)
  and the send starts cold.

Runtime notes:

- The runtime's background installer ignored the session grant, so this
  change alone turned on already-installed repository plugins but didn't
  auto-install them. github/copilot-agent-runtime#27676 fixed that.
  Verified end to end with the real CopilotAgent and launcher, an offline
  file:// marketplace and a repository that enables one plugin. Trusted
  folder and first-send worktree: the plugin installs (globally disabled),
  its skill reaches the next turn's prompt, and trust is not persisted.
  Untrusted folder: nothing installs.
  - Runtime built from main: passes.
  - Bundled SDK 1.0.25: passes.
  - Pre-fix 1.0.24 runtime: no install.
  - Runtime from main with the grant removed: no install.
- 'user' trust is avoided: besides persisting, a session created with it
  got no background plugins (the installer planned before the grant).
- No trust on resume: reopened sessions (for example after a reload) can't
  receive the grant, and trust changes don't reach a live session. The
  runtime needs an API to set or update session trust. This is still an
  open question on the runtime side.

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 22, 2026 01:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

3 open issues
What changed in this PR

Forwards VS Code Workspace Trust state into newly created Copilot SDK sessions so the Copilot runtime can load repository configuration (plugins/hooks/MCP/instructions) when the working directory is trusted.

Changes:

  • Added a shared isAgentHostWorkspaceTrusted helper and reused it across launcher/Codex/prewarmer trust checks.
  • Added trustWorkingDirectory: 'session' on SDK session create when the working directory (or inherited worktree repo) is trusted.
  • Recorded create-time trust on the session wrapper and used it to evict prewarmed sessions when trust changes before first send.
File Description
src/​vs/​platform/​agentHost/​test/​node/​copilotSessionLauncher.test.ts Adds launcher-level tests for working-directory trust grant behavior (create vs resume, worktrees, path case).
src/​vs/​platform/​agentHost/​test/​node/​copilotAgentSession.test.ts Updates test helpers for new CopilotSessionWrapper constructor parameter.
src/​vs/​platform/​agentHost/​test/​node/​copilotAgent.test.ts Adds E2E-ish agent tests for prewarm eviction on trust change and worktree trust inheritance.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotSessionWrapper.ts Stores create-time working-directory trust grant on the wrapper.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotSessionLauncher.ts Implements trust-grant computation and forwards it on session create; threads value into wrapper.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotAgentSession.ts Adds a utility to detect whether the session’s create-time trust matches current trust.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotAgent.ts Applies trust mismatch as a refresh/discard reason; annotates launch plan with worktree repo for inheritance.
src/​vs/​platform/​agentHost/​node/​codex/​codexAgent.ts Replaces inline trust logic with shared isAgentHostWorkspaceTrusted.
src/​vs/​platform/​agentHost/​node/​agentHostSessionPrewarmer.ts Replaces inline trust logic with shared isAgentHostWorkspaceTrusted.
src/​vs/​platform/​agentHost/​common/​agentHostWorkspaceTrust.ts Introduces isAgentHostWorkspaceTrusted helper with URI parsing/case-insensitive parent checks.
src/​vs/​platform/​agentHost/​common/​agentHostSchema.ts Exports IAgentHostWorkspaceTrust for reuse in node/common/test code.

Review effort: Lite

- Narrow getCopilotWorkingDirectoryTrust's return type to 'session' | undefined.
- Log the trusted working directory, and the repository when trust is inherited by a worktree.
- Describe the case-insensitive matching as platform-based, not detected per volume.

Co-authored-by: Copilot <[email protected]>
@vritant24
Vritant Bhardwaj (vritant24) merged commit d6e526a into main Oct 22, 2026
59 checks passed
@vritant24
Vritant Bhardwaj (vritant24) deleted the agents/forward-workspace-trust-to-copilot-runtime branch October 22, 2026 04:24
@vs-code-engineering vs-code-engineering Bot added this to the 1.144.0 milestone Oct 22, 2026
Ulugbek Abdullaev (ulugbekna) added a commit that referenced this pull request Oct 23, 2026
The Copilot launcher already grants the runtime trust for the worktree
Agent Host creates on a session's first send when its repository is
trusted (#343403): VS Code itself trusts that worktree only after the
session reports it. Apply the same rule to project canvas extensions, so
a worktree's canvases work on its first turn instead of staying refused
until the client's trust arrives.

The launch policy takes the launch plan's worktreeRepository with the
session's admission. A module under that worktree is trusted while the
repository is, by canonical path; the worktree must be a strict
descendant of the repository's <repo>.worktrees folder, like the
launcher requires. Revoking the repository's trust revokes the
worktree's launches, and the inheritance ends with the admission.

Worktrees created for other chats, and resumed sessions, get no
inheritance, as with the runtime grant: their extensions start once VS
Code trusts the worktree, through the live reconciliation.

Co-authored-by: Copilot <[email protected]>
Ulugbek Abdullaev (ulugbekna) added a commit that referenced this pull request Oct 23, 2026
…ctory

Review follow-up. The launch policy let every admitted directory that is
a worktree of the session's repository inherit the repository's trust,
including additional working directories, which need not be the worktree
the host created or even a real worktree. The runtime grant from #343403
inherits only for the launch plan's working directory.

Pass the created worktree together with its repository, and let only that
directory inherit, when it is admitted and, both as given and by
canonical path, a worktree under the repository's <repo>.worktrees
folder. A link named like a worktree but resolving elsewhere no longer
inherits; additional directories need workspace trust of their own.

Co-authored-by: Copilot <[email protected]>
Ulugbek Abdullaev (ulugbekna) added a commit that referenced this pull request Oct 28, 2026
The Copilot launcher already grants the runtime trust for the worktree
Agent Host creates on a session's first send when its repository is
trusted (#343403): VS Code itself trusts that worktree only after the
session reports it. Apply the same rule to project canvas extensions, so
a worktree's canvases work on its first turn instead of staying refused
until the client's trust arrives.

The launch policy takes the launch plan's worktreeRepository with the
session's admission. A module under that worktree is trusted while the
repository is, by canonical path; the worktree must be a strict
descendant of the repository's <repo>.worktrees folder, like the
launcher requires. Revoking the repository's trust revokes the
worktree's launches, and the inheritance ends with the admission.

Worktrees created for other chats, and resumed sessions, get no
inheritance, as with the runtime grant: their extensions start once VS
Code trusts the worktree, through the live reconciliation.

Co-authored-by: Copilot <[email protected]>
Ulugbek Abdullaev (ulugbekna) added a commit that referenced this pull request Oct 28, 2026
…ctory

Review follow-up. The launch policy let every admitted directory that is
a worktree of the session's repository inherit the repository's trust,
including additional working directories, which need not be the worktree
the host created or even a real worktree. The runtime grant from #343403
inherits only for the launch plan's working directory.

Pass the created worktree together with its repository, and let only that
directory inherit, when it is admitted and, both as given and by
canonical path, a worktree under the repository's <repo>.worktrees
folder. A link named like a worktree but resolving elsewhere no longer
inherits; additional directories need workspace trust of their own.

Co-authored-by: Copilot <[email protected]>
Ulugbek Abdullaev (ulugbekna) added a commit that referenced this pull request Oct 29, 2026
The Copilot launcher already grants the runtime trust for the worktree
Agent Host creates on a session's first send when its repository is
trusted (#343403): VS Code itself trusts that worktree only after the
session reports it. Apply the same rule to project canvas extensions, so
a worktree's canvases work on its first turn instead of staying refused
until the client's trust arrives.

The launch policy takes the launch plan's worktreeRepository with the
session's admission. A module under that worktree is trusted while the
repository is, by canonical path; the worktree must be a strict
descendant of the repository's <repo>.worktrees folder, like the
launcher requires. Revoking the repository's trust revokes the
worktree's launches, and the inheritance ends with the admission.

Worktrees created for other chats, and resumed sessions, get no
inheritance, as with the runtime grant: their extensions start once VS
Code trusts the worktree, through the live reconciliation.

Co-authored-by: Copilot <[email protected]>
Ulugbek Abdullaev (ulugbekna) added a commit that referenced this pull request Oct 29, 2026
…ctory

Review follow-up. The launch policy let every admitted directory that is
a worktree of the session's repository inherit the repository's trust,
including additional working directories, which need not be the worktree
the host created or even a real worktree. The runtime grant from #343403
inherits only for the launch plan's working directory.

Pass the created worktree together with its repository, and let only that
directory inherit, when it is admitted and, both as given and by
canonical path, a worktree under the repository's <repo>.worktrees
folder. A link named like a worktree but resolving elsewhere no longer
inherits; additional directories need workspace trust of their own.

Co-authored-by: Copilot <[email protected]>
Ulugbek Abdullaev (ulugbekna) added a commit that referenced this pull request Nov 10, 2026
The Copilot launcher already grants the runtime trust for the worktree
Agent Host creates on a session's first send when its repository is
trusted (#343403): VS Code itself trusts that worktree only after the
session reports it. Apply the same rule to project canvas extensions, so
a worktree's canvases work on its first turn instead of staying refused
until the client's trust arrives.

The launch policy takes the launch plan's worktreeRepository with the
session's admission. A module under that worktree is trusted while the
repository is, by canonical path; the worktree must be a strict
descendant of the repository's <repo>.worktrees folder, like the
launcher requires. Revoking the repository's trust revokes the
worktree's launches, and the inheritance ends with the admission.

Worktrees created for other chats, and resumed sessions, get no
inheritance, as with the runtime grant: their extensions start once VS
Code trusts the worktree, through the live reconciliation.

Co-authored-by: Copilot <[email protected]>
Ulugbek Abdullaev (ulugbekna) added a commit that referenced this pull request Nov 10, 2026
…ctory

Review follow-up. The launch policy let every admitted directory that is
a worktree of the session's repository inherit the repository's trust,
including additional working directories, which need not be the worktree
the host created or even a real worktree. The runtime grant from #343403
inherits only for the launch plan's working directory.

Pass the created worktree together with its repository, and let only that
directory inherit, when it is admitted and, both as given and by
canonical path, a worktree under the repository's <repo>.worktrees
folder. A link named like a worktree but resolving elsewhere no longer
inherits; additional directories need workspace trust of their own.

Co-authored-by: Copilot <[email protected]>
Ulugbek Abdullaev (ulugbekna) added a commit that referenced this pull request Nov 13, 2026
The Copilot launcher already grants the runtime trust for the worktree
Agent Host creates on a session's first send when its repository is
trusted (#343403): VS Code itself trusts that worktree only after the
session reports it. Apply the same rule to project canvas extensions, so
a worktree's canvases work on its first turn instead of staying refused
until the client's trust arrives.

The launch policy takes the launch plan's worktreeRepository with the
session's admission. A module under that worktree is trusted while the
repository is, by canonical path; the worktree must be a strict
descendant of the repository's <repo>.worktrees folder, like the
launcher requires. Revoking the repository's trust revokes the
worktree's launches, and the inheritance ends with the admission.

Worktrees created for other chats, and resumed sessions, get no
inheritance, as with the runtime grant: their extensions start once VS
Code trusts the worktree, through the live reconciliation.

Co-authored-by: Copilot <[email protected]>
Ulugbek Abdullaev (ulugbekna) added a commit that referenced this pull request Nov 13, 2026
…ctory

Review follow-up. The launch policy let every admitted directory that is
a worktree of the session's repository inherit the repository's trust,
including additional working directories, which need not be the worktree
the host created or even a real worktree. The runtime grant from #343403
inherits only for the launch plan's working directory.

Pass the created worktree together with its repository, and let only that
directory inherit, when it is admitted and, both as given and by
canonical path, a worktree under the repository's <repo>.worktrees
folder. A link named like a worktree but resolving elsewhere no longer
inherits; additional directories need workspace trust of their own.

Co-authored-by: Copilot <[email protected]>
Ulugbek Abdullaev (ulugbekna) added a commit that referenced this pull request Nov 16, 2026
The Copilot launcher already grants the runtime trust for the worktree
Agent Host creates on a session's first send when its repository is
trusted (#343403): VS Code itself trusts that worktree only after the
session reports it. Apply the same rule to project canvas extensions, so
a worktree's canvases work on its first turn instead of staying refused
until the client's trust arrives.

The launch policy takes the launch plan's worktreeRepository with the
session's admission. A module under that worktree is trusted while the
repository is, by canonical path; the worktree must be a strict
descendant of the repository's <repo>.worktrees folder, like the
launcher requires. Revoking the repository's trust revokes the
worktree's launches, and the inheritance ends with the admission.

Worktrees created for other chats, and resumed sessions, get no
inheritance, as with the runtime grant: their extensions start once VS
Code trusts the worktree, through the live reconciliation.

Co-authored-by: Copilot <[email protected]>
Ulugbek Abdullaev (ulugbekna) added a commit that referenced this pull request Nov 16, 2026
…ctory

Review follow-up. The launch policy let every admitted directory that is
a worktree of the session's repository inherit the repository's trust,
including additional working directories, which need not be the worktree
the host created or even a real worktree. The runtime grant from #343403
inherits only for the launch plan's working directory.

Pass the created worktree together with its repository, and let only that
directory inherit, when it is admitted and, both as given and by
canonical path, a worktree under the repository's <repo>.worktrees
folder. A link named like a worktree but resolving elsewhere no longer
inherits; additional directories need workspace trust of their own.

Co-authored-by: Copilot <[email protected]>
Ulugbek Abdullaev (ulugbekna) added a commit that referenced this pull request Nov 22, 2026
The Copilot launcher already grants the runtime trust for the worktree
Agent Host creates on a session's first send when its repository is
trusted (#343403): VS Code itself trusts that worktree only after the
session reports it. Apply the same rule to project canvas extensions, so
a worktree's canvases work on its first turn instead of staying refused
until the client's trust arrives.

The launch policy takes the launch plan's worktreeRepository with the
session's admission. A module under that worktree is trusted while the
repository is, by canonical path; the worktree must be a strict
descendant of the repository's <repo>.worktrees folder, like the
launcher requires. Revoking the repository's trust revokes the
worktree's launches, and the inheritance ends with the admission.

Worktrees created for other chats, and resumed sessions, get no
inheritance, as with the runtime grant: their extensions start once VS
Code trusts the worktree, through the live reconciliation.

Co-authored-by: Copilot <[email protected]>
Ulugbek Abdullaev (ulugbekna) added a commit that referenced this pull request Nov 22, 2026
…ctory

Review follow-up. The launch policy let every admitted directory that is
a worktree of the session's repository inherit the repository's trust,
including additional working directories, which need not be the worktree
the host created or even a real worktree. The runtime grant from #343403
inherits only for the launch plan's working directory.

Pass the created worktree together with its repository, and let only that
directory inherit, when it is admitted and, both as given and by
canonical path, a worktree under the repository's <repo>.worktrees
folder. A link named like a worktree but resolving elsewhere no longer
inherits; additional directories need workspace trust of their own.

Co-authored-by: Copilot <[email protected]>
Wing K.Y (wingwkyuen) pushed a commit to tcgoidc/vscode that referenced this pull request Nov 22, 2026
…rosoft#343771)

* agentHost: launch project canvas extensions only in trusted folders

Project canvas extensions (.github/extensions/*/extension.mjs) launched
from any folder a live session admitted, whether or not the user trusted
it. Move launch admission into CopilotProjectExtensionLaunchPolicy and
also require VS Code workspace trust, read from the mirrored root
configuration. This replaces the reverted microsoft#342372.

- Missing trust information refuses every project launch; disabled
  workspace trust keeps the previous behavior.
- Admitted roots, trusted folders and the entrypoint are compared by
  canonical path. A decision whose trust changes while roots resolve is
  re-evaluated, and the canonical entrypoint is what launches.
- Only a workspace-less chat's own scratch folder, a direct child of
  ~/.copilot/chats, is exempt: the agent created its contents.

An extension refused here stays refused until its session restarts; the
next commit reconciles running sessions when trust changes.

Co-authored-by: Copilot <[email protected]>

* agentHost: reconcile project canvas extensions when workspace trust changes

The launch policy is consulted only when the runtime starts an extension,
so trust granted or revoked while a session runs had no effect until it
restarted. Reconcile live canvas sessions instead:

- Classify each trust change as an expansion, a contraction or neither
  (reordering), and apply changes in a throttled pass that coalesces
  changes arriving while a pass runs.
- On contraction, re-check the launches the policy allowed and reload only
  sessions running an extension whose launch lost trust. The reload
  relaunches through the policy, which refuses it.
- On expansion, call the host-only extensions.reconcile() in sessions with
  a refused extension. Unlike extensions.enable, it saves no preference,
  respects the user's current enablement and leaves running extensions
  alone.
- Reconcile a session that is still initializing before and right after
  it registers, so a trust change cannot fall between the two.

Every reconciliation RPC is time-bounded and logged.

Co-authored-by: Copilot <[email protected]>

* agentHost: host-created worktrees inherit trust for canvas extensions

The Copilot launcher already grants the runtime trust for the worktree
Agent Host creates on a session's first send when its repository is
trusted (microsoft#343403): VS Code itself trusts that worktree only after the
session reports it. Apply the same rule to project canvas extensions, so
a worktree's canvases work on its first turn instead of staying refused
until the client's trust arrives.

The launch policy takes the launch plan's worktreeRepository with the
session's admission. A module under that worktree is trusted while the
repository is, by canonical path; the worktree must be a strict
descendant of the repository's <repo>.worktrees folder, like the
launcher requires. Revoking the repository's trust revokes the
worktree's launches, and the inheritance ends with the admission.

Worktrees created for other chats, and resumed sessions, get no
inheritance, as with the runtime grant: their extensions start once VS
Code trusts the worktree, through the live reconciliation.

Co-authored-by: Copilot <[email protected]>

* agentHost: inherit worktree trust only for the session's working directory

Review follow-up. The launch policy let every admitted directory that is
a worktree of the session's repository inherit the repository's trust,
including additional working directories, which need not be the worktree
the host created or even a real worktree. The runtime grant from microsoft#343403
inherits only for the launch plan's working directory.

Pass the created worktree together with its repository, and let only that
directory inherit, when it is admitted and, both as given and by
canonical path, a worktree under the repository's <repo>.worktrees
folder. A link named like a worktree but resolving elsewhere no longer
inherits; additional directories need workspace trust of their own.

Co-authored-by: Copilot <[email protected]>

* agentHost: exempt a scratch folder from trust only by canonical path

Review follow-up. The scratch-folder exemption checked the folder's
unresolved path, but admission records its canonical one. The default
chat's folder, ~/.copilot/chats/<session id>, is created with a recursive
mkdir that accepts an existing link, and the chats folder is shared with
other Copilot clients. A link there to an untrusted checkout would have
exempted that checkout's extensions from workspace trust, for every
session using it.

The policy now takes the scratch folder with the chats folder and grants
the exemption only while the folder is a direct child of the chats
folder both as given and by canonical path.

Co-authored-by: Copilot <[email protected]>

* agentHost: keep canvas revocation records across sessions' launch decisions

Review follow-up. The launch policy is shared by every session, but each
launch decision for an entrypoint first deleted that entrypoint's
allowed-launch record. If chat A runs a project extension and chat B
asks to launch it, revoking trust while B's decision resolves found no
record: B was refused and A kept running. A refused relaunch erased A's
record the same way, so a later revocation missed A too.

A launch decision now never removes a record; records are keyed by
entrypoint and canonical module and are dropped only once no live
session admits the module. A stale record can at most reload a session
running a same-named project extension, never miss a revocation.

Co-authored-by: Copilot <[email protected]>

* agentHost: don't fail a session when retrying refused extensions fails

Review follow-up. A trust expansion during a session's initialization
retries its refused project extensions with extensions.reconcile(). If
that rejected, for example on an older runtime without the method, the
error aborted an otherwise successful create or resume, while the live
and post-registration paths only log it.

Log a failed retry during initialization the same way: the extensions
stay refused. A failure while trust contracted still fails the session,
since a revoked extension may otherwise keep running.

Co-authored-by: Copilot <[email protected]>

* agentHost: separate canvas trust revocation from retries, and stop at retiring sessions

Initialization failed a session whose retry of refused project extensions
failed whenever the same trust change revoked any extension on the host,
even one this session didn't run. A session now logs a failed retry
itself, and throws only when it can't stop an extension whose trust was
revoked, which still fails initialization.

A live reconciliation also kept sending requests to a session that a
configuration refresh was replacing, and the SDK addresses them by session
id, so they could reach the replacement. Reconciliation now stops once its
session starts retiring or changes runtime, and destroying a session lets
a reconciliation already in flight finish before it disconnects.

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants