Repository navigation
agentHost: keep credentials and isolation with a moved session's chat; refuse moves across credential owners - #342548
Merged
Sandeep Somavarapu (sandy081) merged 7 commits intoOct 19, 2026
Conversation
…s chat Moving a session under another one ends the source. Its credential binding (_credentialOwners) and the workspace-conversion isolation markers were still keyed to the source, so removing it dropped them for the moved chat. Both now follow onDidChangeChatOwner. Co-authored-by: Copilot <[email protected]>
Moving a chat or session between sessions whose credential principals differ (including sponsored and unsponsored) is refused with differentCredentialOwner before anything changes. Same-principal moves re-key the chat's credential binding to its new owner; a promoted chat's new session inherits its principal. Co-authored-by: Copilot <[email protected]>
A promoted session persists its inherited credential principal, so a restart never falls back to the ambient token. Sessions of a move or promotion are held so an unsponsored one can't gain a principal while the move commits. A chat that changes owner across different credential owners anyway loses its sponsored bindings and resolves under its new owner instead of throwing. Co-authored-by: Copilot <[email protected]>
… the promotion The new session's principal is part of the promote commit's values (a central session value restored through the state store), so a restart never falls back to the ambient token. The target is held during promotion, and a failed in-memory step moves the chat's credentials fail-closed. Co-authored-by: Copilot <[email protected]>
Sandeep Somavarapu (sandy081)
enabled auto-merge (squash)
October 19, 2026 13:50
Sandeep Somavarapu (sandy081)
marked this pull request as draft
October 19, 2026 13:53
auto-merge was automatically disabled
October 19, 2026 13:53
Pull request was converted to draft
…owngrade Restoring the principal now falls back to session.db when central state lacks it (sessions imported before the key was registered), and a promoted session's principal is also written to its session.db for older builds. Co-authored-by: Copilot <[email protected]>
Sandeep Somavarapu (sandy081)
marked this pull request as ready for review
October 19, 2026 13:55
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Upgrade restoration and promotion of unmapped peers can lose credential-owner enforcement and allow ambient credential fallback.
1 open issue
What changed in this PR
Preserves chat credentials and isolation during Agent Host moves, and rejects moves between different credential owners.
Changes:
- Transfers credential and isolation ownership with moved chats.
- Adds credential-owner validation and atomic principal persistence for promotions.
- Adds regression tests and documents move guarantees.
| File | Description |
|---|---|
src/vs/platform/agentHost/test/node/sessionWorkspaceConversion.test.ts |
Tests isolation retention after moves. |
src/vs/platform/agentHost/test/node/agentService.test.ts |
Tests credential transfer, refusals, promotion, and restart behavior. |
src/vs/platform/agentHost/node/chatContributions/sessionWorkspaceConversion/sessionWorkspaceConversionService.ts |
Preserves moved chats’ isolation state. |
src/vs/platform/agentHost/node/agentService.ts |
Integrates credential validation, transfer, and persistence. |
src/vs/platform/agentHost/node/agentHostSessionStateMirror.ts |
Registers the credential principal as central state. |
src/vs/platform/agentHost/node/agentHostAuthenticationService.ts |
Adds credential-owner comparison, holds, and transfer. |
src/vs/platform/agentHost/common/agentHostChatMove.ts |
Adds the credential-owner mismatch refusal. |
src/vs/platform/agentHost/AGENTS.md |
Documents credential guarantees for moves. |
Review effort: Balanced
Sandeep Somavarapu (sandy081)
marked this pull request as draft
October 19, 2026 14:17
…sion.db before the promotion commits The principal stays in session.db only, as older builds read it, instead of being a central session value. A promotion writes it to the new session's database before the commit, so a committed promotion always has it on disk and a failed write refuses the promotion with nothing changed. Co-authored-by: Copilot <[email protected]>
…owner Read the promoted principal from the source session and seed an unmapped chat's credential owner from the previous owner, so a restored sponsored session never falls back to the ambient token. Restoring an already persisted principal is no longer blocked by a move hold; only binding a new one is. Co-authored-by: Copilot <[email protected]>
Sandeep Somavarapu (sandy081)
marked this pull request as ready for review
October 19, 2026 14:53
Sandeep Somavarapu (sandy081)
enabled auto-merge (squash)
October 19, 2026 14:53
Ladislau Szomoru (lszomoru)
approved these changes
Oct 19, 2026
Sandeep Somavarapu (sandy081)
deleted the
agents/fix-vscode-move-session-bugs
branch
October 19, 2026 15:46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes two bugs in agent host session moves (
moveChat/moveSession), found while reviewing the "Move Chats" feature.AuthRequired. The binding now follows the chat on a recorded owner change (onDidChangeChatOwner).SessionWorkspaceConversionServicecleared the isolation markers of a moved main chat when the source ended. Removal now skips a chat that moved away.AgentChatMoveRefusal.DifferentCredentialOwner(differentCredentialOwner) in the shared validation, before anything changes. A promoted session inherits the chat's principal, written to the new session'ssession.dbbefore the promote commit (a failed write refuses the promote with nothing changed; a failed commit leaves a harmless orphansession.db). Unsponsored sessions can't gain a principal while a move into/out of them is committing. A mismatch that gets through anyway drops the chat's sponsored bindings and never falls back to the ambient token. An agentMerge-only binding counts as sponsored.Client mapping (not on main yet; branches adding refusal maps must map
differentCredentialOwner):How to test (all passed):
./scripts/test.sh --run src/vs/platform/agentHost/test/node/agentService.test.ts— 1185 passing, 16 pending./scripts/test.sh --run src/vs/platform/agentHost/test/node/sessionWorkspaceConversion.test.ts— 120 passing, 1 pending./scripts/test.sh --run src/vs/platform/agentHost/test/node/agentHostAuthenticationScope.test.ts— 22 passing./scripts/test.sh --run src/vs/platform/agentHost/test/node/agentHostSessionStateStore.test.ts— 80 passingnpm run typecheck-client— passednpm run eslint -- <changed files>and the commit hygiene hook — passedFail-first (each test run with its fix reverted, then restored):
AgentHostAuthenticationService … a chat without a recorded credential owner follows its session when it moves, and keeps the principal after the source is released— failed:AssertionError: Expected values to be strictly deep-equal: + principal: undefined, + target: undefined - principal: { apiOrigin: 'https://api.github.com', userId: '1' }credential owners … a persisted principal is restored for a session a move holds, while binding a new one is refused— failed:+ restored: 'undefined' - restored: 'allowed'(newrestorePersistedCredentialPrincipal)ambient).