feat: Implement custom agent selection for agent-host sessions#314334
Draft
DonJayamanne wants to merge 6 commits intomainfrom
Draft
feat: Implement custom agent selection for agent-host sessions#314334DonJayamanne wants to merge 6 commits intomainfrom
DonJayamanne wants to merge 6 commits intomainfrom
Conversation
Contributor
DonJayamanne
commented
May 5, 2026
- Added support for selecting and changing custom agents in the CopilotAgent class.
- Introduced methods to resolve and store agent selections, including persistence in session metadata.
- Enhanced the CopilotAgentSession to handle agent selection changes and communicate with the SDK.
- Created a new AgentHostAgentPicker component for a user-friendly interface to select agents.
- Updated sessions provider interface to include methods for setting and clearing agent selections.
- Integrated agent selection into the session handling logic, ensuring proper state management and updates.
- Added necessary UI elements and actions to facilitate agent selection in both new and running sessions.
- Added support for selecting and changing custom agents in the CopilotAgent class. - Introduced methods to resolve and store agent selections, including persistence in session metadata. - Enhanced the CopilotAgentSession to handle agent selection changes and communicate with the SDK. - Created a new AgentHostAgentPicker component for a user-friendly interface to select agents. - Updated sessions provider interface to include methods for setting and clearing agent selections. - Integrated agent selection into the session handling logic, ensuring proper state management and updates. - Added necessary UI elements and actions to facilitate agent selection in both new and running sessions.
Contributor
Screenshot ChangesBase: Changed (7)Errored (18)Fixtures that failed to render — no screenshot was produced.
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds end-to-end support for selecting a custom agent per agent-host session: a new UI picker in the Sessions window drives a new session/agentChanged protocol action, which is persisted in session metadata and applied to the Copilot SDK session (select/deselect) when sessions are created/resumed or changed live.
Changes:
- Introduces
SessionAgentChangedas a client-dispatchable protocol action and plumbsSessionSummary.agentthrough state/reducers/export surfaces. - Adds persistence + runtime application of agent selection in the Copilot agent provider (
CopilotAgent/CopilotAgentSession), including provisional-session handling. - Adds a Sessions window UI picker (
AgentHostAgentPicker) and provider API (ISessionsProvider.setAgent) to set/clear the session’s selected agent.
Show a summary per file
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionHandler.ts | Dispatches SessionAgentChanged based on request modeInstructions and adds helpers to derive/compare agent selection. |
| src/vs/sessions/services/sessions/common/sessionsProvider.ts | Extends provider interface with optional setAgent(sessionId, agentId) API. |
| src/vs/sessions/contrib/remoteAgentHost/browser/remoteAgentHost.contribution.ts | Wires up the new agent picker contribution import for the Sessions window. |
| src/vs/sessions/contrib/chat/browser/agentHost/agentHostAgentPicker.ts | New UI picker for selecting a custom agent and dispatching setAgent to the active sessions provider. |
| src/vs/sessions/contrib/agentHost/browser/baseAgentHostSessionsProvider.ts | Tracks agent selection on sessions/new-sessions, dispatches SessionAgentChanged, and passes agent selection via modeInstructions on initial send. |
| src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts | Adds setAgent() that selects/deselects a custom agent via the Copilot SDK RPC surface. |
| src/vs/platform/agentHost/node/copilot/copilotAgent.ts | Resolves stored selection (URI) to SDK agent name, persists selection in metadata, applies selection on create/resume, and handles live changeAgent. |
| src/vs/platform/agentHost/node/agentSideEffects.ts | Handles SessionAgentChanged by invoking the provider’s optional changeAgent. |
| src/vs/platform/agentHost/common/state/sessionState.ts | Re-exports AgentSelection from the protocol state module. |
| src/vs/platform/agentHost/common/state/sessionActions.ts | Re-exports SessionAgentChangedAction. |
| src/vs/platform/agentHost/common/state/protocol/version/registry.ts | Adds SessionAgentChanged to the action→introduced-in map. |
| src/vs/platform/agentHost/common/state/protocol/state.ts | Adds AgentSelection + SessionSummary.agent (and also includes a large message-attachment redesign). |
| src/vs/platform/agentHost/common/state/protocol/reducers.ts | Updates session reducer to persist summary.agent on SessionAgentChanged. |
| src/vs/platform/agentHost/common/state/protocol/commands.ts | Updates protocol command types to include AgentSelection (and adds new completions-related surface). |
| src/vs/platform/agentHost/common/state/protocol/actions.ts | Defines ActionType.SessionAgentChanged and SessionAgentChangedAction. |
| src/vs/platform/agentHost/common/state/protocol/action-origin.generated.ts | Marks SessionAgentChanged as client-dispatchable and updates unions. |
| src/vs/platform/agentHost/common/state/protocol/.ahp-version | Bumps synced agent-host-protocol version hash. |
| src/vs/platform/agentHost/common/agentService.ts | Adds agent?: AgentSelection to metadata/config and optional IAgent.changeAgent. |
Copilot's findings
- Files reviewed: 18/18 changed files
- Comments generated: 7
| Resource = 'resource', | ||
| } | ||
|
|
||
| /** |
| @@ -1 +1 @@ | |||
| 4551ca9 | |||
| 06213ff | |||
Comment on lines
+123
to
+131
| for (const eventType of [dom.EventType.MOUSE_DOWN, TouchEventType.Tap]) { | ||
| this._renderDisposables.add(dom.addDisposableListener(trigger, eventType, e => { | ||
| if (dom.isMouseEvent(e) && e.button !== 0) { | ||
| return; | ||
| } | ||
| dom.EventHelper.stop(e, true); | ||
| this._showPicker(); | ||
| })); | ||
| } |
| private _select(session: ISession, item: IAgentPickerItem): void { | ||
| const provider = this._sessionsProvidersService.getProviders().find(p => p.id === session.providerId); | ||
| provider?.setAgent?.(session.sessionId, item.id); | ||
| this._storageService.store(STORAGE_KEY, item.id?.toString() ?? '', StorageScope.PROFILE, StorageTarget.MACHINE); |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.