Skip to content

agentHost: adopt channel-based AHP wire model#317251

Merged
connor4312 merged 6 commits into
mainfrom
connor4312/ah-channels
May 19, 2026
Merged

agentHost: adopt channel-based AHP wire model#317251
connor4312 merged 6 commits into
mainfrom
connor4312/ah-channels

Conversation

@connor4312
Copy link
Copy Markdown
Member

agentHost: adopt channel-based AHP wire model

Adopts the channel-based Agent Host Protocol revision from
microsoft/agent-host-protocol#127. Subscriptions, action delivery, and
protocol notifications now all route over named channels identified by a
top-level channel: URI field, replacing the pre-channels subscribe /
dispatch / notify model.

  • Renames ROOT_STATE_URI from agenthost:/root to ahp-root:// and
    adds an isAhpRootChannel helper that tolerates both the canonical
    wire form and the workbench URI round-tripped form (ahp-root:).
  • Threads a channel parameter through every action dispatch path:
    IAgentService.dispatchAction, IAgentConnection.dispatch,
    AgentHostStateManager.dispatchServerAction / dispatchClientAction,
    and AgentSubscriptionManager.dispatchOptimistic. Individual action
    payloads no longer carry session / terminal / changeset fields;
    the envelope carries the channel.
  • Replaces the { method: 'notification', params: { notification } }
    wrapper with top-level JSON-RPC methods (root/sessionAdded,
    root/sessionRemoved, root/sessionSummaryChanged, auth/required).
    Each notification's params now carry their own channel: URI field.
  • Renames the per-command identifying field to channel for the channel-
    scoped commands (createSession, disposeSession, createTerminal,
    disposeTerminal, fetchTurns, completions,
    invokeChangesetOperation). Connection-level commands hard-code the
    root channel string.
  • Updates the subscribe result to { snapshot? } and the
    SubscribeParams / UnsubscribeParams field name from resource to
    channel.
  • Drops the removed ProtocolNotification, NotificationType,
    NotificationMethodParams, and NotificationMap exports; provides a
    thin compat NotificationType constant keyed by method name for
    consumers that still discriminate notification variants.
  • Adapts AgentSubscription routing to switch on envelope.channel
    rather than inspecting per-action URI fields (_isRelevantEnvelope
    replaces _isRelevantAction).
  • Migrates all producers (agentService, agentSideEffects,
    agentConfigurationService, agentHostChangesetService,
    agentHostTerminalManager, agentHostStateManager,
    protocolServerHandler, Claude/Copilot agent sessions, terminal
    manager, etc.) and consumers (workbench session handler, terminal
    contribution, pty, customization harness, provider tests) to the new
    shapes.

(Commit message generated by Copilot)

Adopts the channel-based Agent Host Protocol revision from
microsoft/agent-host-protocol#127. Subscriptions, action delivery, and
protocol notifications now all route over named channels identified by a
top-level `channel: URI` field, replacing the pre-channels subscribe /
dispatch / notify model.

- Renames `ROOT_STATE_URI` from `agenthost:/root` to `ahp-root://` and
  adds an `isAhpRootChannel` helper that tolerates both the canonical
  wire form and the workbench `URI` round-tripped form (`ahp-root:`).
- Threads a `channel` parameter through every action dispatch path:
  `IAgentService.dispatchAction`, `IAgentConnection.dispatch`,
  `AgentHostStateManager.dispatchServerAction` / `dispatchClientAction`,
  and `AgentSubscriptionManager.dispatchOptimistic`. Individual action
  payloads no longer carry `session` / `terminal` / `changeset` fields;
  the envelope carries the channel.
- Replaces the `{ method: 'notification', params: { notification } }`
  wrapper with top-level JSON-RPC methods (`root/sessionAdded`,
  `root/sessionRemoved`, `root/sessionSummaryChanged`, `auth/required`).
  Each notification's params now carry their own `channel: URI` field.
- Renames the per-command identifying field to `channel` for the channel-
  scoped commands (`createSession`, `disposeSession`, `createTerminal`,
  `disposeTerminal`, `fetchTurns`, `completions`,
  `invokeChangesetOperation`). Connection-level commands hard-code the
  root channel string.
- Updates the subscribe result to `{ snapshot? }` and the
  `SubscribeParams` / `UnsubscribeParams` field name from `resource` to
  `channel`.
- Drops the removed `ProtocolNotification`, `NotificationType`,
  `NotificationMethodParams`, and `NotificationMap` exports; provides a
  thin compat `NotificationType` constant keyed by method name for
  consumers that still discriminate notification variants.
- Adapts `AgentSubscription` routing to switch on `envelope.channel`
  rather than inspecting per-action URI fields (`_isRelevantEnvelope`
  replaces `_isRelevantAction`).
- Migrates all producers (`agentService`, `agentSideEffects`,
  `agentConfigurationService`, `agentHostChangesetService`,
  `agentHostTerminalManager`, `agentHostStateManager`,
  `protocolServerHandler`, Claude/Copilot agent sessions, terminal
  manager, etc.) and consumers (workbench session handler, terminal
  contribution, pty, customization harness, provider tests) to the new
  shapes.

(Commit message generated by Copilot)
# Conflicts:
#	src/vs/platform/agentHost/test/node/claudeMapSessionEvents.test.ts
Copilot AI review requested due to automatic review settings May 19, 2026 06:13
@connor4312 connor4312 enabled auto-merge (squash) May 19, 2026 06:13
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 updates VS Code’s Agent Host integration to the channel-based Agent Host Protocol (AHP) wire model: routing subscriptions, action delivery, and protocol notifications through a top-level channel field and switching notifications to top-level JSON-RPC methods.

Changes:

  • Introduces ahp-root:// as the root channel plus isAhpRootChannel to tolerate URI round-tripping.
  • Threads channel through dispatch paths and removes per-action session/terminal/changeset routing fields in favor of envelope routing.
  • Migrates protocol notification wiring from a notification wrapper to top-level methods like root/sessionAdded and updates tests/consumers accordingly.
Show a summary per file
File Description
src/vs/workbench/services/agentHost/test/common/agentHostPermissionService.test.ts Updates permission requests to carry channel.
src/vs/workbench/services/agentHost/browser/editorRemoteAgentHostServiceClient.ts Updates dispatch API to require channel.
src/vs/workbench/contrib/terminal/test/browser/agentHostPty.test.ts Updates terminal PTY tests for channel-scoped actions/envelopes.
src/vs/workbench/contrib/terminal/browser/agentHostPty.ts Sends terminal actions via channel + action envelope.
src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostUntitledProvisionalSessionService.test.ts Updates dispatch expectations to include channel.
src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostTerminalContribution.test.ts Updates mock dispatches and assertions for channel-based dispatch.
src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostClientTools.test.ts Updates session tool routing to use channels rather than action.session.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/loggingAgentConnection.ts Logs dispatches as { channel, action }.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostUntitledProvisionalSessionService.ts Dispatches session config changes with explicit channel.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostTerminalContribution.ts Dispatches root config changes against ROOT_STATE_URI.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionListController.ts Switches to new notification types (root/session*).
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionHandler.ts Removes per-action session/terminal routing fields; uses channel routing.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostChatInputPicker.ts Dispatches config changes with channel-scoped dispatch.
src/vs/sessions/contrib/providers/remoteAgentHost/test/browser/remoteAgentHostSessionsProvider.test.ts Updates provider tests for channel-based notifications/actions.
src/vs/sessions/contrib/providers/remoteAgentHost/test/browser/remoteAgentHostCustomizationHarness.test.ts Updates customization harness tests for channel-scoped dispatch.
src/vs/sessions/contrib/providers/remoteAgentHost/browser/remoteAgentHostCustomizationHarness.ts Dispatches root customization config on ROOT_STATE_URI.
src/vs/sessions/contrib/providers/agentHost/test/browser/localAgentHostSessionsProvider.test.ts Updates provider tests for channel-based notifications/actions.
src/vs/sessions/contrib/providers/agentHost/browser/baseAgentHostSessionsProvider.ts Updates provider dispatch paths to supply channel and use root channel.
src/vs/platform/agentHost/test/node/reducers.test.ts Adjusts reducer tests for removed per-action routing fields.
src/vs/platform/agentHost/test/node/protocol/turnExecution.integrationTest.ts Updates subscribe params and snapshot optionality handling.
src/vs/platform/agentHost/test/node/protocol/testHelpers.ts Updates handshake/session creation helpers to channel-based params.
src/vs/platform/agentHost/test/node/protocol/sessionLifecycle.integrationTest.ts Updates notification expectations and subscribe shape usage.
src/vs/platform/agentHost/test/node/protocol/sessionFeatures.integrationTest.ts Updates protocol feature tests to new subscribe + notifications model.
src/vs/platform/agentHost/test/node/protocol/sessionDiffs.integrationTest.ts Updates session/changeset subscription params for channel-based subscribe.
src/vs/platform/agentHost/test/node/protocol/sessionConfig.integrationTest.ts Updates session config tests for channel-based protocol (incomplete).
src/vs/platform/agentHost/test/node/protocol/realSdkTestHelpers.ts Updates real-SDK test harness to new notification model (incomplete).
src/vs/platform/agentHost/test/node/protocol/multiClient.integrationTest.ts Updates multi-client tests to channel-based protocol (incomplete).
src/vs/platform/agentHost/test/node/protocol/handshake.integrationTest.ts Updates handshake tests for channel-based createSession + notifications.
src/vs/platform/agentHost/test/node/protocol/copilotRealSdk.integrationTest.ts Updates assertions to use envelope channel instead of action.session.
src/vs/platform/agentHost/test/node/mockAgent.ts Removes per-action session routing fields; relies on envelope channel.
src/vs/platform/agentHost/test/node/copilotSlashCommandCompletionProvider.test.ts Updates completions params to use channel.
src/vs/platform/agentHost/test/node/copilotShellTools.test.ts Updates terminal creation params (terminalchannel).
src/vs/platform/agentHost/test/node/copilotAgent.test.ts Updates action envelopes for session routing removal.
src/vs/platform/agentHost/test/node/claudeMapSessionEvents.test.ts Updates session event mapping tests to use envelope channel.
src/vs/platform/agentHost/test/node/claudeAgent.test.ts Updates test assertions for channel-based session identification.
src/vs/platform/agentHost/test/node/agentService.test.ts Updates dispatch/state-manager calls to channel-based API.
src/vs/platform/agentHost/test/node/agentHostTerminalManager.test.ts Updates terminal manager tests for channel-based terminal identity.
src/vs/platform/agentHost/test/node/agentHostSkillCompletionProvider.test.ts Updates completion params to use channel.
src/vs/platform/agentHost/test/node/agentHostFileCompletionProvider.test.ts Updates file completion lookup to use params.channel.
src/vs/platform/agentHost/test/node/agentHostChangesetService.test.ts Updates emitted envelopes assertions to check envelope.channel.
src/vs/platform/agentHost/test/electron-browser/remoteAgentHostProtocolClient.test.ts Updates protocol-client tests for channel-based requests/errors.
src/vs/platform/agentHost/test/electron-browser/localAhpJsonlLogging.test.ts Updates logging wrapper tests for channel-aware dispatchAction.
src/vs/platform/agentHost/test/common/agentSubscription.test.ts Updates subscription routing to channel-based envelopes.
src/vs/platform/agentHost/node/sessionPermissions.ts Updates tool-ready action creation (session routing removed).
src/vs/platform/agentHost/node/protocolServerHandler.ts Updates server routing to channel-based subscribe/dispatch/notifications.
src/vs/platform/agentHost/node/copilot/copilotSlashCommandCompletionProvider.ts Uses params.channel for copilot session gating.
src/vs/platform/agentHost/node/copilot/copilotShellTools.ts Uses channel-based createTerminal params.
src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts Removes redundant session field from emitted actions.
src/vs/platform/agentHost/node/claude/claudeSubagentSignals.ts Removes per-action session routing fields.
src/vs/platform/agentHost/node/claude/claudeSdkPipeline.ts Removes per-action session routing fields.
src/vs/platform/agentHost/node/claude/claudeMapSessionEvents.ts Removes per-action session routing fields.
src/vs/platform/agentHost/node/claude/claudeAgentSession.ts Removes per-action session routing fields.
src/vs/platform/agentHost/node/agentService.ts Changes dispatcher to accept channel + action and route attachments by channel.
src/vs/platform/agentHost/node/agentHostTerminalManager.ts Routes terminal actions via envelope channel; root terminal list via root channel.
src/vs/platform/agentHost/node/agentHostStateManager.ts Adds channel-aware dispatch and top-level notification methods.
src/vs/platform/agentHost/node/agentHostSkillCompletionProvider.ts Uses params.channel when resolving agent candidates.
src/vs/platform/agentHost/node/agentHostFileCompletionProvider.ts Uses params.channel for working directory lookup.
src/vs/platform/agentHost/node/agentHostChangesetService.ts Emits changeset actions on changeset channel rather than in-action field.
src/vs/platform/agentHost/node/agentConfigurationService.ts Dispatches root and session config updates on correct channel.
src/vs/platform/agentHost/electron-browser/localAgentHostService.ts Updates local dispatcher and optimistic dispatch to require channel.
src/vs/platform/agentHost/common/state/sessionState.ts Defines ahp-root:// and isAhpRootChannel.
src/vs/platform/agentHost/common/state/sessionProtocol.ts Drops removed notification exports from sessionProtocol surface.
src/vs/platform/agentHost/common/state/sessionActions.ts Reworks notification typing + compat NotificationType constants.
src/vs/platform/agentHost/common/state/protocol/version/registry.ts Converts notification versioning to method-name based mapping.
src/vs/platform/agentHost/common/state/protocol/state.ts Updates docs for URI/snapshot wording to channel-based model.
src/vs/platform/agentHost/common/state/protocol/notifications.ts Defines top-level notification params (root/session*, auth/required) with channel.
src/vs/platform/agentHost/common/state/protocol/messages.ts Updates notification maps and typed notification union for new methods.
src/vs/platform/agentHost/common/state/protocol/.ahp-version Bumps synced protocol revision.
src/vs/platform/agentHost/common/state/agentSubscription.ts Updates subscription routing to _isRelevantEnvelope and channel-based optimistic dispatch.
src/vs/platform/agentHost/common/agentService.ts Updates IAgentService/IAgentConnection dispatch signatures to include channel.
src/vs/platform/agentHost/common/agentHostFileSystemProvider.ts Adds channel: ROOT_STATE_URI to filesystem RPCs.
src/vs/platform/agentHost/browser/nullAgentHostService.ts Updates null service dispatch signature to accept channel.

Copilot's findings

Comments suppressed due to low confidence (6)

src/vs/platform/agentHost/test/node/protocol/sessionConfig.integrationTest.ts:232

  • This subscribe call is still using { resource: sessionUri }. The channel-based protocol expects { channel: sessionUri }, and SubscribeResult.snapshot is now optional so callers should handle snapshot.snapshot possibly being undefined.
    src/vs/platform/agentHost/test/node/protocol/sessionConfig.integrationTest.ts:194
  • The persistence test still uses the pre-channels protocol shapes: subscribe is called with { resource: sessionUri } instead of { channel: sessionUri }. Additionally, the subsequent dispatchAction notification should now include a top-level channel and the action payload should not carry session (the channel is the envelope).
    src/vs/platform/agentHost/test/node/protocol/realSdkTestHelpers.ts:702
  • This test still uses old protocol field names: subscribe is called with { resource: sessionUri } (should be { channel: sessionUri }). Also the preceding createSession call uses { session: ... } which should be { channel: ... } under the channel-based wire model.
    src/vs/platform/agentHost/test/node/protocol/realSdkTestHelpers.ts:522
  • The real-SDK tests still call subscribe with { resource: ROOT_STATE_URI }. The updated protocol expects { channel: ROOT_STATE_URI } (and InitializeParams/other commands also now carry a channel: 'ahp-root://').
    src/vs/platform/agentHost/test/node/protocol/realSdkTestHelpers.ts:664
  • This resubscribe still uses { resource: sessionUri }. With the channel-based protocol it should be { channel: sessionUri } (and callers should handle snapshot being optional on the result).
    src/vs/platform/agentHost/test/node/protocol/realSdkTestHelpers.ts:809
  • Terminal subscriptions here still call subscribe with { resource: terminalUri }. The channel-based protocol expects { channel: terminalUri } (same for the subsequent subscribe call later in this test).
  • Files reviewed: 80/80 changed files
  • Comments generated: 6

Comment thread src/vs/platform/agentHost/test/node/protocol/realSdkTestHelpers.ts
Comment thread src/vs/platform/agentHost/test/node/protocol/multiClient.integrationTest.ts Outdated
Comment thread src/vs/platform/agentHost/node/protocolServerHandler.ts
Comment thread src/vs/platform/agentHost/test/node/protocol/sessionConfig.integrationTest.ts Outdated
Addresses feedback from Copilot's review of #317251:

- Update real-SDK integration test helpers and protocol integration
  tests to use the channel-based command shapes (rename `session` /
  `resource` to `channel`, add `channel: 'ahp-root://'` to
  connection-level commands, drop `session` from action payloads, route
  via params-level `channel`).
- Treat the canonical `ahp-root://` and the URI-normalized `ahp-root:`
  forms as equivalent in `_isRelevantToClient` so root broadcasts reach
  a client that subscribed using either form (mirrors `isAhpRootChannel`
  already in use elsewhere).
- Drop a `..` hop from the `NotificationType` import path in the local
  and remote session-provider tests; import from
  `state/sessionActions.js` directly.
- Drop a stale post-merge `session: SESSION_STR` in
  `claudeMapSessionEvents.test.ts:Test 9.5` and the matching
  `requestResourceAccess` test expectation in
  `agentHostFileSystemProvider.test.ts` so they match the new
  channel-based shapes (root cause of the macOS browser CI failure).

(Commit message generated by Copilot)
# Conflicts:
#	src/vs/sessions/contrib/providers/remoteAgentHost/test/browser/remoteAgentHostCustomizationHarness.test.ts
pwang347
pwang347 previously approved these changes May 19, 2026
@connor4312 connor4312 merged commit c7e690b into main May 19, 2026
39 of 40 checks passed
@connor4312 connor4312 deleted the connor4312/ah-channels branch May 19, 2026 17:28
@vs-code-engineering vs-code-engineering Bot added this to the 1.122.0 milestone May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants