Repository navigation
agentHost: respect managed permission modes - #340408
Ross Wollman (rwoll) wants to merge 14 commits into
Conversation
Resolve native approval policy in the Copilot host and advertise available and effective modes to both windows. Apply the legacy blanket only when no explicit new mode restriction is configured, retaining independent tool restrictions. Use the same host-authoritative path on desktop and remote hosts while preserving legacy client guards for peers without approval reports. *🤖 Authored with GitHub Copilot on behalf of @rwoll.* Co-authored-by: Copilot <[email protected]>
Retain the reviewed SDK 1.0.18-preview.1 and runtime 1.0.94-1 while incorporating current upstream changes. The only conflicts were the older upstream SDK dependency entries. *🤖 Authored with GitHub Copilot on behalf of @rwoll.* Co-authored-by: Copilot <[email protected]>
Use allowed and blocked indicators matching the reviewed PR table. *🤖 Authored with GitHub Copilot on behalf of @rwoll.* Co-authored-by: Copilot <[email protected]>
Mark scenarios 6 and 8 in the permission matrix without changing their behavior. *🤖 Authored with GitHub Copilot on behalf of @rwoll.* Co-authored-by: Copilot <[email protected]>
|
Base:
|
| timeoutMs: number, | ||
| workingDirectory?: string, | ||
| ): Promise<Awaited<ReturnType<CopilotClient['rpc']['managedSettings']['resolve']>>> { | ||
| const result = await raceTimeout(managedSettings.resolve({ |
There was a problem hiding this comment.
Looking at the caching behavior for this call, since we don't want to slow down users starting a new session. Will follow up with findings. Input from folks familiar with this hot path would be helpful.
🤖 Authored with GitHub Copilot on behalf of Ross Wollman (@rwoll).
There was a problem hiding this comment.
Follow-up from checking SDK 1.0.18-preview.1 / runtime 1.0.94-1:
- This call uses the runtime cache. Server policy has a one-hour freshness window per account, including cached "no policy" responses. This is not a hard network rate limit: forced refreshes, invalidation, concurrent misses, retries, and background refreshes can still fetch.
- With no GitHub account selected, resolution can return device policy without fetching GitHub policy or requiring sign-in. A local tokenless SDK probe succeeded, but that is not a full BYOK first-send benchmark.
I would still appreciate input from folks familiar with session startup: do we need both the preview/config-refresh resolution and the launch-time resolution, and is the remaining work on cache hits acceptable?
🤖 Authored with GitHub Copilot on behalf of Ross Wollman (@rwoll).
There was a problem hiding this comment.
🟡 Changes recommended
Runtime mutability validation and pre-resolution legacy clamping can violate the host-advertised permission contract.
4 open findings
What changed in this PR
Adds host-authoritative managed permission modes across desktop and remote Copilot Agent Hosts.
Changes:
- Resolves and enforces native approval-mode policies with legacy fallback precedence.
- Updates Editor and Agents Window permission pickers and completion actions.
- Upgrades the Copilot SDK/runtime and expands policy coverage.
| File | Description |
|---|---|
.github/skills/policy-and-managed-settings/sdk-runtime-policy.md |
Documents approval policy precedence. |
package.json |
Updates Copilot SDK/runtime versions. |
package-lock.json |
Locks updated root dependencies. |
remote/package.json |
Updates remote Copilot dependencies. |
remote/package-lock.json |
Locks updated remote dependencies. |
src/vs/platform/agentHost/common/agentHostManagedSettings.ts |
Moves global approval resolution host-side. |
src/vs/platform/agentHost/common/sessionConfigProperties.ts |
Handles host-reported approval modes. |
src/vs/platform/agentHost/node/agentService.ts |
Validates host-owned approval state. |
src/vs/platform/agentHost/node/copilot/copilotAgent.ts |
Resolves managed defaults and choices. |
src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts |
Synchronizes runtime permission modes. |
src/vs/platform/agentHost/node/copilot/copilotAgentStartupConfig.ts |
Tracks legacy policy startup state. |
src/vs/platform/agentHost/node/copilot/copilotApprovalPolicy.ts |
Implements policy precedence and projection. |
src/vs/platform/agentHost/node/copilot/copilotSessionLauncher.ts |
Supplies policy and feature flags. |
src/vs/platform/agentHost/node/sessionPermissions.ts |
Enforces effective host-reported modes. |
src/vs/platform/agentHost/test/common/agentHostManagedSettings.test.ts |
Updates bridge expectations. |
src/vs/platform/agentHost/test/electron-browser/agentHostProtocolClient.test.ts |
Tests root-policy forwarding. |
src/vs/platform/agentHost/test/node/agentService.test.ts |
Tests config validation and defaults. |
src/vs/platform/agentHost/test/node/copilotAgent.test.ts |
Updates SDK fixtures and flags. |
src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts |
Tests runtime mode reconciliation. |
src/vs/platform/agentHost/test/node/copilotApprovalPolicy.test.ts |
Covers policy combinations. |
src/vs/platform/agentHost/test/node/copilotSessionLauncher.test.ts |
Tests launch-time policy injection. |
src/vs/platform/agentHost/test/node/copilotTestEvents.ts |
Adds unmanaged-settings test fixture. |
src/vs/platform/agentHost/test/node/providerIntegration/copilotAutoTier.integrationTest.ts |
Adapts SDK tier narrowing. |
src/vs/platform/agentHost/test/node/providerIntegration/copilotManagedPermissions.integrationTest.ts |
Tests runtime restrictions. |
src/vs/platform/agentHost/test/node/sessionPermissions.test.ts |
Tests global approval enforcement. |
src/vs/sessions/contrib/chat/browser/agentHostInputCompletions.ts |
Reads session policy for completions. |
src/vs/sessions/contrib/chat/test/browser/agentHostInputCompletions.test.ts |
Updates completion fixtures. |
src/vs/sessions/contrib/providers/agentHost/browser/agentHostPermissionPickerDelegate.ts |
Delegates host-aware policy checks. |
src/vs/sessions/contrib/providers/agentHost/browser/baseAgentHostSessionsProvider.ts |
Integrates defaults and host schema. |
src/vs/sessions/contrib/providers/copilotChatSessions/browser/mobilePermissionPicker.ts |
Reuses delegated policy state. |
src/vs/sessions/contrib/providers/copilotChatSessions/browser/permissionPicker.ts |
Supports host-specific restrictions. |
src/vs/sessions/contrib/providers/remoteAgentHost/test/browser/remoteAgentHostSessionsProvider.test.ts |
Tests remote host authority. |
src/vs/workbench/contrib/chat/browser/agentHostCompletionAction.ts |
Filters unavailable completion actions. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostChatInputPicker.ts |
Disables unavailable permission rows. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionHandler.ts |
Passes provider into initial config. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostUntitledProvisionalSessionService.ts |
Seeds provider-aware defaults. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentSessionSettingsFileSystemProvider.ts |
Excludes host-owned reports. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/applyAgentHostSessionConfig.ts |
Uses host schema for policy checks. |
src/vs/workbench/contrib/chat/browser/widget/input/editor/agentHostInputCompletions.ts |
Resolves policy-aware completions. |
src/vs/workbench/contrib/chat/browser/widget/input/permissionPickerActionItem.ts |
Adds delegated policy checks. |
src/vs/workbench/contrib/chat/common/agentHostConfigPolicy.ts |
Detects host-owned approval policy. |
src/vs/workbench/contrib/chat/test/browser/agentHostCompletionAction.test.ts |
Tests policy helpers. |
src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostChatInputPicker.test.ts |
Tests disabled host choices. |
src/vs/workbench/contrib/chat/test/browser/widget/input/editor/chatInputCompletions.test.ts |
Updates injected test services. |
Files not reviewed (1)
- remote/package-lock.json: Generated file
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
Preserve the permission policy resolver import alongside upstream bulk questions and Mission Control changes. Validated the merged client build, typecheck, lint, and 1839 focused host tests. *🤖 Authored with GitHub Copilot on behalf of @rwoll.* Co-authored-by: Copilot <[email protected]>
| | # | Legacy policy JSON | Managed-settings JSON | Local: Allow All | Local: Assisted | Local: Manual | Copilot/Agent Host: Allow All | Copilot/Agent Host: Assisted | Copilot/Agent Host: Manual | | ||
| |---|---|---|:---:|:---:|:---:|:---:|:---:|:---:| | ||
| | 1 | `{}` | `{}` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | ||
| | 2 | `{"ChatToolsAutoApprove":false}` | `{}` | ❌ | ❌ | ✅ | ❌ | ❌ | ✅ | | ||
| | 3 | `{}` | `{"permissions":{"disableBypassPermissionsMode":"disable"}}` | ❌ | ❌ | ✅ | ❌ | ✅ | ✅ | | ||
| | 4 | `{"ChatToolsAutoApprove":false}` | `{"permissions":{"disableBypassPermissionsMode":"disable"}}` | ❌ | ❌ | ✅ | ❌ | ✅ | ✅ | | ||
| | 5 | `{}` | `{"permissions":{"disableAssistedPermissionsMode":true}}` | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | | ||
| | 6 ⚠️ | `{"ChatToolsAutoApprove":false}` | `{"permissions":{"disableAssistedPermissionsMode":true}}` | ❌ | ❌ | ✅ | ✅ | ❌ | ✅ | | ||
| | 7 | `{"ChatToolsAutoApprove":false}` | `{"permissions":{"disableBypassPermissionsMode":"disable","disableAssistedPermissionsMode":true}}` | ❌ | ❌ | ✅ | ❌ | ❌ | ✅ | | ||
| | 8 ⚠️ | `{"ChatToolsAutoApprove":false}` | `{"permissions":{"disableBypassPermissionsMode":"enable"}}` | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ | |
There was a problem hiding this comment.
Reviewed this offline with Harald Kirschner (@digitarald) and we are on the same page that this is the expected table. (6) and (8) are a result of the simple rule: if managed settings exist, copilot harness should follow them instead of the legacy policy.
Retain upstream provider timing and detached-service support alongside managed approval policies. Use the SDK/runtime versions already rolled on main instead of carrying a dedicated dependency bump. 🤖 Authored with GitHub Copilot on behalf of @rwoll. Co-authored-by: Copilot <[email protected]>
Do not overwrite the actual SDK result with the requested allow-all mode after a policy-constrained response. Publish the actual applied selection consistently with ordinary synchronization. Confirmed the bundled runtime returns success:false, mode:manual for blocked allow-all. Both new regressions failed before the fix; five focused toggle/synchronization tests and targeted lint pass. 🤖 Authored with GitHub Copilot on behalf of @rwoll. Co-authored-by: Copilot <[email protected]>
Give launch/runtime policy snapshots, selection reconciliation, response acceptance, and applied reports one session-owned object. Keep SDK calls, sequencing, retry timing, configuration publication, and lifecycle in CopilotAgentSession. Preserve the approved precedence matrix and recomputation/event timing, including consulting current policy after SDK calls. Add standalone transition and result-acceptance coverage. Validation: 1113 policy/session/launcher tests passed; strict initialization/type check and targeted hygiene passed. 🤖 Authored with GitHub Copilot on behalf of @rwoll. Co-authored-by: Copilot <[email protected]>
Keep explicit and remembered approval preferences until the host advertises its policy contract. Normalize both standard and VS Code approval bindings, wait for resolved preferences before prewarming, and retain legacy restrictions for older peers.\n\nValidate existing-session approval writes as runtime changes and let live Copilot sessions apply native-policy precedence for approval toggles. *🤖 Authored with GitHub Copilot on behalf of @rwoll.* Co-authored-by: Copilot <[email protected]>
This comment has been minimized.
This comment has been minimized.
Provide the new service contracts in paste and session-identity mocks. Assert config replacement over writable client values without requiring host-owned readonly reports to disappear. *🤖 Authored with GitHub Copilot on behalf of @rwoll.* Co-authored-by: Copilot <[email protected]>
This comment has been minimized.
This comment has been minimized.
Merge origin/main at 4bd93ff without rewriting the PR history. *🤖 Authored with GitHub Copilot on behalf of @rwoll.* Co-authored-by: Copilot <[email protected]>
Keep only explicit approval defaults before discovery, translate completion keys and values for standard hosts, and retain unavailable Editor choices as disabled. Surface completion write failures and cover provider-neutral defaults and acceptance paths. Clarify that legacy Local does not provide Assisted mode. *🤖 Authored with GitHub Copilot on behalf of @rwoll.* Co-authored-by: Copilot <[email protected]>
Include the merged automatic-migration cancellation fix and preserve both SDK type imports at the session-launcher merge boundary. *🤖 Authored with GitHub Copilot on behalf of @rwoll.* Co-authored-by: Copilot <[email protected]>
<!-- Thank you for submitting a Pull Request. Please: * Read our Pull Request guidelines: https://github.com/microsoft/vscode/wiki/How-to-Contribute#pull-requests * Associate an issue with the Pull Request. * Ensure that the code is up-to-date with the `main` branch. * Include a description of the proposed changes and how to test them. --> Supersedes #340408. Builds on the automatic migration and cleanup in #340585 and #340596. Any nonempty managed `permissions` object now requires Copilot Agent Host, including defaults, explicit `false` / `"enable"`, and empty rule lists. This reuses the existing Local chat migration without sending anything automatically. Copilot's permission picker reflects runtime restrictions and defaults, allowing admins to block Allow All while keeping Assisted available. Explicit new mode restrictions replace the legacy blanket restriction; `defaultMode` alone does not. Empty `permissions: {}` and legacy policy alone retain existing Local behavior. Editor Inline Chat keeps its limited read/edit exception. Sandboxing remains independent. ## Policy behavior **Legacy `ChatToolsAutoApprove: false` with no managed permissions still blocks both Allow All and Assisted in Copilot Agent Host.** It does not force users off Local. A nonempty `permissions` object determines harness eligibility; only an explicit new mode restriction replaces the legacy blanket mode restriction. The table shows selectable modes, not the starting selection. It assumes all modes are supported and no additional restrictions. Legacy JSON represents policy values, not OS-specific deployment syntax. Local does not support Assisted. | # | Legacy policy JSON | Managed-settings JSON | Full Local chat | AH: Allow All | AH: Assisted | AH: Manual | |---|---|---|---|:---:|:---:|:---:| | 1 | `{}` | `{}` | Available | ✅ | ✅ | ✅ | | 2 | `{"ChatToolsAutoApprove":false}` | `{}` | Available, legacy restrictions | ❌ | ❌ | ✅ | | 3 | `{}` | `{"permissions":{"disableBypassPermissionsMode":"disable"}}` | Migrate to Copilot | ❌ | ✅ | ✅ | | 4 | `{"ChatToolsAutoApprove":false}` | `{"permissions":{"disableBypassPermissionsMode":"disable"}}` | Migrate to Copilot | ❌ | ✅ | ✅ | | 5 | `{}` | `{"permissions":{"disableAssistedPermissionsMode":true}}` | Migrate to Copilot | ✅ | ❌ | ✅ | | 6 | `{"ChatToolsAutoApprove":false}` | `{"permissions":{"disableAssistedPermissionsMode":true}}` | Migrate to Copilot | ✅ | ❌ | ✅ | | 7 | `{"ChatToolsAutoApprove":false}` | `{"permissions":{"disableBypassPermissionsMode":"disable","disableAssistedPermissionsMode":true}}` | Migrate to Copilot | ❌ | ❌ | ✅ | | 8 | `{"ChatToolsAutoApprove":false}` | `{"permissions":{"disableBypassPermissionsMode":"enable"}}` | Migrate to Copilot | ✅ | ✅ | ✅ | | 9 | `{"ChatToolsAutoApprove":false}` | `{"permissions":{"disableAssistedPermissionsMode":false}}` | Migrate to Copilot | ✅ | ✅ | ✅ | | 10 | `{}` | `{"permissions":{"defaultMode":"assisted"}}` | Migrate to Copilot | ✅ | ✅ | ✅ | | 11 | `{"ChatToolsAutoApprove":false}` | `{"permissions":{"defaultMode":"assisted"}}` | Migrate to Copilot | ❌ | ❌ | ✅ | | 12 | `{"ChatToolsAutoApprove":false}` | `{"permissions":{"ask":[]}}` | Migrate to Copilot | ❌ | ❌ | ✅ | `permissions: {}` behaves like no permissions object. Rows 6, 8, and 9 intentionally replace the legacy restriction with the explicitly configured new mode controls. Rows 11 and 12 require Agent Host but retain the legacy mode restriction. In row 10, Assisted is the starting default unless an explicit or remembered choice takes precedence; in row 11 it is unavailable, so the default falls back to Manual. “Migrate to Copilot” means full Local execution is unavailable: new chats use Copilot and existing Local chats migrate when displayed. The editor-inline exception above remains. Managed `sandbox.enabled: true` independently requires Agent Host even when permissions are absent. ## Testing Test with only `permissions.disableBypassPermissionsMode: "disable"`: full Local chats should move to Copilot, Allow All should be unavailable, and Assisted should remain selectable. Also test policy removal and an empty permissions object. Relates #338932. Relates microsoft/vscode-internalbacklog#9987. *🤖 Authored with GitHub Copilot on behalf of @rwoll.*


Admin and user impact
Lets admins control Copilot Agent Host permission modes:
permissions.disableAssistedPermissionsMode: trueblocks Assisted withoutalso blocking Allow All.
permissions.disableBypassPermissionsMode: "disable"blocks Allow All whileleaving Assisted available.
permissions.defaultModechooses the starting mode for new chats (manual,assisted, orallow-all). It is a default, not a lock.Blocked modes cannot be selected or applied. Manual remains available.
Explicit or remembered approval choices take precedence over
defaultMode,subject to the allowed modes. An unavailable managed default falls back to Manual.
How policies combine
An explicitly configured new mode restriction replaces the old
ChatToolsAutoApproverestriction. Without one, the old restriction stillapplies. Setting only
defaultModedoes not override it. Separate restrictionson individual tools still apply.
Explicit
disableAssistedPermissionsMode: falseanddisableBypassPermissionsMode: "enable"also opt into the new policy group.Omitting both mode restrictions keeps the legacy fallback.
Potential surprise: rows 6 and 8 allow Allow All even when
ChatToolsAutoApproveis false. In row 6, the admin has explicitly blocked onlyAssisted using the new settings. We discussed this behavior offline and agreed
to proceed with the table below.
The table shows which modes can be selected, not the starting mode. It assumes
no additional restrictions. The legacy JSON represents policy values, not
OS-specific deployment syntax.
✅ Allowed; ❌ Blocked; N/A: not supported by that harness.
{}{}{"ChatToolsAutoApprove":false}{}{}{"permissions":{"disableBypassPermissionsMode":"disable"}}{"ChatToolsAutoApprove":false}{"permissions":{"disableBypassPermissionsMode":"disable"}}{}{"permissions":{"disableAssistedPermissionsMode":true}}{"ChatToolsAutoApprove":false}{"permissions":{"disableAssistedPermissionsMode":true}}{"ChatToolsAutoApprove":false}{"permissions":{"disableBypassPermissionsMode":"disable","disableAssistedPermissionsMode":true}}{"ChatToolsAutoApprove":false}{"permissions":{"disableBypassPermissionsMode":"enable"}}Local offers Default, Allow All, and Autopilot, not Assisted. Runtime
defaultModedoes not configure Local's starting permission level.
UI difference: the Editor shows blocked modes disabled with an explanation;
the Agents Window hides them. This PR does not change that difference.
Data and UI flow
flowchart TD Policy["New settings + old policy"] --> Host["Agent Host decides allowed modes and default"] Host --> UI["Editor / Agents Window shows the choices"] UI -->|User selects a mode| Host Host --> Runtime["Copilot runtime applies the mode and enforces restrictions"]Applies to desktop and remote Copilot Agent Hosts in the Editor and Agents Window.
Policies are read where the host runs; desktop device policy is not automatically
copied to remote hosts. Legacy Local and sandbox behavior are unchanged by
this PR.
Uses the SDK/runtime already rolled into
main; this PR no longer changes thedependency manifests or lockfiles.
Implementation
Approval-policy state and decisions live in a small, session-owned
CopilotSessionApprovalPolicy. The session retains SDK calls, sequencing,retries, and configuration publication; the policy object adds no service,
listeners, or cache.
Explicit and remembered approval preferences survive until host schema discovery,
including the standard
approvalModebinding. Older hosts retain the legacyrestriction. Approval toggles publish the mode actually applied by the runtime.
Completion actions use the host's advertised approval key and values, and Editor
pickers keep unavailable modes visible and disabled for either binding.
Policy resolution uses the runtime cache, but first-send latency has not been
benchmarked; the startup-performance discussion remains open.
Local validation results
and CI test corrections
are recorded in the comments. Azure build 482438
passed the Windows, Linux, and macOS Electron integration jobs, but the overall
build failed after the Windows unit-test job timed out.
Manual testing
Restart to apply changed managed settings; this PR does not promise live refresh
of all native policy. Apply the numbered scenarios through managed policy, then
compare both picker surfaces. Also test a new Assisted default, an explicit or
remembered Manual choice, resume, and global approval on/off.
🤖 Authored with GitHub Copilot on behalf of Ross Wollman (@rwoll).