Skip to content

agenthost: customization syncing data flow - #305372

Merged
Connor Peet (connor4312) merged 13 commits into
mainfrom
connor4312/customizations
Mar 31, 2026
Merged

Connor Peet (connor4312) merged 13 commits into
mainfrom
connor4312/customizations

Conversation

@connor4312

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings March 27, 2026 01:25
@vs-code-engineering vs-code-engineering Bot added this to the Backlog milestone Mar 27, 2026

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.

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 AgentPluginManager service to sync/copy customization plugin directories to {userData}/agentPlugins with 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

  • setCustomizationEnabled currently 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 _pluginDirs accordingly 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

  • _keyForUri derives 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-URI SequencerByKey guarantees (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

  • _persistCache only writes entries that have a cached nonce. Since ICustomizationRef.nonce is 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

  • sendMessage adds the session ID to _activeTurns before awaiting async work, but it’s only removed on onIdle/dispose/shutdown. If _resumeSession or session.send() throws, the session ID will remain in _activeTurns and can permanently defer plugin restarts. Consider using a try/finally (or removing the ID on failure and/or in onSessionError) so _activeTurns can’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

  • arraysEqual duplicates vs/base/common/arrays.equals. Consider reusing the shared helper to avoid custom comparison code and keep behavior consistent (e.g. handling undefined inputs 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;
}

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.

Pull request overview

Copilot reviewed 50 out of 50 changed files in this pull request and generated 7 comments.

@connor4312
Connor Peet (connor4312) marked this pull request as ready for review March 31, 2026 22:48
@connor4312
Connor Peet (connor4312) merged commit 231f8d7 into main Mar 31, 2026
18 checks passed
@connor4312
Connor Peet (connor4312) deleted the connor4312/customizations branch March 31, 2026 23:09
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators May 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants