Repository navigation
agentHost: address review of shared agent host discovery - #347743
Merged
Merged
Conversation
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)
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Reusing an IPv6 loopback supervisor passes an unbracketed host to legacy servers, producing invalid WebSocket URLs that prevent renderer connections.
1 open issue
What changed in this PR
This follow-up to #347738 improves shared agent host discovery so remote editor windows and the Agents Window can use the same host, while restoring compatibility with older servers.
Changes:
- Restore CLI bridge arguments for older servers, with token redaction and environment cleanup in newer servers.
- Align endpoint selection with newest-first registry order.
- Normalize IPv6 and wildcard URL hosts, and avoid unresolved SSH preference keys.
| File | Description |
|---|---|
src/vs/workbench/services/agentHost/test/browser/editorRemoteAgentHostServiceClient.test.ts |
Tests SSH authorities with a port but no user. |
src/vs/server/test/node/serverConnectionToken.test.ts |
Tests bridge-token redaction. |
src/vs/server/node/serverServices.ts |
Formats shared endpoint hosts for URLs. |
src/vs/server/node/serverEnvironmentService.ts |
Accepts legacy bridge flags and redacts tokens. |
src/vs/server/node/server.main.ts |
Removes the inherited bridge-token environment variable. |
src/vs/platform/agentHost/test/node/sshRemoteAgentHostService.test.ts |
Updates expectations for registry-order selection. |
src/vs/platform/agentHost/test/node/sshRemoteAgentHostHelpers.test.ts |
Tests IPv6 and wildcard host formatting. |
src/vs/platform/agentHost/test/node/localAgentHostMetadata.test.ts |
Tests publication ordering and timestamp ties. |
src/vs/platform/agentHost/test/node/devContainerAgentHostService.test.ts |
Tests newest-first compatible endpoint reuse. |
src/vs/platform/agentHost/test/node/agentHostEndpointRegistry.test.ts |
Tests first-match endpoint selection. |
src/vs/platform/agentHost/test/electron-browser/sshRemoteAgentHostService.test.ts |
Tests registry-order SSH preference resolution. |
src/vs/platform/agentHost/node/sshRemoteAgentHostService.ts |
Updates selection-policy comments only. |
src/vs/platform/agentHost/node/sshRemoteAgentHostHelpers.ts |
Adds a URL-host formatting helper. |
src/vs/platform/agentHost/node/localAgentHostMetadata.ts |
Orders registry entries by publication time. |
src/vs/platform/agentHost/node/devContainerAgentHostService.ts |
Uses shared selection and URL-host formatting. |
src/vs/platform/agentHost/electron-browser/sshRemoteAgentHostServiceImpl.ts |
Preserves registry order when choosing candidates. |
src/vs/platform/agentHost/common/sshRemoteAgentHost.ts |
Skips preference keys requiring unresolved SSH configuration. |
src/vs/platform/agentHost/common/agentHostEndpointRegistry.ts |
Selects the first compatible registry entry. |
cli/src/tunnels/control_server.rs |
Passes supervisor details to legacy server bridges. |
cli/src/tunnels/code_server.rs |
Restores bridge arguments and environment-only token passing. |
cli/src/commands/agent_host.rs |
Adds supervisor-to-bridge argument population. |
Review effort: Balanced
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)
`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)
Dmitriy Vasyura (dmitrivMS)
approved these changes
Nov 11, 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: address review of shared agent host discovery
Follow-up to #347738 for the review comments that arrived after it merged.
--agent-host-bridge-*arguments again. A client can askcode tunnelor theexec 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.
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.
server and in the Dev Container relay.
of the stored preference depends on SSH config.
code command-shell(the Remote-SSH exec server) no longer starts an agent host supervisor and waits up to 300 seconds for it. Its server has the client's commit, so it uses a live shared agent host or starts and publishes its own, and stays alive while that agent host has sessions or clients.code tunnelkeeps the supervisor.Refs #346859
Fixes #346518
Fixes #347561
How to test
Validation run for this change:
pnpm run typecheck-client: passed./scripts/test.sh --runforlocalAgentHostMetadata,agentHostEndpointRegistry,sshRemoteAgentHostHelpers,sshRemoteAgentHostService(node and electron-browser),devContainerAgentHostService,wslRemoteAgentHostHelpers,serverConnectionToken,agentHostChannelandeditorRemoteAgentHostServiceClient: passed (436 tests)cargo test --lib -- code_server control_server agent_host(incli/): passed (101 tests);cargo test --lib: passed (210 tests)pnpm run oxlint <changed files>: passed(Commit message generated by Copilot)