Skip to content

feat: Enhance agent host session management with custom agent support - #317398

Merged
Don Jayamanne (DonJayamanne) merged 13 commits into
mainfrom
don/theoretical-alligator
May 21, 2026
Merged

Don Jayamanne (DonJayamanne) merged 13 commits into
mainfrom
don/theoretical-alligator

Conversation

@DonJayamanne

@DonJayamanne Don Jayamanne (DonJayamanne) commented May 19, 2026 •

Copy link
Copy Markdown
Contributor
  • 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.

For #316169

Copilot AI review requested due to automatic review settings May 19, 2026 21:45

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–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, agent on SessionSummary, 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

Comment thread src/vs/sessions/contrib/providers/agentHost/browser/agentHostAgents.ts Outdated
Comment thread src/vs/platform/agentHost/node/copilot/copilotPluginConverters.ts
Comment thread src/vs/platform/agentHost/node/copilot/copilotAgent.ts Outdated
@DonJayamanne
Don Jayamanne (DonJayamanne) marked this pull request as ready for review May 20, 2026 00:48
@vs-code-engineering

vs-code-engineering Bot commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

Ladislau Szomoru (@lszomoru)

Matched files:

  • src/vs/sessions/services/sessions/browser/sessionsManagementService.ts
  • src/vs/sessions/services/sessions/common/session.ts
  • src/vs/sessions/services/sessions/common/sessionsProvider.ts

@roblourens roblourens left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should land the AHP PR first

Comment thread src/vs/sessions/services/sessions/common/session.ts Outdated
@connor4312

Copy link
Copy Markdown
Member

Implementation looks generally OK to me

- 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>
@DonJayamanne
Don Jayamanne (DonJayamanne) dismissed stale reviews from Sandeep Somavarapu (sandy081) and roblourens May 21, 2026 00:50

Resolved the feedback

@DonJayamanne
Don Jayamanne (DonJayamanne) merged commit 35d33ab into main May 21, 2026
25 checks passed
@DonJayamanne
Don Jayamanne (DonJayamanne) deleted the don/theoretical-alligator branch May 21, 2026 00:50
@vs-code-engineering vs-code-engineering Bot added this to the 1.122.0 milestone May 21, 2026
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Jul 5, 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.

6 participants