Skip to content

agentHost: address review of shared agent host discovery - #347743

Merged
Connor Peet (connor4312) merged 3 commits into
mainfrom
connor4312/346859-review-fixes
Nov 11, 2026
Merged

Connor Peet (connor4312) merged 3 commits into
mainfrom
connor4312/346859-review-fixes

Conversation

@connor4312

@connor4312 Connor Peet (connor4312) commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

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.
  • 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 tunnel keeps the supervisor.
  • Put brackets around IPv6 hosts in the bridge argument that the CLI gives to older servers.

Refs #346859
Fixes #346518
Fixes #347561

How to test

Validation run for this change:

  • pnpm run typecheck-client: passed
  • ./scripts/test.sh --run for localAgentHostMetadata, agentHostEndpointRegistry, sshRemoteAgentHostHelpers, sshRemoteAgentHostService (node and electron-browser), devContainerAgentHostService, wslRemoteAgentHostHelpers, serverConnectionToken, agentHostChannel and editorRemoteAgentHostServiceClient: passed (436 tests)
  • cargo test --lib -- code_server control_server agent_host (in cli/): passed (101 tests); cargo test --lib: passed (210 tests)
  • pnpm run oxlint <changed files>: passed

(Commit message generated by Copilot)

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)
Copilot AI balanced review requested due to automatic review settings November 11, 2026 22:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Comment thread cli/src/commands/agent_host.rs Resolved
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)
@connor4312
Connor Peet (connor4312) merged commit 9415f2f into main Nov 11, 2026
52 of 53 checks passed
@connor4312
Connor Peet (connor4312) deleted the connor4312/346859-review-fixes branch November 11, 2026 22:30
@vs-code-engineering vs-code-engineering Bot added this to the 1.147.0 milestone Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants