feat: Enhance agent host session management with custom agent support - #317398
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the Agent Host–backed sessions stack (protocol → agent host implementation → sessions provider adapters → sessions UI) to support selecting a custom agent per session, including persistence/fallback behavior and surfacing an Agent picker in the Sessions UI.
Changes:
- Added protocol + metadata plumb‑through for session-level custom agent selection (
SessionAgentChanged,agentonSessionSummary,CreateSessionParams.agent). - Extended sessions-layer APIs/providers to expose and set per-session custom agents (
ISessionAgentRef,ISessionsProvider.setAgent?,IAgentHostSessionsProvider.getCustomAgents+ change event). - Implemented custom agent discovery/advertisement from plugins (YAML frontmatter support) and added UI/tests for effective-agent resolution and picker behavior.
Show a summary per file
| File | Description |
|---|---|
| src/vs/sessions/services/sessions/common/sessionsProvider.ts | Adds optional setAgent hook for providers to set/clear a session’s custom agent. |
| src/vs/sessions/services/sessions/common/session.ts | Introduces ISessionAgentRef and adds optional agent observables to ISession/IChat. |
| src/vs/sessions/services/sessions/browser/sessionsManagementService.ts | Exposes agent on the active session wrapper. |
| src/vs/sessions/contrib/providers/remoteAgentHost/browser/remoteAgentHost.contribution.ts | Wires in the Agent picker contribution for remote agent hosts. |
| src/vs/sessions/contrib/providers/agentHost/test/browser/localAgentHostSessionsProvider.test.ts | Adds tests for setAgent, custom agent merging, and change events. |
| src/vs/sessions/contrib/providers/agentHost/test/browser/agentHostAgents.test.ts | Adds unit tests for effective-agent merging/deduping/sorting. |
| src/vs/sessions/contrib/providers/agentHost/test/browser/agentHostAgentPicker.test.ts | Adds unit tests for stored-vs-session agent resolution and storage key formation. |
| src/vs/sessions/contrib/providers/agentHost/browser/baseAgentHostSessionsProvider.ts | Implements setAgent, caches root/session state for agent merging, and exposes getCustomAgents + change event. |
| src/vs/sessions/contrib/providers/agentHost/browser/agentHostAgents.ts | New helper to compute the merged effective custom-agent list. |
| src/vs/sessions/contrib/providers/agentHost/browser/agentHostAgentPicker.ts | New UI contribution to render/persist an Agent picker and dispatch setAgent. |
| src/vs/sessions/common/agentHostSessionsProvider.ts | Extends IAgentHostSessionsProvider with getCustomAgents + onDidChangeCustomAgents. |
| src/vs/platform/agentPlugins/common/pluginParsers.ts | Adds agent frontmatter parsing for name/description via readAgentComponents. |
| src/vs/platform/agentHost/test/node/copilotPluginConverters.test.ts | Expands test coverage for agent frontmatter parsing and tool allow-list behavior. |
| src/vs/platform/agentHost/node/protocolServerHandler.ts | Passes agent through to createSession. |
| src/vs/platform/agentHost/node/copilot/copilotPluginConverters.ts | Parses agent frontmatter for SDK config and projects agents into protocol CustomizationAgentRef. |
| src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts | Adds SDK calls to select/deselect a custom agent on a live session. |
| src/vs/platform/agentHost/node/copilot/copilotAgent.ts | Persists agent selection in session metadata, includes it in create/resume paths, and advertises agents on customizations. |
| src/vs/platform/agentHost/node/agentSideEffects.ts | Applies SessionAgentChanged via agent.changeAgent side-effect hook. |
| src/vs/platform/agentHost/node/agentService.ts | Includes agent in created/listed session summary metadata. |
| src/vs/platform/agentHost/common/state/sessionState.ts | Re-exports new protocol types (AgentSelection, CustomizationAgentRef). |
| src/vs/platform/agentHost/common/state/sessionActions.ts | Re-exports new SessionAgentChangedAction type alias. |
| src/vs/platform/agentHost/common/state/protocol/version/registry.ts | Declares protocol introduction version for SessionAgentChanged. |
| src/vs/platform/agentHost/common/state/protocol/common/actions.ts | Adds ActionType.SessionAgentChanged to unions. |
| src/vs/platform/agentHost/common/state/protocol/channels-session/state.ts | Adds SessionSummary.agent, defines AgentSelection, and introduces CustomizationAgentRef + CustomizationRef.agents. |
| src/vs/platform/agentHost/common/state/protocol/channels-session/reducer.ts | Updates session reducer to apply SessionAgentChanged. |
| src/vs/platform/agentHost/common/state/protocol/channels-session/commands.ts | Adds CreateSessionParams.agent. |
| src/vs/platform/agentHost/common/state/protocol/channels-session/actions.ts | Defines SessionAgentChangedAction. |
| src/vs/platform/agentHost/common/state/protocol/action-origin.generated.ts | Updates generated unions/dispatchability map to include SessionAgentChanged. |
| src/vs/platform/agentHost/common/state/protocol/.ahp-version | Bumps protocol sync/version reference. |
| src/vs/platform/agentHost/common/agentService.ts | Extends common agent interfaces to carry/accept agent selection and changeAgent?. |
Copilot's findings
- Files reviewed: 30/30 changed files
- Comments generated: 4
Don Jayamanne (DonJayamanne)
requested review from
Connor Peet (connor4312) and
roblourens
and removed request for
Connor Peet (connor4312) and
roblourens
May 20, 2026 00:48
Don Jayamanne (DonJayamanne)
marked this pull request as ready for review
May 20, 2026 00:48
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: Ladislau Szomoru (@lszomoru)Matched files:
|
roblourens
previously requested changes
May 20, 2026
roblourens
left a comment
Member
There was a problem hiding this comment.
I think we should land the AHP PR first
Sandeep Somavarapu (sandy081)
previously requested changes
May 20, 2026
Member
|
Implementation looks generally OK to me |
Don Jayamanne (DonJayamanne)
force-pushed
the
don/theoretical-alligator
branch
from
May 20, 2026 22:24
fbc6581 to
77f7703
Compare
- Introduced ISessionAgentRef interface to represent custom agent references in session management. - Updated AgentHostSessionAdapter to handle agent selection and state updates. - Implemented setAgent method in BaseAgentHostSessionsProvider to manage agent changes and dispatch relevant actions. - Enhanced session-related interfaces and types to include agent properties. - Added tests for agent selection, effective agent resolution, and custom agent handling in various scenarios. - Integrated agent host agent picker into remote agent host contributions.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…ng plugin agent is found
Don Jayamanne (DonJayamanne)
force-pushed
the
don/theoretical-alligator
branch
from
May 20, 2026 23:40
4721b01 to
0c9c59e
Compare
…ion customizations
Don Jayamanne (DonJayamanne)
requested a review
from Sandeep Somavarapu (sandy081)
May 21, 2026 00:21
Don Jayamanne (DonJayamanne)
requested review from
Connor Peet (connor4312) and
roblourens
May 21, 2026 00:21
Don Jayamanne (DonJayamanne)
enabled auto-merge (squash)
May 21, 2026 00:21
Justin Chen (justschen)
approved these changes
May 21, 2026
Don Jayamanne (DonJayamanne)
dismissed stale reviews from Sandeep Somavarapu (sandy081) and roblourens
May 21, 2026 00:50
Resolved the feedback
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.
For #316169