Repository navigation
agenthost: customization syncing data flow - #305372
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the Agent Host protocol/state to support “customizations” (Open Plugins) and pending messages, and wires a new server-side customization sync path (including local caching) into the Copilot agent and side-effects layer.
Changes:
- Add protocol/state support for customizations + pending messages (actions, reducers, version registries, state types).
- Introduce an
AgentPluginManagerservice to sync/copy customization plugin directories to{userData}/agentPluginswith nonce caching + LRU eviction. - Add agent-side wiring for receiving client customizations (
session/activeClientChanged) and toggling them (session/customizationToggled), plus filesystem URI helpers/providers for client↔host file access.
Reviewed changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/vs/platform/agentHost/test/node/pluginStorage.test.ts | Placeholder indicating plugin storage tests moved. |
| src/vs/platform/agentHost/test/node/mockAgent.ts | Extend mock agent with customization APIs for new side-effect paths. |
| src/vs/platform/agentHost/test/node/agentSideEffects.test.ts | Add coverage for customization sync/toggle behavior and publishing agent customizations. |
| src/vs/platform/agentHost/test/node/agentPluginManager.test.ts | New unit tests for plugin sync, caching, concurrency, eviction, persistence. |
| src/vs/platform/agentHost/test/common/agentClientUri.test.ts | New tests for vscode-agent-client URI wrapping/unwrapping. |
| src/vs/platform/agentHost/node/copilot/copilotAgent.ts | Add customization sync integration and restart scheduling with --plugin-dir CLI args. |
| src/vs/platform/agentHost/node/agentSideEffects.ts | Dispatch customization sync on active-client changes and forward toggle events to agents. |
| src/vs/platform/agentHost/node/agentPluginManager.ts | New implementation for syncing/caching plugin directories on disk. |
| src/vs/platform/agentHost/node/agentHostServerMain.ts | Register IAgentPluginManager service in the standalone server DI container. |
| src/vs/platform/agentHost/node/agentHostMain.ts | Instantiate AgentPluginManager and pass into CopilotAgent for utility-process path. |
| src/vs/platform/agentHost/common/state/versions/versionRegistry.ts | Declare introduced-in versions for new action types. |
| src/vs/platform/agentHost/common/state/sessionState.ts | Re-export customization-related protocol types/enums. |
| src/vs/platform/agentHost/common/state/sessionActions.ts | Export new customization action types. |
| src/vs/platform/agentHost/common/state/protocol/version/registry.ts | Auto-generated protocol registry updated for new actions. |
| src/vs/platform/agentHost/common/state/protocol/state.ts | Auto-generated protocol state updated with icons, customizations, pending messages. |
| src/vs/platform/agentHost/common/state/protocol/reducers.ts | Reducer support for customizations and pending messages; enhance softAssertNever. |
| src/vs/platform/agentHost/common/state/protocol/notifications.ts | Auto-generated protocol header updated. |
| src/vs/platform/agentHost/common/state/protocol/messages.ts | Auto-generated protocol header updated. |
| src/vs/platform/agentHost/common/state/protocol/errors.ts | Auto-generated protocol header updated. |
| src/vs/platform/agentHost/common/state/protocol/commands.ts | Auto-generated protocol header updated (includes encoding for fetchContent). |
| src/vs/platform/agentHost/common/state/protocol/actions.ts | Auto-generated actions updated with customizations + pending message actions. |
| src/vs/platform/agentHost/common/state/protocol/action-origin.generated.ts | Auto-generated dispatchability/action unions updated. |
| src/vs/platform/agentHost/common/agentService.ts | Extend IAgent with optional customization methods. |
| src/vs/platform/agentHost/common/agentPluginManager.ts | New service interface + decorator for plugin syncing. |
| src/vs/platform/agentHost/common/agentHostFileSystemProvider.ts | Refactor into abstract base + add remote-connection abstraction (host-side FS). |
| src/vs/platform/agentHost/common/agentHostClientFileSystemProvider.ts | New inverse FS provider for agent host reading client-side files. |
| src/vs/platform/agentHost/common/agentClientUri.ts | New URI wrapper/unwrapper for client-side URIs addressable from agent host. |
Comments suppressed due to low confidence (5)
src/vs/platform/agentHost/node/copilot/copilotAgent.ts:142
setCustomizationEnabledcurrently only logs and schedules a restart, but it never updates the effective plugin directory list that gets passed to the CLI (and the method comment says it will “rebuild” it). As a result, toggling a customization won’t actually enable/disable anything in the restarted client. Track per-customization enabled state + pluginDir mapping from the last sync and rebuild_pluginDirsaccordingly before restarting.
setCustomizationEnabled(uri: string, enabled: boolean): void {
this._logService.info(`[Copilot] Customization toggled: ${uri} enabled=${enabled}`);
// A toggle requires a client restart with updated plugin dirs.
// Rebuild the effective plugin dirs from enabled customizations.
this._scheduleClientRestart();
}
src/vs/platform/agentHost/node/agentPluginManager.ts:133
_keyForUriderives the on-disk directory name by replacing non-alphanumerics with-and truncating to 128 chars. This can produce collisions for distinct URIs (e.g. differing only by punctuation or after the truncation point), which can clobber plugin contents and break the per-URISequencerByKeyguarantees (different URIs could write into the same dest dir concurrently). Use a collision-resistant key (e.g. hash of the full URI, possibly with a short human-readable prefix).
private _keyForUri(uri: string): string {
return uri.replace(/[^a-zA-Z0-9]/g, '-').replace(/-+/g, '-').replace(/^-|-$/g, '').substring(0, 128);
}
src/vs/platform/agentHost/node/agentPluginManager.ts:221
_persistCacheonly writes entries that have a cached nonce. SinceICustomizationRef.nonceis optional, plugins without a nonce won’t be persisted in_lruOrder, which means eviction state won’t survive restarts and the on-disk cache can grow beyond_maxPlugins. Consider persisting LRU entries even without a nonce (or reconstructing LRU from the on-disk directory listing on startup) so eviction remains effective after restarts.
// Write entries in LRU order (oldest first)
const entries: ICacheEntry[] = [];
for (const uri of this._lruOrder) {
const nonce = this._cachedNonces.get(uri);
if (nonce) {
entries.push({ uri: uri.toString(), nonce });
}
}
src/vs/platform/agentHost/node/copilot/copilotAgent.ts:318
sendMessageadds the session ID to_activeTurnsbefore awaiting async work, but it’s only removed ononIdle/dispose/shutdown. If_resumeSessionorsession.send()throws, the session ID will remain in_activeTurnsand can permanently defer plugin restarts. Consider using a try/finally (or removing the ID on failure and/or inonSessionError) so_activeTurnscan’t get stuck.
async sendMessage(session: URI, prompt: string, attachments?: IAgentAttachment[]): Promise<void> {
const sessionId = AgentSession.id(session);
this._activeTurns.add(sessionId);
this._logService.info(`[Copilot:${sessionId}] sendMessage called: "${prompt.substring(0, 100)}${prompt.length > 100 ? '...' : ''}" (${attachments?.length ?? 0} attachments)`);
const entry = this._sessions.get(sessionId) ?? await this._resumeSession(sessionId);
this._logService.info(`[Copilot:${sessionId}] Found session wrapper, calling session.send()...`);
src/vs/platform/agentHost/node/copilot/copilotAgent.ts:954
arraysEqualduplicatesvs/base/common/arrays.equals. Consider reusing the shared helper to avoid custom comparison code and keep behavior consistent (e.g. handlingundefinedinputs if needed later).
function arraysEqual(a: string[], b: string[]): boolean {
if (a.length !== b.length) {
return false;
}
for (let i = 0; i < a.length; i++) {
if (a[i] !== b[i]) {
return false;
}
}
return true;
}
Closed
Connor Peet (connor4312)
marked this pull request as ready for review
March 31, 2026 22:48
Michael Lively (Yoyokrazy)
approved these changes
Mar 31, 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 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.
No description provided.