Repository navigation
[cherry-pick] agentHost: bind SDK customization operations to the verified policy session - #342629
Merged
Merged
Conversation
…ified policy session
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No blocking issues remain; focused regression coverage supports the change, and the reported test failure also occurs on unmodified main.
No open issues 🎉
What changed in this PR
Cherry-picks #342613 to fix customization marketplace failures by using the verified hidden policy session, even while a chat is open.
Changes:
- Routes SDK customization operations through the hidden session.
- Rejects pending SDK operations when their policy session is replaced.
- Updates regression tests and lifecycle documentation.
| File | Description |
|---|---|
src/vs/sessions/AI_CUSTOMIZATIONS.md |
Documents hidden-session binding and invalidation. |
src/vs/platform/agentHost/test/node/copilotCustomizationInstallations.test.ts |
Tests session reuse and stale-operation rejection. |
src/vs/platform/agentHost/test/node/copilotAgent.test.ts |
Tests verified hidden-session inventory with a live chat. |
src/vs/platform/agentHost/node/copilot/customizations/copilotCustomizationInstallations.ts |
Enforces hidden-session binding and validates pending operations. |
src/vs/platform/agentHost/node/copilot/copilotAgent.ts |
Removes visible-chat routing from customization calls. |
Review effort: Balanced
Vritant Bhardwaj (vritant24)
approved these changes
Oct 19, 2026
Vritant Bhardwaj (vritant24)
enabled auto-merge
October 19, 2026 18:36
Dmitriy Vasyura (dmitrivMS)
approved these changes
Oct 19, 2026
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.
Cherry-pick of #342613 from
main.Problem
While a Copilot chat is open, the customization marketplace can't load installation receipts. The renderer logs this many times per second:
Root cause
CopilotCustomizationInstallationsused the open chat's SDK session aspolicySessionIdforlist,recover,search, and install/uninstall planning. It used the hidden policy session only when no chat was open.The Copilot runtime admits installation and inventory requests only when the policy session's GitHub credential is verified: a github.com login backed by a resolved Copilot user record (
mcp_installationauthority()→installation_account_fingerprint()). A credential passed atcreateSession(gitHubToken/gitHubTokenProvider) is never verified. Onlysession.rpc.gitHubAuth.setCredentialsverifies it. A standalone SDK repro against runtimes 1.0.92-0 through 1.0.100-1 showedrefused: policy-context-unavailablewith the createSession token, even after a chat turn, andlistedright aftersetCredentialson the same session.#341648 added
setCredentialsto the hidden policy session. Chat sessions get it only when the token changes while they're live. Chats created after the last token change, and provider-backed chats, are never verified.Fix
Search, inventory, recovery, and install/uninstall planning now always use the hidden policy session (
getOrCreatePolicySessionId). None of these operations needs the chat's identity:installationConfirmationHandlermatches on thepolicySessionIdthat planned the operation. Plan and apply now always use the same hidden session, so matching is unchanged.policySessionId. They're now invalidated when the hidden session is replaced (auth change, client restart, idle disposal) rather than when you switch chats. The existing re-search recovery path handles that.The visible-session getter and the no-factory path are removed. That path produced "Start a Copilot agent session before managing SDK installations." and
unavailable: session. The only production caller (CopilotAgent) always provides the hidden-session factory, so only tests could reach it. The factory is now required.releasePolicySessionand the 10-minute idle disposal are unchanged.AI_CUSTOMIZATIONS.mdis updated.Tests
copilotCustomizationInstallations.test.ts: tests that relied on a fixed chat session ID now use aTestPolicySessionshelper that records created sessions. A new test checks that search, list, recover, and prepare all bind to one hidden session.copilotAgent.test.ts: a new test opens a live chat and checks thatlistCustomizationInstallationsgoes to the hidden session, which receivedsetCredentials, and not to the chat's session.Validation
npm run typecheck-client: passednpm run eslint -- <changed files>: passed./scripts/test.sh --run src/vs/platform/agentHost/test/node/copilotCustomizationInstallations.test.ts --run src/vs/platform/agentHost/test/node/copilotSessionLauncher.test.ts --run src/vs/platform/agentHost/test/node/copilotAgent.test.ts: 1012 passing, 1 pending, 1 failing. The failure isisolates peer runtimes, preserves local adoption identity and refuses revoked prepared work, which also fails on unmodifiedmain(e1a22a1ad40).