Skip to content

Agent Host: resuming a Copilot CLI session fails when a managed sandbox policy restricts hosts/paths ("Sandbox configuration update violates managed policy") #349234

Open

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/copilot 1.0.108-0, @github/copilot-sdk 1.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:

  1. Configure a device-managed sandbox policy in /etc/github-copilot/managed-settings.json (resolved as source=mdm) that restricts network.allowedHosts (and optionally filesystem.readonlyPaths):

    {
      "sandbox": {
        "userPolicy": {
          "network": {
            "allowLocalNetwork": true,
            "allowedHosts": ["example.com", "*.example.org", "..."]
          },
          "filesystem": {
            "readonlyPaths": ["/workspaces/<project>/.git/hooks", "/workspaces/<project>/.vscode", "..."]
          }
        }
      }
    }
  2. 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_resolved arrives the policy is applied.

  3. 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 still undefined).
  • Without the policy, the config is built from host settings only:
    • allowedNetworkDomains: [] → no allowedHosts, i.e. all hosts allowed. This exceeds the managed host list.
    • readonlyPaths gets the session data directories (.../agentSessionData/<id>/attachments, shell-init directory) because t?.readonlyPaths === undefined. These paths are not in the managed readonlyPaths, which managed settings match by exact string.
  • The runtime rejects this. On create, _openWithSandboxConfig retries without the config and update errors are only logged. On resume, throwOnError is true, 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.js never sets sandboxConfigSource, so every config counts as an explicit choice and conflicts.
  • Putting the hosts into agent-host-config.json in the container does not persist: the values are reset from the client's chat.agent.sandbox.* settings on connect. chat.agent.sandbox.network.allowedDomains has application scope and cannot be set by the dev container or workspace.

Suggested fix (any of these)

  1. 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.
  2. On resume, wait for session.managed_settings_resolved before applyLaunchConfig, or build the config from the resolved policy.
  3. On resume, treat managed_sandbox_policy_conflict like the create path does: log it and continue with the runtime's existing sandbox configuration, instead of failing the restore.
  4. 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

  1. xeladotbe commented on Nov 19, 2026

    @xeladotbe
    Author

    Additional findings: the runtime rejects every sandbox config when a managed sandbox policy exists

    I dug deeper. The resume failure is not caused by specific fields of the config VS Code sends (allowedHosts, session-data readonlyPaths, …). The runtime rejects any sandboxConfig update once a managed sandbox policy is present, including one that is identical to the policy.

    Environment: VS Code 1.146.0 (69047191fc4), bundled @github/copilot-sdk 1.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=mdm in 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(), then createSession({ workingDirectory, enableManagedSettings: true }), then session.rpc.options.update({ sandboxConfig }):

    sandboxConfig sent Result
    { enabled: true } managed_sandbox_policy_conflict
    { enabled: false } managed_sandbox_policy_conflict
    enabled: true + auth/MCP/LSP flags, no userPolicy managed_sandbox_policy_conflict
    userPolicy.network with exactly the managed allowedHosts managed_sandbox_policy_conflict
    userPolicy.network + filesystem.readonlyPaths exactly equal to the managed policy managed_sandbox_policy_conflict
    config VS Code computes on resume (session-data dirs as readonlyPaths, no hosts) managed_sandbox_policy_conflict
    any of the above without enableManagedSettings accepted

    Why this breaks resume completely:

    1. Since Fix sandbox state reconciliation when resuming Copilot sessions #343654, 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.
    2. Because the runtime reports a conflict for every config, this is not an edge case. No chat can ever be resumed while a managed sandbox policy 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").
    3. Follow-up error in the UI: 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. dropping isResume) 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):

    • Runtime: accept updates that are equal to or stricter than the managed floor (as the schema description says: "composes with the user's value in the safe direction"), and only reject actual loosening. Alternatively, floor the config instead of rejecting it, as already happens for sandboxConfigSource values like repository_policy.
    • VS Code: on resume, distinguish "policy got stricter than the stored chat state" from "runtime rejects sandbox updates under managed policy". In the latter case, behave like create: continue with the runtime's enforced config and report the conflict.

    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".

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

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions