Agent Host: enable session-specific Copilot sandbox settings - #335364
Agent Host: enable session-specific Copilot sandbox settings#335364Dileep Yavanmandha (dileepyavan) wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The displayed defaults and managed-policy state can diverge from runtime behavior, and the linked issue’s required sandbox-specific confirmation remains unimplemented.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review tier: Balanced
Findings: 4
New issues introduced by this change (4)
| Severity | Finding |
|---|---|
src/vs/platform/agentHost/common/agentService.ts — This now reads chat.agent.sandbox.enabled even for the SDK shell path, while… |
|
src/vs/platform/agentHost/node/sessionPermissions.ts — The linked #333900 explicitly requires a sandbox-specific “Disable sandbox for this session and… |
|
src/vs/sessions/contrib/providers/copilotChatSessions/browser/permissionPicker.ts — This presentation uses the workbench-wide managed-settings snapshot, not the authoritative… |
|
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostChatInputPicker.ts — This editor picker also derives managed state from the workbench-wide snapshot rather than the… |
What changed in this PR
Adds session-scoped sandbox configuration for local Copilot Agent Host sessions, including persistence, policy enforcement, runtime updates, permissions UI, and tests.
Changes:
- Persists per-session sandbox choices with owner, restore, and fork semantics.
- Applies choices across SDK and custom-terminal execution under managed policy.
- Adds shared picker UI, bypass handling, tests, and documentation.
| File | Description |
|---|---|
src/vs/workbench/contrib/terminalContrib/chatAgentTools/test/browser/agentHostSandboxForwarder.test.ts |
Updates forwarding expectations. |
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/agentHostSandboxForwarder.ts |
Retains restrictions when disabled. |
src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostChatInputPicker.test.ts |
Tests session toggle behavior. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostChatInputPicker.ts |
Adds editor session toggle. |
src/vs/sessions/contrib/providers/copilotChatSessions/test/browser/permissionPicker.test.ts |
Tests Agents-window toggle. |
src/vs/sessions/contrib/providers/copilotChatSessions/browser/permissionPicker.ts |
Integrates shared toggle UI. |
src/vs/sessions/contrib/providers/agentHost/test/browser/localAgentHostSessionsProvider.test.ts |
Verifies non-inheritance. |
src/vs/sessions/contrib/providers/agentHost/test/browser/agentHost/agentHostSessionConfigPicker.test.ts |
Verifies picker exclusion. |
src/vs/sessions/contrib/providers/agentHost/test/browser/agentHost/agentHostPermissionPickerDelegate.test.ts |
Tests per-session delegation. |
src/vs/sessions/contrib/providers/agentHost/browser/baseAgentHostSessionsProvider.ts |
Excludes sandbox from remembered defaults. |
src/vs/sessions/contrib/providers/agentHost/browser/agentHostSessionConfigPicker.ts |
Defers sandbox to permissions UI. |
src/vs/sessions/contrib/providers/agentHost/browser/agentHostPermissionPickerDelegate.ts |
Reads and writes session choices. |
src/vs/platform/agentHost/test/node/shared/editArcReporter.test.ts |
Updates configuration stub. |
src/vs/platform/agentHost/test/node/sessionSandbox.test.ts |
Covers ownership and policy precedence. |
src/vs/platform/agentHost/test/node/copilotShellTools.test.ts |
Tests custom-terminal updates. |
src/vs/platform/agentHost/test/node/copilotSessionLauncher.test.ts |
Tests startup policy handling. |
src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts |
Tests live SDK updates. |
src/vs/platform/agentHost/test/node/copilotAgent.test.ts |
Tests restore and fork semantics. |
src/vs/platform/agentHost/test/node/chatContributions.test.ts |
Tests metadata persistence. |
src/vs/platform/agentHost/test/node/agentHostChangesetOperationService.test.ts |
Updates configuration stub. |
src/vs/platform/agentHost/test/common/agentMetaReaders.test.ts |
Tests bypass metadata validation. |
src/vs/platform/agentHost/test/browser/agentHostSandboxToggle.test.ts |
Tests shared toggle logic. |
src/vs/platform/agentHost/node/sessionSandbox.ts |
Resolves session sandbox overrides. |
src/vs/platform/agentHost/node/sessionPermissions.ts |
Persists bypass opt-outs. |
src/vs/platform/agentHost/node/copilot/copilotShellTools.ts |
Associates engines with session URIs. |
src/vs/platform/agentHost/node/copilot/copilotSessionLauncher.ts |
Applies startup sandbox policy. |
src/vs/platform/agentHost/node/copilot/copilotSandboxPolicy.ts |
Projects runtime policy. |
src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts |
Applies live SDK configuration. |
src/vs/platform/agentHost/node/copilot/agentHostSandboxEngine.ts |
Merges session overrides. |
src/vs/platform/agentHost/node/agentConfigurationService.ts |
Stores runtime policy floors. |
src/vs/platform/agentHost/common/sessionConfigKeys.ts |
Defines persisted sandbox choice. |
src/vs/platform/agentHost/common/meta/agentToolCallMeta.ts |
Adds typed bypass metadata. |
src/vs/platform/agentHost/common/agentService.ts |
Selects sandbox default setting. |
src/vs/platform/agentHost/common/agentHostSchema.ts |
Advertises the session property. |
src/vs/platform/agentHost/browser/agentHostSandboxToggle.ts |
Shares toggle presentation logic. |
src/vs/platform/agentHost/AGENTS.md |
Documents sandbox architecture. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| export function getAgentHostCopilotSandboxSettingId(_customTerminalToolEnabled: boolean, windows = isWindows): AgentHostCopilotSandboxSettingId { | ||
| // TODO: Check Agent Host-specific sandbox settings once they are enabled for users. | ||
| return windows ? AgentSandboxSettingId.AgentSandboxWindowsEnabled : AgentSandboxSettingId.AgentSandboxEnabled; |
| /** | ||
| * Handles the side effect of a `ChatToolCallConfirmed` action when the | ||
| * user selected "Allow in this Session". Adds the tool to the session's | ||
| * permission allow list so future calls are auto-approved. | ||
| * user selected "Allow in this Session": persist a sandbox opt-out for | ||
| * escapes, or a tool permission for ordinary confirmations. |
| provider: this._delegate.getSandboxToggleProvider?.(), | ||
| sessionEnabled: this._delegate.sandboxEnabled?.get(), | ||
| globalEnabled: settingId !== undefined && isAgentSandboxEnabledValue(this.configurationService.getValue<AgentSandboxEnabledSettingValue>(settingId)), | ||
| managedEnabled: this._delegate.managedSandboxEnforced?.get() === true, | ||
| allowsBypass: this.agentHostEnablementService.managedSandboxAllowsBypass.get(), |
| provider: context?.backendSession.scheme, | ||
| sessionEnabled: value === AgentSandboxEnabledValue.On ? true : value === AgentSandboxEnabledValue.Off ? false : undefined, | ||
| globalEnabled: settingId !== undefined && isAgentSandboxEnabledValue(this._configurationService.getValue<AgentSandboxEnabledSettingValue>(settingId)), | ||
| managedEnabled: this._agentHostEnablementService.managedSandboxEnforced.get(), | ||
| allowsBypass: this._agentHostEnablementService.managedSandboxAllowsBypass.get(), |
Screenshot ChangesBase: Changed (32)2 insignificant change(s) omitted (≤20 px, Δ≤2). See CI logs for details. Errored (2)Fixtures that failed to render — no screenshot was produced.
|

Summary
Related to #333900.
Adds a persisted, session-scoped sandbox choice for the local Copilot Agent Host, without changing the user's global sandbox settings. This control is not added to Claude, Codex, or extension-backed Copilot Chat.
Changes
sandboxEnabled(default,on,off) to session configuration. Missing/defaultfollows current global settings; explicit choices survive restore. Peer chats and nested subagents resolve to the same owner. New sessions and forks do not inherit the choice.Review Guide
sessionConfigKeys.ts,agentHostSchema.ts,agentConfigurationService.ts, andsessionSandbox.ts: persisted choice, owner resolution, and precedence.copilotSandboxPolicy.ts,copilotSessionLauncher.ts,copilotAgentSession.ts,agentHostSandboxEngine.ts, andsessionPermissions.ts: runtime application and escape handling.agentHostSandboxToggle.ts, picker/delegate changes, andagentHostSandboxForwarder.ts: presentation, session writes, and global defaults.src/vs/platform/agentHost/AGENTS.md.Validation
origin/mainat585a254fad3in signed commit229facda6b8. No unresolved conflicts; stagedgit diff --checkpassed. Merge pre-commit hygiene passed for 349 eligible files from 455 staged files.autoTierandclientInfooptions, plus an apparently stale test-stub diagnostic (the reported missing methods are present). Dependency/typecheck reconciliation remains pending.gulp hygieneis blocked locally by an existing Windows path construction error (C:\C:\...); standalone changed-file hygiene and both signed commits' pre-commit hooks passed.Manual Verification / Draft Follow-ups
Live UI/SDK end-to-end verification is still pending. Picker dismissal after toggling remains unverified, and changed toggle presentations still use whole-list refreshes. The sandbox-specific confirmation wording requested in #333900 remains a follow-up.