Repository navigation
agentHost: share one agent host between remote editor windows and the Agents Window - #347738
Merged
Merged
Conversation
… Agents Window A VS Code server that a remote extension starts (WSL, Dev Containers, and Remote-SSH without the exec server) started a private agent host. It did not read the endpoint registry and did not publish its agent host. Thus the editor window and the Agents Window used different agent hosts and showed different sessions. Now all remotes use the shared registry. - The server reads the registry before it starts an agent host. It connects to a live standalone agent host of the same quality. If there is none, it starts an agent host on loopback TCP that publishes itself as a standalone entry, so later clients use it. - Remove the `--agent-host-bridge-*` server flags. The CLI makes sure that its supervisor runs before it starts the server, and the server finds the supervisor in the registry. - The Dev Containers connector uses any shareable standalone agent host, not only the agent hosts that it started. It tags its relay process with the session marker, so that a container is not stopped while the Agents Window uses it. - The SSH, WSL and Dev Containers connectors start `code agent host` with `--server-data-dir`. Thus the agent host keeps sessions in the same data folder as the server of the product. - Share the SSH agent location preference with editor windows. The server and the SSH connector select endpoints with one function, so an editor-owned endpoint can be shared. - Open sessions across Agents Window and SSH, WSL and Dev Container editor windows when both use the same agent host. - The chat view starts a new chat if it cannot restore a session, for example when the agent host changed. - Podman does not report masked paths. Report the Dev Container sandbox as unsupported for this case, instead of failing the session. Fixes #346859 (Commit message generated by Copilot)
Ross Wollman (rwoll)
approved these changes
Nov 11, 2026
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Concurrent first connections can launch separate agent hosts and split sessions because automatic allocation is not coordinated across processes.
8 open issues
Coordinate automatic host allocation across processes · New Preserve bridge handoff for servers without registry discovery · New Align live standalone selection across CLI and server · New Use the same ordinal editor ID ordering on both paths · New Resolve SSH user and port before reading host preferences · New Bracket IPv6 hosts when building relay URLs · New Normalize wildcard and IPv6 registry addresses for WebSocket URLs · New Verify the actual source endpoint before shared-host handoff · New
What changed in this PR
This PR moves remote editor servers toward the shared agent-host registry so editor windows and the Agents Window can discover the same sessions, addressing the remote session-sharing issues in #346859 and #344412.
Changes:
- Discover and publish shared agent hosts, replacing explicit CLI bridge arguments.
- Share SSH location preferences and extend session handoff across supported remote connections.
- Align remote data directories, tag Dev Container relays, and handle missing sessions and Podman sandbox metadata.
| File | Description |
|---|---|
src/vs/workbench/workbench.common.main.ts |
Registers shared location preferences in the workbench. |
src/vs/workbench/services/agentHost/test/browser/editorRemoteAgentHostServiceClient.test.ts |
Tests SSH preference lookup and forwarding. |
src/vs/workbench/services/agentHost/browser/editorRemoteAgentHostServiceClient.ts |
Forwards SSH location preferences when connecting. |
src/vs/workbench/contrib/sessions/providers/remoteAgentHost/REMOTE_AGENT_HOST_SESSIONS_PROVIDER.md |
Documents sharing rules and handoff limitations. |
src/vs/workbench/contrib/sessions/browser/openInVSCodeUtils.ts |
Extends remote session translation and mismatch checks. |
src/vs/workbench/contrib/chat/test/browser/widgetHosts/viewPane/chatViewPane.test.ts |
Tests restore failure fallback and cancellation. |
src/vs/workbench/contrib/chat/browser/widgetHosts/viewPane/chatViewPane.ts |
Falls back to a new chat after restore failure. |
src/vs/sessions/test/electron-browser/vscodeActions.test.ts |
Tests desktop remote session handoff. |
src/vs/sessions/test/browser/vscodeActions.test.ts |
Tests web remote session handoff. |
src/vs/sessions/sessions.web.main.ts |
Removes duplicate preference service registration. |
src/vs/sessions/sessions.desktop.main.ts |
Removes duplicate preference service registration. |
src/vs/sessions/sessions.core.web.main.ts |
Removes duplicate preference service registration. |
src/vs/sessions/sessions.core.main.ts |
Loads shared preference service registration. |
src/vs/sessions/sessions.common.main.ts |
Loads shared preference service registration. |
src/vs/sessions/electron-browser/actions/vscodeActions.ts |
Supplies SSH preferences to desktop handoff checks. |
src/vs/sessions/contrib/providers/remoteAgentHost/test/browser/remoteWorkspaceHandoffService.test.ts |
Tests shared-host decisions and preferences. |
src/vs/sessions/contrib/providers/remoteAgentHost/browser/remoteWorkspaceHandoffService.ts |
Reuses SSH parsing and shared-host checks. |
src/vs/sessions/contrib/chat/test/electron-browser/agentsWindowWorkspaceHandoff.test.ts |
Covers SSH and WSL session handoff. |
src/vs/sessions/contrib/chat/electron-browser/chat.contribution.ts |
Enables SSH and WSL session opening. |
src/vs/sessions/common/remoteWorkspaceHandoff.ts |
Updates handoff contract documentation. |
src/vs/sessions/browser/actions/vscodeActions.ts |
Supplies SSH preferences to web handoff checks. |
src/vs/server/test/node/serverConnectionToken.test.ts |
Updates redaction tests after bridge flag removal. |
src/vs/server/test/node/agentHostChannel.test.ts |
Tests location preference validation and forwarding. |
src/vs/server/node/serverServices.ts |
Discovers shared hosts or starts a discoverable TCP host. |
src/vs/server/node/serverEnvironmentService.ts |
Removes bridge arguments and token handling. |
src/vs/server/node/server.main.ts |
Removes bridge token environment plumbing. |
src/vs/server/node/remoteExtensionHostAgentServer.ts |
Updates server setup arguments. |
src/vs/server/node/agentHostChannel.ts |
Validates connection location preferences. |
src/vs/platform/agentHost/test/node/wslRemoteAgentHostHelpers.test.ts |
Checks WSL server data directory arguments. |
src/vs/platform/agentHost/test/node/sshRemoteAgentHostService.test.ts |
Tests rejection of different-quality standalones. |
src/vs/platform/agentHost/test/node/sshRemoteAgentHostHelpers.test.ts |
Updates remote launch command expectations. |
src/vs/platform/agentHost/test/node/localAgentHostMetadata.test.ts |
Tests endpoint discovery, ordering, and cleanup. |
src/vs/platform/agentHost/test/node/devContainerSandbox.test.ts |
Covers missing Podman masking metadata. |
src/vs/platform/agentHost/test/node/devContainerAgentHostService.test.ts |
Tests shared endpoints and session-tagged relays. |
src/vs/platform/agentHost/test/node/agentHostEndpointRegistry.test.ts |
Tests endpoint selection and quality filtering. |
src/vs/platform/agentHost/test/browser/remoteAgentHostLocationPreferenceService.test.ts |
Checks machine-local preference storage. |
src/vs/platform/agentHost/node/wslRemoteAgentHostHelpers.ts |
Passes the product data folder to WSL launches. |
src/vs/platform/agentHost/node/sshRemoteAgentHostService.ts |
Uses shared selection and updated launch arguments. |
src/vs/platform/agentHost/node/sshRemoteAgentHostHelpers.ts |
Adds --server-data-dir to launch commands. |
src/vs/platform/agentHost/node/nodeAgentHostStarter.ts |
Passes the endpoint registry path to child hosts. |
src/vs/platform/agentHost/node/localAgentHostMetadata.ts |
Supports standalone publication and endpoint selection. |
src/vs/platform/agentHost/node/devContainerSandbox.ts |
Treats unreported masking conservatively. |
src/vs/platform/agentHost/node/devContainerAgentHostService.ts |
Reuses compatible hosts and tags relay processes. |
src/vs/platform/agentHost/node/agentHostMain.ts |
Publishes configured TCP hosts as standalone endpoints. |
src/vs/platform/agentHost/common/sshRemoteAgentHost.ts |
Centralizes SSH authority parsing and preference keys. |
src/vs/platform/agentHost/common/agentService.ts |
Adds location preference to IPC connection options. |
src/vs/platform/agentHost/common/agentHostEndpointRegistry.ts |
Adds shared endpoint eligibility and selection helpers. |
src/vs/platform/agentHost/browser/remoteAgentHostLocationPreferenceService.ts |
Uses machine-local storage and registers the service. |
cli/src/tunnels/control_server.rs |
Awaits the supervisor without forwarding bridge arguments. |
cli/src/tunnels/code_server.rs |
Removes bridge fields, arguments, and their test. |
cli/src/commands/tunnels.rs |
Updates comments to describe registry discovery. |
cli/src/commands/agent_host.rs |
Removes the supervisor-to-server bridge helper. |
Review effort: Balanced
Connor Peet (connor4312)
added a commit
that referenced
this pull request
Nov 11, 2026
* agentHost: address review of shared agent host discovery Follow-up to #347738 for the review comments that arrived after it merged. - The CLI sends the `--agent-host-bridge-*` arguments again. A client can ask `code tunnel` or the exec server for a server commit that does not discover agent hosts through the registry. Such a server must use the bridge, or it starts a private agent host. New servers accept and ignore these arguments, redact the token in logs, and remove the token from their environment. - Select endpoints in the same order as the Rust CLI: the most recently published entry first. The local registry reader sorts by entry file time, and the server, the SSH and Dev Containers connectors, and the SSH endpoint picker use the first match in that order. - Put brackets around IPv6 hosts and use loopback for wildcard hosts in agent host URLs, in the server and in the Dev Container relay. - Do not read the SSH agent location preference for an authority without a user, because the key of the stored preference depends on SSH config. Refs #346859 (Commit message generated by Copilot) * cli: put brackets around IPv6 bridge hosts Servers that use the `--agent-host-bridge-host` argument put the host into a `ws://` URL. Put brackets around an IPv6 host, so that a supervisor bound to `::1` gives a valid URL. (Commit message generated by Copilot) * cli: do not start an agent host supervisor for command-shell `code command-shell` (the Remote-SSH exec server) waited for an agent host supervisor before it started the server. If the supervisor did not become ready, the window waited 300 seconds. The server that command-shell starts has the same commit as the client, so it does not need the supervisor. It uses a live shared agent host from the endpoint registry, or it starts and publishes its own agent host. It stays alive while that agent host has sessions or clients. `code tunnel` keeps the supervisor, because clients connect to its agent host without a server and can ask for older server commits. Fixes #346518 (Commit message generated by Copilot)
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: share one agent host between remote editor windows and the Agents Window
A VS Code server that a remote extension starts (WSL, Dev Containers, and Remote-SSH without the
exec server) started a private agent host. It did not read the endpoint registry and did not
publish its agent host. Thus the editor window and the Agents Window used different agent hosts
and showed different sessions. Now all remotes use the shared registry.
agent host of the same quality. If there is none, it starts an agent host on loopback TCP that
publishes itself as a standalone entry, so later clients use it.
--agent-host-bridge-*server flags. The CLI makes sure that its supervisor runsbefore it starts the server, and the server finds the supervisor in the registry.
that it started. It tags its relay process with the session marker, so that a container is not
stopped while the Agents Window uses it.
code agent hostwith--server-data-dir.Thus the agent host keeps sessions in the same data folder as the server of the product.
select endpoints with one function, so an editor-owned endpoint can be shared.
the same agent host.
changed.
case, instead of failing the session.
Fixes #346859
Fixes #344412
How to test
Manual: in an SSH host and a Dev Container (with a server that has this change), connect an editor window and the Agents Window in either order. There is one entry in
~/.config/<Product>/agent-host/local-endpoint/entries/, the editor server'sremoteagent.logshowsOpening upstream to 127.0.0.1:<port of that entry>, and both windows show the same sessions. Open in VS Code / Open in Agents Window moves the session between the windows.Validation run for this change:
pnpm run typecheck-client: passed./scripts/test.sh --runfor the changed agent host, server, sessions and chat view tests (localAgentHostMetadata,agentHostEndpointRegistry,sshRemoteAgentHostHelpers,sshRemoteAgentHostService,wslRemoteAgentHostHelpers,wslRemoteAgentHostService,devContainerAgentHostService,devContainerSandbox,remoteAgentHostLocationPreferenceService,agentHostChannel,serverConnectionToken,agentsWindowWorkspaceHandoff,remoteWorkspaceHandoffService,vscodeActions(browser and electron-browser),resolveRemoteAuthority,editorRemoteAgentHostServiceClient,chatViewPane): passedcargo test --lib -- code_server control_server agent_host(incli/): passedpnpm run eslint <changed files>: passedpnpm run valid-layers-check: passed(Commit message generated by Copilot)