Skip to content

Unify agentHost server-side dispatch: remove IProtocolSideEffectHandler#306158

Merged
roblourens merged 3 commits intomainfrom
roblou/unify-agenthost-dispatch
Mar 30, 2026
Merged

Unify agentHost server-side dispatch: remove IProtocolSideEffectHandler#306158
roblourens merged 3 commits intomainfrom
roblou/unify-agenthost-dispatch

Conversation

@roblourens
Copy link
Copy Markdown
Member

Eliminate the IProtocolSideEffectHandler interface and make ProtocolServerHandler talk to IAgentService directly. This removes the duplicate adapter layer between the WebSocket protocol server and the real service implementation.

Problem

There were two different server-side dispatch layers for the same operations, both ending up at AgentService:

  1. IPC MessagePort path (local): ProxyChannel auto-serializes IAgentService method calls
  2. WebSocket JSON-RPC path (remote/CLI): ProtocolServerHandlerIProtocolSideEffectHandler → manual adapter → AgentService

The IProtocolSideEffectHandler interface duplicated IAgentService with different method signatures, required a ~40-line inline adapter in agentHostMain.ts, and the standalone server (agentHostServerMain.ts) manually wired SessionStateManager + AgentSideEffects instead of using AgentService.

Changes

  • ProtocolServerHandler now takes IAgentService + SessionStateManager + IProtocolServerConfig instead of IProtocolSideEffectHandler
  • Deleted the IProtocolSideEffectHandler interface entirely
  • Deleted the ~40-line inline adapter in agentHostMain.ts
  • agentHostServerMain.ts now creates AgentService instead of manually wiring SessionStateManager + AgentSideEffects
  • Removed implements IProtocolSideEffectHandler from AgentSideEffects
  • Removed 6 dead methods from AgentSideEffects that were only needed by the deleted interface (handleCreateSession, handleDisposeSession, handleListSessions, handleGetResourceMetadata, handleAuthenticate, getDefaultDirectory)
  • Type conversions (URIstring, IAgentSessionMetadataISessionSummary) now happen at the protocol boundary in ProtocolServerHandler
  • Fixed dispatchAction double-dispatch: WS path previously dispatched to stateManager AND called handleAction (which dispatched to stateManager again)
  • Extension methods (getResourceMetadata, authenticate, etc.) now call IAgentService directly instead of untyped fallbacks
  • authenticate params are now validated with proper JSON-RPC error code (-32602)

(Written by Copilot)

Eliminate the IProtocolSideEffectHandler interface and make
ProtocolServerHandler talk to IAgentService directly. This removes
the duplicate adapter layer between the WebSocket protocol server
and the real service implementation.

Changes:
- ProtocolServerHandler now takes IAgentService + SessionStateManager +
  IProtocolServerConfig instead of IProtocolSideEffectHandler
- Deleted ~40-line inline adapter in agentHostMain.ts
- agentHostServerMain.ts now uses AgentService instead of manually
  wiring SessionStateManager + AgentSideEffects
- Removed implements IProtocolSideEffectHandler from AgentSideEffects
- Removed dead methods from AgentSideEffects that were only needed
  by the deleted interface (handleCreateSession, handleDisposeSession,
  handleListSessions, handleGetResourceMetadata, handleAuthenticate,
  getDefaultDirectory)
- Type conversions (URI<->string, IAgentSessionMetadata<->ISessionSummary)
  now happen at the protocol boundary in ProtocolServerHandler
- Fixed dispatchAction double-dispatch: WS path previously dispatched
  to stateManager AND called handleAction (which dispatched again)
- Extension methods (getResourceMetadata, authenticate, etc.) now call
  IAgentService directly instead of untyped fallbacks

(Written by Copilot)
Copilot AI review requested due to automatic review settings March 29, 2026 20:38
@vs-code-engineering vs-code-engineering bot added this to the Backlog milestone Mar 29, 2026
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 removes the extra server-side adapter layer (IProtocolSideEffectHandler) and routes WebSocket JSON-RPC requests directly to IAgentService, aligning the WebSocket and IPC dispatch paths and simplifying the standalone agent host server wiring.

Changes:

  • Refactors ProtocolServerHandler to depend on IAgentService (plus config) and removes IProtocolSideEffectHandler.
  • Updates the standalone server (agentHostServerMain.ts) to construct and use AgentService directly.
  • Updates unit tests and protocol documentation to reflect the new dispatch boundary and protocol validation.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/vs/platform/agentHost/test/node/protocolServerHandler.test.ts Reworks mocks/tests to target IAgentService instead of the removed side-effect handler interface.
src/vs/platform/agentHost/test/node/agentSideEffects.test.ts Removes tests for side-effect handler methods that were deleted along with IProtocolSideEffectHandler.
src/vs/platform/agentHost/protocol.md Updates contributor checklist to reflect the new handler/service boundary.
src/vs/platform/agentHost/node/protocolServerHandler.ts Main refactor: dispatches protocol operations to IAgentService, adds config, removes IProtocolSideEffectHandler, fixes double-dispatch.
src/vs/platform/agentHost/node/agentSideEffects.ts Drops implements IProtocolSideEffectHandler and deletes side-effect methods that were only needed for that interface.
src/vs/platform/agentHost/node/agentHostServerMain.ts Simplifies standalone server wiring to create AgentService and pass it to ProtocolServerHandler.
src/vs/platform/agentHost/node/agentHostMain.ts Removes the inline adapter and wires ProtocolServerHandler directly to AgentService.

roblourens and others added 2 commits March 29, 2026 17:20
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
@roblourens roblourens marked this pull request as ready for review March 30, 2026 02:07
@roblourens roblourens enabled auto-merge (squash) March 30, 2026 02:07
@roblourens roblourens merged commit 94c7bf8 into main Mar 30, 2026
18 checks passed
@roblourens roblourens deleted the roblou/unify-agenthost-dispatch branch March 30, 2026 02:07
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.

3 participants