feat: add --agents to run Code's agent host - #7943
Open
1000ch wants to merge 1 commit into
Open
Conversation
VS Code 1.132 added the Agents Window, opened on the desktop with `code --agents`. Its workbench lives in `vs/sessions`, which Code only bundles into its vscode-web build, not into the vscode-reh-web server build we package, so there is no Agents Window for us to serve yet. The agent host that runs agent sessions is in the server build, though. Code spawns it only when told where it should listen, and registers the channel the browser uses to reach it over the remote connection at the same time. Without a path that channel is registered as unavailable, so agent sessions cannot connect at all today. `--agents` supplies that path, pointing the agent host at a socket in the user data directory (a named pipe on Windows). Agent sessions then work in the regular chat UI. Code never unlinks the socket, so a leftover one from a killed instance is removed before startup. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
What
Adds
--agents, which starts Code's agent host so agent sessions can run on the server.Why
VS Code 1.132 added the Agents Window, opened on the desktop with
code --agents. code-server cannot serve that window yet, but the piece underneath it — the agent host — already ships in the server build and is simply never started.Three facts from the submodule at
df53daa(1.132.0), all still true onmain(1.134.0):vs/sessions, a layer parallel tovs/workbench. A web build of it exists (vs/sessions/sessions.web.main.internal.ts), butbuild/gulpfile.reh.tslists onlybuildfile.codeWebinwebEntryPoints, sovscode-reh-web— the build we package — has no Agents Window bundle. Onlygulpfile.vscode.web.ts(thevscode-webbuild behind vscode.dev) includesbuildfile.sessionsWeb.buildfile.codeServerincludesvs/platform/agentHost/node/agentHostMain, and bothrehandreh-webuse it.serverServices.tsspawns the agent host only when--agent-host-portor--agent-host-pathis set, and registers theagentHostProxyIPC channel at the same time. With neither flag it registersUnavailableAgentHostChanneland logsno --agent-host-bridge-port / --agent-host-bridge-path set.The browser side is already wired up.
workbench.web.main.tsregistersEditorRemoteAgentHostServiceClientforIAgentHostService, which proxies the agent host protocol over the remote agent connection, andWebAgentHostEnablementServicetreats the agent host as available whenever there is a remote authority — which for code-server is always. So the workbench believes agent sessions are available and then has nothing to connect to.This is the same topology Code already uses for tunnels. From
serverServices.ts:A browser renderer talking to an agent host over the remote connection is an intended configuration; nobody has connected the self-hosted server to it.
How
--agentsmakestoCodeArgspassagent-host-pathpointing atagent-host.sockin the user data directory (a named pipe on Windows, which has no Unix sockets). That is enough for Code to spawn the agent host and register the channel the browser uses.Code binds the socket but never unlinks it, so a socket left behind by a killed instance would make the agent host fail to listen on the next start. code-server removes a stale one before Code can load.
Named after Code's own flag so the two line up if we can serve the Agents Window later.
Limitations
buildfile.sessionsWebadded to the reh-web entry points, plus an HTML entry point and a route to serve it — a patch againstlib/vscode, which this PR deliberately does not add.product.agentSdks, and its build pipeline stamps that only intoreh, notreh-web("REH-web skips it because the agent host is node-only", AH: per-platform agent SDK build + CDN upload microsoft/vscode#321012). Pointing Code at a local SDK root via its dev-override env vars is the only way around it today.Testing
npm run test:unit— added coverage for parsing--agentsand for theagent-host-paththattoCodeArgsproduces, including that concurrent instances get separate sockets.lib/vscodein this environment, so the agent host actually spawning and a session connecting through it has not been exercised. Happy to hold this until someone can confirm on a real build.🤖 Generated with Claude Code