Skip to content

Fix sandbox state reconciliation when resuming Copilot sessions - #343654

Merged
Dileep Yavanmandha (dileepyavan) merged 10 commits into
mainfrom
DileepY/sandbox-resume-fix
Oct 29, 2026
Merged

Dileep Yavanmandha (dileepyavan) merged 10 commits into
mainfrom
DileepY/sandbox-resume-fix

Conversation

@dileepyavan

@dileepyavan Dileep Yavanmandha (dileepyavan) commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Summary

Fix sandbox state reconciliation when resuming Copilot sessions:

  • Restore a chat's confirmed sandbox opt-out through the runtime session command when current managed policy allows bypass. Missing confirmation does not authorize bypass, and current policy remains authoritative.
  • Publish successfully applied sandbox state and reconcile a conflicting saved off selection for the affected chat only, without overwriting newer selections or changing sibling chats.
  • Give new pending bypass requests precedence over previously confirmed state.
  • Fail resume finalization and disconnect the unattached SDK session when managed policy rejects the sandbox update or the bypass command is rejected.
  • Add regression coverage and update the agent-host architecture documentation.

Validation

Validation after merging the fetched origin/main on October 28, 2026:

  • npm run build-fast -- --client-only: passed.
  • npm run eslint -- src/vs/platform/agentHost/test/node/sessionSandbox.test.ts src/vs/platform/agentHost/test/node/copilotSessionLauncher.test.ts: passed.
  • npm run test-node -- --run src\vs\platform\agentHost\test\node\sessionSandbox.test.ts --run src\vs\platform\agentHost\test\node\copilotSessionLauncher.test.ts --run src\vs\platform\agentHost\test\node\copilotAgentSession.test.ts --reporter dot: passed, 1,736 tests.
  • .\scripts\test.bat --run src\vs\platform\agentHost\test\node\sessionSandbox.test.ts --run src\vs\platform\agentHost\test\node\copilotSessionLauncher.test.ts --run src\vs\platform\agentHost\test\node\copilotAgentSession.test.ts --reporter dot: blocked before running tests by EPERM replacing the Electron executable; the Node runner above passed.
  • $files = @(git diff --name-only origin/main HEAD); node --experimental-strip-types build\hygiene.ts @files: passed, 14 eligible files checked from 16 requested paths.
  • git diff --cached --check before the merge commit and git diff origin/DileepY/sandbox-resume-fix..HEAD --check before pushing: passed.
  • Full type-check, integration tests, and live provider scenarios were not run.

Base Branch Status

Fetched origin and merged origin/main at 5be653c66d6b2b47c068e2b0a40df3db66dc8b3f. Resolved import conflicts in two sandbox test files, retaining both branches' imports. Merge commit: e1942b84ee0. The pre-existing test-call updates were preserved in separate commit c3d8cc5be84.

Related Issue

Fixes #344903
Fixes #343371

Copilot AI balanced review requested due to automatic review settings October 23, 2026 00:08

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.

🔵 Needs a closer look

Security-sensitive resume authorization needs human validation, and a concurrent-update reconciliation defect remains unresolved.

1 open issue
What changed in this PR

This PR corrects sandbox-state reconciliation when Copilot sessions resume in the Agent Host, separating prior attachment state from authorization for the resumed runtime.

Changes:

  • Resolve resume-time sandbox configuration without reusing previous bypass authorization.
  • Reconcile saved selections after successful updates, preserve pending bypass requests, and fail resume on managed-policy conflicts.
  • Add regression coverage and document the resume behavior.
File Description
src/​vs/​platform/​agentHost/​test/​node/​sessionSandbox.test.ts Tests resolution without prior bypass authorization.
src/​vs/​platform/​agentHost/​test/​node/​copilotSessionLauncher.test.ts Covers resume reconciliation, concurrent selections, bypass requests, and failures.
src/​vs/​platform/​agentHost/​test/​node/​copilotAgentSession.test.ts Updates launch calls for the resume flag.
src/​vs/​platform/​agentHost/​node/​sessionSandbox.ts Allows resolution to ignore applied state.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotSessionSandbox.ts Implements resume-aware application and selection reconciliation.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotSessionLauncher.ts Passes resume context into sandbox initialization.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotAgentSession.ts Forwards resume context to sandbox handling.
src/​vs/​platform/​agentHost/​AGENTS.md Documents reconciliation and failure behavior.

Review effort: Balanced

this._configurationService.setChatSandboxEnabled(target, sandboxConfig.enabled);
if (isResume && requestedSelection === undefined && sandboxConfig.enabled
&& values?.[SessionConfigKey.SandboxEnabled] === 'off'
&& this._configurationService.getChatConfigValues(writeTarget) === values) {
Preserve confirmed sandbox state, deduplicate conflict notifications, and cover background reporting and recovery.

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

Copy link
Copy Markdown
Member Author

Copilot resolve the merge conflicts in this pull request

Copilot AI commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Copilot resolve the merge conflicts in this pull request

Resolved the conflicts and merged current main in commit 53da12f. The build and tests could not run to completion because the local SDK dependency is mismatched and Electron’s sandbox helper is not configured; ESLint passed.

Restore confirmed sandbox opt-outs through the runtime session command when current policy allows bypass. Keep policy enforcement, newer selections, and rejection handling authoritative.

Co-authored-by: Copilot <[email protected]>
Resolve sandbox test import conflicts while retaining both branches' coverage.

Co-authored-by: Copilot <[email protected]>
Observe changes to sandbox state rather than every session metadata event. Windows diagnostics also updates session metadata when sandboxing is disabled, unlike Linux and macOS.

Co-authored-by: Copilot <[email protected]>
@dileepyavan
Dileep Yavanmandha (dileepyavan) marked this pull request as ready for review October 29, 2026 06:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

5 participants