Repository navigation
Description
Does this issue occur when all extensions are disabled?: Yes
- VS Code Version: 1.146.0 (commit
69047191fc427f2f92828279aae1d90d8eeda7ab, 2026-11-10), Electron 43.8.6 - OS Version: Darwin arm64 25.6.0 (host); VS Code Remote - Dev Container (Debian trixie, Linux arm64)
- Copilot: bundled
@github/copilot1.0.108-0,@github/copilot-sdk1.0.30-preview.0; Copilot CLI in the container 1.0.114 - Settings:
chat.agent.sandbox.enabled: "on",chat.agent.networkFilter: true,chat.agent.sandbox.network.allowNetwork: true
Steps to Reproduce:
-
Configure a device-managed sandbox policy in
/etc/github-copilot/managed-settings.json(resolved assource=mdm) that restrictsnetwork.allowedHosts(and optionallyfilesystem.readonlyPaths):{ "sandbox": { "userPolicy": { "network": { "allowLocalNetwork": true, "allowedHosts": ["example.com", "*.example.org", "..."] }, "filesystem": { "readonlyPaths": ["/workspaces/<project>/.git/hooks", "/workspaces/<project>/.vscode", "..."] } } } } -
Start a new agent session in VS Code and send a message. This works: the open-time config is rejected, VS Code reopens without it, and once
session.managed_settings_resolvedarrives the policy is applied. -
Reload the window or restart the container, then open that session again and send a message.
Actual behavior
- The session opens empty (no history) and the error is "Couldn't open session".
- Sending a message fails with
Error: (sendFailed) Sandbox configuration update violates managed policy. Contact your administrator for more information. - Retrying then fails with
Conflicting chat storage identity: ahp-chat:/<new-id>, because a new session is created under the existing session ID.
Agent host log:
[warning] [Copilot:<sdk-id>] Open-time sandboxConfig conflicts with managed policy; reopening without it Sandbox configuration update violates managed policy. ...
[info] [Copilot:<sdk-id>] SDK resumeSession settled: ... outcome=success
[warning] [Copilot:<sdk-id>] Failed to apply SDK sandboxConfig Sandbox configuration update violates managed policy. ...
[warning] [Copilot] Failed to resume chat backing ahp-chat:/<chat-id>: Sandbox configuration update violates managed policy. ...
[error] [ProtocolServer] Request 'subscribe' id=6 failed Failed to restore session ahp-session:/<id>: Sandbox configuration update violates managed policy. ...
[error] [ProtocolServer] Request 'createSession' id=28 failed Conflicting chat storage identity: ahp-chat:/<new-id>
The session history in ~/.copilot/session-state/<id>/events.jsonl is intact. copilot --resume <id> in a terminal works.
Expected behavior
Resuming a session under a managed policy should behave like creating one: the session opens with the managed policy applied and the history is shown.
Analysis (from the minified agentHostMain.js)
- On resume,
applyLaunchSandbox(..., isResume=true)→applyLaunchConfig→_updateConfig(throwOnError=true, ...)sends a config built by_computeConfig()before the per-session managed policy is known (getSessionSandboxPolicy()is stillundefined). - Without the policy, the config is built from host settings only:
allowedNetworkDomains: []→ noallowedHosts, i.e. all hosts allowed. This exceeds the managed host list.readonlyPathsgets the session data directories (.../agentSessionData/<id>/attachments, shell-init directory) becauset?.readonlyPaths === undefined. These paths are not in the managedreadonlyPaths, which managed settings match by exact string.
- The runtime rejects this. On create,
_openWithSandboxConfigretries without the config and update errors are only logged. On resume,throwOnErroristrue, so the error aborts the restore. - The SDK supports
sandboxConfigSource(never_configured/user_enabled/repository_policy…). For these settings-derived origins the runtime raises a host preference to the managed policy instead of rejecting it.agentHostMain.jsnever setssandboxConfigSource, so every config counts as an explicit choice and conflicts. - Putting the hosts into
agent-host-config.jsonin the container does not persist: the values are reset from the client'schat.agent.sandbox.*settings on connect.chat.agent.sandbox.network.allowedDomainshas application scope and cannot be set by the dev container or workspace.
Suggested fix (any of these)
- Send
sandboxConfigSource(e.g.user_enabled/never_configured) with launch and update configs derived from settings, so the runtime floors them to the managed policy instead of rejecting them. - On resume, wait for
session.managed_settings_resolvedbeforeapplyLaunchConfig, or build the config from the resolved policy. - On resume, treat
managed_sandbox_policy_conflictlike the create path does: log it and continue with the runtime's existing sandbox configuration, instead of failing the restore. - Do not create a new session or chat identity for an existing session after a failed restore, which currently causes
Conflicting chat storage identity.
Activity
xeladotbe commentedon Nov 19, 2026
Additional findings: the runtime rejects every sandbox config when a managed
sandboxpolicy existsI dug deeper. The resume failure is not caused by specific fields of the config VS Code sends (
allowedHosts, session-datareadonlyPaths, …). The runtime rejects anysandboxConfigupdate once a managedsandboxpolicy is present, including one that is identical to the policy.Environment: VS Code 1.146.0 (
69047191fc4), bundled@github/copilot-sdk1.0.30-preview.0 / runtime 1.0.108-0, Linux arm64 dev container, file-based managed settings in/etc/github-copilot/managed-settings.json(source=mdmin the runtime log):{ "sandbox": { "userPolicy": { "network": { "allowLocalNetwork": true, "allowedHosts": ["github.com", "registry.npmjs.org", "…18 hosts"] }, "filesystem": { "readonlyPaths": ["/workspaces/frontend/.github", "…5 paths"] } } } }Repro: a standalone script using the bundled SDK:
new CopilotClient(), thencreateSession({ workingDirectory, enableManagedSettings: true }), thensession.rpc.options.update({ sandboxConfig }):sandboxConfigsent{ enabled: true }managed_sandbox_policy_conflict{ enabled: false }managed_sandbox_policy_conflictenabled: true+ auth/MCP/LSP flags, nouserPolicymanaged_sandbox_policy_conflictuserPolicy.networkwith exactly the managedallowedHostsmanaged_sandbox_policy_conflictuserPolicy.network+filesystem.readonlyPathsexactly equal to the managed policymanaged_sandbox_policy_conflictreadonlyPaths, no hosts)managed_sandbox_policy_conflictenableManagedSettingsWhy this breaks resume completely:
applyLaunchSandbox(session, isResume=true)deliberately treats a policy conflict as fatal (rejectPolicyConflicts) and disconnects the session. The intent is reasonable: fail closed if the managed policy changed since the chat was created.sandboxpolicy is active. New chats only work because the same conflict is downgraded to a warning on create ("continuing with the runtime's existing sandbox configuration").Conflicting chat storage identity: ahp-chat:/…, because a new session is created under the old ID after the failed restore.Workaround verified: changing the resume call to
rejectPolicyConflicts = (selection !== undefined)(i.e. droppingisResume) makes old chats resumable again. The runtime keeps enforcing the managed policy: in a resumed chat with sandboxing on, non-allowlisted hosts are still blocked and allowlisted hosts work.Suggested fix (either side):
sandboxConfigSourcevalues likerepository_policy.Also note: because of the same blanket rejection, VS Code's own sandbox settings (e.g.
chat.agent.sandbox.network.allowedDomains) are never applied under a managed policy, not even for new chats. Only the managed policy is effective. This is fine security-wise, but it means e.g. MCP servers whose hosts are not in the managed list fail with "sandbox network host rules deny this destination".