Repository navigation
agentHost: scope client customizations to session working directories - #330378
Merged
Connor Peet (connor4312) merged 1 commit intoAug 12, 2026
Merged
Conversation
The synthetic vscode-synced-customization plugin was keyed only by session type, so one bundle identity was shared by every session of a provider and resolved against whatever workspace folder happened to be ambient. In the Agents window the ambient folder is swapped on every active-session change, so switching sessions re-resolved and re-published customizations to every live session and leaked one repository's files into sessions running in another. Customization state is now keyed by the session's working-directory set. Scopes are refcounted and shared by sessions with identical roots, so each repository gets a stable bundle authority and nonce and the agent host's plugin cache stops re-materializing on every switch. Prompt enumeration takes an explicit root instead of reading the ambient workspace. Publishing is consolidated into a single debounced per-session reconciler, replacing four separate dispatch sites that each compared against not-yet-updated session state and produced redundant actions. Publishing is gated on the scope having resolved so a freshly acquired scope cannot transiently wipe the host's customizations, an identical payload is never re-sent, and undefined-valued keys are omitted from published payloads so a value round-tripped through the wire compares equal to the one that produced it.
Aaron Munger (amunger)
approved these changes
Aug 12, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Scopes agent-host customizations to each session’s working directories and consolidates active-client publishing.
Changes:
- Adds ref-counted, root-scoped customization bundles.
- Debounces and deduplicates active-client reconciliation.
- Extends prompt discovery and tests for explicit roots.
Show a summary per file
| File | Description |
|---|---|
promptsService.test.ts |
Tests explicit-root discovery. |
mockPromptsService.ts |
Updates mock API. |
resolveCustomizationRefs.test.ts |
Updates root-aware tests. |
enumerateLocalCustomizationsForHarness.test.ts |
Tests multi-root enumeration. |
agentHostUntitledProvisionalSessionService.test.ts |
Updates scoped-client mock. |
agentHostClientTools.test.ts |
Tests scope sharing. |
agentHostChatContribution.test.ts |
Tests reconciliation behavior. |
promptFilesLocator.ts |
Adds explicit-root resolution. |
promptsServiceImpl.ts |
Forwards optional roots. |
promptsService.ts |
Extends prompt service API. |
syncedCustomizationBundler.ts |
Uses URI-aware origin mapping. |
agentHostUntitledProvisionalSessionService.ts |
Adds provisional-session scopes. |
agentHostToolUtils.ts |
Omits undefined schemas. |
agentHostSessionHandler.ts |
Consolidates client publishing. |
agentHostLocalCustomizations.ts |
Enumerates scoped roots. |
agentHostChatContribution.ts |
Adds ambient management scope. |
agentHostActiveClientService.ts |
Implements scoped customization lifecycle. |
remoteAgentHostSessionsProvider.test.ts |
Updates remote scope mock. |
remoteAgentHost.contribution.ts |
Adds remote ambient scope. |
localAgentHostSessionsProvider.test.ts |
Tests resolution gating. |
baseAgentHostSessionsProvider.ts |
Scopes provider client state. |
Review details
Tip
Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Suppressed comments (1)
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostUntitledProvisionalSessionService.ts:745
- Updating the binding here can publish the new folder's customizations to the still-live old provisional backend.
_reconcileGenerationdeliberately leavesentry.generationpointing at the old session until a replacement is ready, whileActiveClientBindingcalls_publishActiveClient(entry)as soon as the new scope resolves; that method dispatches to the current (old-root) generation. This transiently recreates the cross-repository leak this change is intended to prevent. Keep the scope associated with each generation/backend URI and only switch the published binding atomically when the replacement generation is installed (the workspace-folder-change path has the same ordering issue).
this._updateActiveClientScope(entry);
- Files reviewed: 21/21 changed files
- Comments generated: 2
- Review effort level: Balanced
Comment on lines
+448
to
+449
| function createScopeAuthority(sessionType: string, roots: readonly URI[]): string { | ||
| return `${sessionType}-${hash(getScopeKey(roots))}`; |
| if (!entry.usesWorkspaceRootSet && (this._computeWorkingDirectories(entry.workingDirectory, entry.provider)?.length ?? 0) > 1) { | ||
| entry.usesWorkspaceRootSet = true; | ||
| } | ||
| this._updateActiveClientScope(entry); |
Connor Peet (connor4312)
deleted the
connor4312/agenthost-scoped-customizations
branch
August 12, 2026 03:17
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
The synthetic
vscode-synced-customizationplugin was keyed only by session type, so one bundle identity was shared by every session of a provider and resolved against whatever workspace folder happened to be ambient. In the Agents window the ambient folder is swapped on every active-session change, so switching sessions re-resolved and re-published customizations to every live session, and one repository's instructions, prompts, skills and workspace MCP servers leaked into sessions running in another. The agent host then re-materialized and re-bound plugins each time, and the nonce cache never hit because ping-ponging between two repos evicted each bundle in turn.What changed
Customizations are keyed by the session's working-directory set.
IAgentHostActiveClientServicehands out refcountedIAgentCustomizationScopes, shared between sessions with identical roots, each owning its own bundler with an authority derived from the normalized root set.IWorkspaceContextServiceis gone from the service.IPromptsService.listPromptFilesForStoragetakes an optional explicit root; omitted, it behaves exactly as before.Publishing is consolidated. Four separate
activeClientSetdispatch sites in the session handler became one debounced per-session reconciler, held in a self-containedActiveClientEntry. The claim/no-claim distinction is now explicit: the client publishes only where it is already an active client, or where it explicitly claimed the session at open.Publishing is gated on resolution. A freshly acquired scope reports an empty customization set until it resolves; publishing that would transiently wipe the host's state, so nothing publishes from an unresolved scope, and session creation waits for the pending publish to settle.
Verification
Validated against Agent Host log captures of the same flow (message a session, switch to a session in another repo, switch back):
Each repository resolves to its own authority and nonce, byte-stable across app restarts, with no re-materialization on return and no cross-repo content in either session.
A later capture caught a dispatch loop (344 identical actions in 8s) when a plugin was disabled, the UI switched, and the plugin re-enabled: an identical payload is now never re-sent, so a payload the server does not acknowledge costs one dispatch rather than spinning.
Notes
sessionTypederived so identical computations are not duplicated per scope.