feat: Add custom agent selection functionality to agent host sessions#314315
Closed
DonJayamanne wants to merge 1 commit intomainfrom
Closed
feat: Add custom agent selection functionality to agent host sessions#314315DonJayamanne wants to merge 1 commit intomainfrom
DonJayamanne wants to merge 1 commit intomainfrom
Conversation
- Introduced `AgentSelection` type to manage custom agent selections. - Implemented `changeAgent` method in `CopilotAgent` to handle agent changes. - Enhanced `CopilotAgentSession` to set and clear custom agents. - Updated session metadata storage to include agent information. - Created `AgentHostAgentPicker` for selecting custom agents in chat sessions. - Integrated agent selection into session handling logic, ensuring proper dispatch of changes. - Modified session interfaces and providers to support agent ID management. - Added UI elements for agent selection in both new and running sessions.
Contributor
Screenshot ChangesBase: Changed (10)Errored (18)Fixtures that failed to render — no screenshot was produced.
|
Contributor
There was a problem hiding this comment.
Pull request overview
Adds custom-agent selection support to agent-host chat sessions so session state, provider plumbing, protocol state, and Copilot-backed execution can track a selected customization-derived agent.
Changes:
- Adds
AgentSelectionto the agent-host protocol/state model and wires a newSessionAgentChangedaction through reducers, exports, and side effects. - Extends agent-host session/provider plumbing to store, expose, and mutate a selected custom agent for new and existing sessions.
- Introduces a new agent picker UI in the Sessions chat surfaces and persists agent metadata in the Copilot-backed agent implementation.
Show a summary per file
| File | Description |
|---|---|
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionHandler.ts |
Derives agent selection from request mode instructions and dispatches SessionAgentChanged during turn handling. |
src/vs/sessions/services/sessions/common/sessionsProvider.ts |
Adds optional setAgent provider API. |
src/vs/sessions/services/sessions/common/session.ts |
Extends session/chat interfaces with observable agentId. |
src/vs/sessions/contrib/remoteAgentHost/browser/remoteAgentHost.contribution.ts |
Registers the new agent picker contribution. |
src/vs/sessions/contrib/chat/browser/agentHost/agentHostAgentPicker.ts |
Adds the custom-agent picker UI and menu/action registrations. |
src/vs/sessions/contrib/agentHost/browser/baseAgentHostSessionsProvider.ts |
Tracks selected agent on new/live sessions and dispatches agent-change actions. |
src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts |
Adds SDK-facing agent select/deselect calls on a live Copilot session. |
src/vs/platform/agentHost/node/copilot/copilotAgent.ts |
Persists/restores selected agent metadata and resolves URI selections to SDK agent names. |
src/vs/platform/agentHost/node/agentSideEffects.ts |
Routes SessionAgentChanged actions to agent providers. |
src/vs/platform/agentHost/common/state/sessionState.ts |
Re-exports AgentSelection from protocol state. |
src/vs/platform/agentHost/common/state/sessionActions.ts |
Re-exports SessionAgentChangedAction. |
src/vs/platform/agentHost/common/state/protocol/version/registry.ts |
Registers version metadata for the new action type. |
src/vs/platform/agentHost/common/state/protocol/state.ts |
Defines AgentSelection and adds it to SessionSummary. |
src/vs/platform/agentHost/common/state/protocol/reducers.ts |
Updates session reducer to persist selected agent in summary state. |
src/vs/platform/agentHost/common/state/protocol/commands.ts |
Extends create-session protocol params with agent selection. |
src/vs/platform/agentHost/common/state/protocol/actions.ts |
Defines SessionAgentChanged and its payload shape. |
src/vs/platform/agentHost/common/state/protocol/action-origin.generated.ts |
Marks the new action as a session/client-dispatchable action. |
src/vs/platform/agentHost/common/agentService.ts |
Extends shared agent/session interfaces with agent selection support. |
Copilot's findings
Comments suppressed due to low confidence (2)
src/vs/sessions/contrib/chat/browser/agentHost/agentHostAgentPicker.ts:342
- This new-session contribution is not gated out on phone layout. The existing mode/model controls are explicitly hidden on phone because
mobileChatInputConfigPickerowns that surface (agentHostSessionConfigPicker.ts:798-804,agentHostModelPicker.ts:43-47), so adding the desktop picker here will render an extra desktop-style control in the mobile toolbar instead of following the established bottom-sheet flow.
menu: [{
id: Menus.NewSessionConfig,
group: 'navigation',
order: -1,
when: IsActiveSessionAgentHost,
}],
src/vs/sessions/contrib/chat/browser/agentHost/agentHostAgentPicker.ts:360
- This adds a new interactive picker to the chat input/new-session toolbar, but the existing
SessionsChatAccessibilityHelptext is not updated to mention it. Screen-reader users rely on that help dialog to discover newly added controls, so the new agent-selection workflow is currently undocumented from the accessibility surface.
registerAction2(class extends Action2 {
constructor() {
super({
id: PICKER_ACTION_ID,
title: nls.localize2('agentHostAgentPicker', "Agent"),
f1: false,
menu: [{
id: Menus.NewSessionConfig,
group: 'navigation',
order: -1,
when: IsActiveSessionAgentHost,
}],
});
}
override async run(): Promise<void> { /* handled by action view item */ }
});
registerAction2(class extends Action2 {
constructor() {
super({
id: RUNNING_SESSION_PICKER_ACTION_ID,
title: nls.localize2('agentHostRunningSessionAgentPicker', "Agent"),
f1: false,
menu: [{
id: MenuId.ChatInput,
group: 'navigation',
order: 1,
when: ChatContextKeyExprs.isAgentHostSession,
}],
});
- Files reviewed: 18/18 changed files
- Comments generated: 3
Comment on lines
1347
to
+1363
| @@ -1306,6 +1359,9 @@ export abstract class BaseAgentHostSessionsProvider extends Disposable implement | |||
| if (this._newSession === newSession) { | |||
| this._newSession = undefined; | |||
| } | |||
| if (selectedAgentId !== undefined) { | |||
| this.setAgent(committedSession.sessionId, selectedAgentId); | |||
Comment on lines
+314
to
+317
| 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); |
| provider?: string; | ||
| /** Model selection (ID and optional model-specific configuration) */ | ||
| model?: ModelSelection; | ||
| /** Custom agent selection (name) — selects a customization-pipeline agent for this session */ |
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.
AgentSelectiontype to manage custom agent selections.changeAgentmethod inCopilotAgentto handle agent changes.CopilotAgentSessionto set and clear custom agents.AgentHostAgentPickerfor selecting custom agents in chat sessions.