Skip to content

Agent-host: Spawn from CLI and connect to remotes from Sessions#301140

Merged
roblourens merged 126 commits intomainfrom
connor4312/agent-host-server
Mar 17, 2026
Merged

Agent-host: Spawn from CLI and connect to remotes from Sessions#301140
roblourens merged 126 commits intomainfrom
connor4312/agent-host-server

Conversation

@connor4312
Copy link
Member

@connor4312 connor4312 commented Mar 12, 2026

Exposes --agent-host-port/--agent-host-path to specify an additional port for them to listen on. This runs as a separate process mirroring the architecture from desktop.

Does a 'hello world'.

There are changes to the import logic. I honestly don't know a lot about the import changes Opus is doing here . Without them, there is an error:

import { CopilotClient } from "@github/copilot-sdk";
         ^^^^^^^^^^^^^
SyntaxError: The requested module '@github/copilot-sdk' does not provide an export named 'CopilotClient'

This was Copilot's explanation for why they're needed here but not in Electron:

The agent host process itself didn't change — the issue is the module resolution environment differs between Electron and the server.

Electron (desktop): ElectronAgentHostStarter spawns a utility process that inherits the main process's module resolution. It resolves packages from the root node_modules, where @github/copilot-sdk, ws, etc. are all installed. Everything just works.

Server: NodeAgentHostStarter spawns a child via bootstrap-fork.js, which registers a custom ESM resolver hook (bootstrap-import.ts) that redirects all module lookups to node_modules instead of root node_modules. That's the [bootstrap-import] Initialized node_modules redirector for: ...\remote\node_modules log line. The remote folder has its own package.json with a curated set of server-specific dependencies.

The problems were:

  1. Missing deps@github/copilot-sdk, @github/copilot, and ws weren't in package.json because the agent host had never run in the server context before
  2. Resolver bugs — bootstrap-import.ts was written when all remote deps were CJS. It hardcoded format: 'commonjs', didn't handle exports maps, didn't handle .mjs files, and didn't resolve subpath imports like vscode-jsonrpc/node. These are pre-existing limitations that never mattered until now because no server component previously depended on ESM-only npm packages.

So in short: the agent host code is identical — it's the server's module resolution plumbing that needed updating to support the ESM packages the agent host depends on.

cc @bpasero as the expert in this area

…ssion fixes

Tool invocation rendering:
- Emit tool_start/tool_complete as ChatToolInvocation (not progressMessage)
- Shell tools (bash/powershell) render as terminal command blocks with
  IChatTerminalToolInvocationData, output, and exit codes
- Non-shell tools render via invocationMessage/pastTenseMessage (markdown)
- Filter out report_intent (hidden internal tool)

Agent-agnostic protocol:
- IPC events carry display-ready fields (displayName, invocationMessage,
  pastTenseMessage, toolInput, toolOutput, toolKind, language)
- All Copilot CLI-specific logic in copilotToolDisplay.ts with typed
  interfaces for known tools (CopilotToolName enum, parameter types)
- Renderer never references specific SDK tool names

Session fixes:
- Resumed sessions show tool invocations in history (getSessionMessages
  now returns tool events alongside messages)
- Fixed 'already has a pending request' on resumed sessions by
  conditionally providing interruptActiveResponseCallback
- Fixed event filtering for resumed sessions (sessionId override in
  _trackSession)

Documentation:
- Split parity.md into design.md (decisions) and backlog.md (tasks)
- Updated architecture.md, sessions.md with cross-references
- Added maintenance notes to all docs
Replace hardcoded per-provider contributions with a single
AgentHostContribution that discovers available agents from the
agent host process at startup. Each IAgent backend now exposes
an IAgentDescriptor with display metadata and auth requirements.

- Add IAgentDescriptor interface and listAgents() to IPC contract
- CopilotAgent/ClaudeAgent return descriptors via getDescriptor()
- Single AgentHostContribution discovers + registers dynamically
- Remove agentHostConstants.ts (no more hardcoded session types)
- AgentHostSessionListController/LMProvider take params instead
- Rename AgentSessionProviders.AgentHost -> AgentHostCopilot
- Update architecture.md, sessions.md, backlog.md

(Written by Copilot)
- Add listAgents() forwarding to AgentHostServiceClient
- Guard async discovery against disposal race
- Add provider field to IAgentModelInfo for per-provider filtering
- Filter models and sessions by provider in LM provider and list
  controller
- Update tests for new dynamic API and agent-host-copilot scheme

(Written by Copilot)
sharp is a transitive dependency of the Claude Agent SDK used for
image processing. Its native .node binaries cause dpkg-shlibdeps
errors during Debian packaging due to $ORIGIN RPATH references.
Strip all @img/sharp-* platform packages since the agent host
doesn't need image processing at runtime.

(Written by Copilot)
The Claude Agent SDK bundles ripgrep binaries for all platforms
under vendor/ripgrep/. Wrong-architecture binaries cause macOS
Mach-O verification to fail. Strip them entirely via .moduleignore
(VS Code has its own ripgrep) and add to verify-macho skip list.

(Written by Copilot)
…nt context

- Add Agent Host IPC output channel (only registered at trace log level) that
  logs all IPC method calls, results, and progress events with full JSON payloads
- Add trace-level logging in AgentService dispatcher for all method calls
- Add trace-level logging in session handler for all progress events and session
  resolution
- Wire up onPermissionRequest handler on CopilotClient.createSession and
  resumeSession to auto-approve tool permission requests
- Add IAgentAttachment type to IPC contract and thread attachments from chat
  variables (file, directory, selection) through sendMessage to the Copilot SDK

(Written by Copilot)
roblourens and others added 5 commits March 13, 2026 20:04
… hosts (#301639)

* Add directory listing to protocol, and folder picker for remote agent hosts

* Protocol improvements

* Don't register agenthost URIs as workspace folders

* Update pickers after merge

* Resolve comments
Base automatically changed from roblou/agent-host to main March 16, 2026 22:33
@roblourens roblourens changed the title agentHost: hello world from server Agent-host: Spawn from CLI and connect to remotes from Sessions Mar 17, 2026
@roblourens roblourens enabled auto-merge (squash) March 17, 2026 21:00
@roblourens roblourens disabled auto-merge March 17, 2026 21:00
mjbvz
mjbvz previously approved these changes Mar 17, 2026
@vs-code-engineering vs-code-engineering bot added this to the 1.113.0 milestone Mar 17, 2026
@roblourens roblourens merged commit 888a6c5 into main Mar 17, 2026
20 checks passed
@roblourens roblourens deleted the connor4312/agent-host-server branch March 17, 2026 23:17
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.

6 participants