agentHost: adopt channel-based AHP wire model#317251
Merged
Merged
Conversation
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
Contributor
There was a problem hiding this comment.
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 plusisAhpRootChannelto tolerate URI round-tripping. - Threads
channelthrough dispatch paths and removes per-actionsession/terminal/changesetrouting fields in favor of envelope routing. - Migrates protocol notification wiring from a
notificationwrapper to top-level methods likeroot/sessionAddedand 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 (terminal → channel). |
| 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
subscribecall is still using{ resource: sessionUri }. The channel-based protocol expects{ channel: sessionUri }, andSubscribeResult.snapshotis now optional so callers should handlesnapshot.snapshotpossibly being undefined.
src/vs/platform/agentHost/test/node/protocol/sessionConfig.integrationTest.ts:194 - The persistence test still uses the pre-channels protocol shapes:
subscribeis called with{ resource: sessionUri }instead of{ channel: sessionUri }. Additionally, the subsequentdispatchActionnotification should now include a top-levelchanneland the action payload should not carrysession(the channel is the envelope).
src/vs/platform/agentHost/test/node/protocol/realSdkTestHelpers.ts:702 - This test still uses old protocol field names:
subscribeis called with{ resource: sessionUri }(should be{ channel: sessionUri }). Also the precedingcreateSessioncall 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
subscribewith{ resource: ROOT_STATE_URI }. The updated protocol expects{ channel: ROOT_STATE_URI }(andInitializeParams/other commands also now carry achannel: '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 handlesnapshotbeing optional on the result).
src/vs/platform/agentHost/test/node/protocol/realSdkTestHelpers.ts:809 - Terminal subscriptions here still call
subscribewith{ 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
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
previously approved these changes
May 19, 2026
Yoyokrazy
approved these changes
May 19, 2026
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.
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: URIfield, replacing the pre-channels subscribe /dispatch / notify model.
ROOT_STATE_URIfromagenthost:/roottoahp-root://andadds an
isAhpRootChannelhelper that tolerates both the canonicalwire form and the workbench
URIround-tripped form (ahp-root:).channelparameter through every action dispatch path:IAgentService.dispatchAction,IAgentConnection.dispatch,AgentHostStateManager.dispatchServerAction/dispatchClientAction,and
AgentSubscriptionManager.dispatchOptimistic. Individual actionpayloads no longer carry
session/terminal/changesetfields;the envelope carries the channel.
{ 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: URIfield.channelfor the channel-scoped commands (
createSession,disposeSession,createTerminal,disposeTerminal,fetchTurns,completions,invokeChangesetOperation). Connection-level commands hard-code theroot channel string.
{ snapshot? }and theSubscribeParams/UnsubscribeParamsfield name fromresourcetochannel.ProtocolNotification,NotificationType,NotificationMethodParams, andNotificationMapexports; provides athin compat
NotificationTypeconstant keyed by method name forconsumers that still discriminate notification variants.
AgentSubscriptionrouting to switch onenvelope.channelrather than inspecting per-action URI fields (
_isRelevantEnvelopereplaces
_isRelevantAction).agentService,agentSideEffects,agentConfigurationService,agentHostChangesetService,agentHostTerminalManager,agentHostStateManager,protocolServerHandler, Claude/Copilot agent sessions, terminalmanager, etc.) and consumers (workbench session handler, terminal
contribution, pty, customization harness, provider tests) to the new
shapes.
(Commit message generated by Copilot)