Skip to content

agents: add "Debug Local Agent Host Process In Dev Tools" command#312246

Merged
roblourens merged 4 commits intomainfrom
roblou/agents/debug-local-agent-host-process
Apr 23, 2026
Merged

agents: add "Debug Local Agent Host Process In Dev Tools" command#312246
roblourens merged 4 commits intomainfrom
roblou/agents/debug-local-agent-host-process

Conversation

@roblourens
Copy link
Copy Markdown
Member

Adds a Developer: Debug Local Agent Host Process In Dev Tools command — analogous to the existing Developer: Debug Extension Host In Dev Tools — that opens a Chrome DevTools window attached to the local agent host utility process. Registered for both VS Code and the Agents app.

How it works

  • New getInspectInfo(tryEnable) on IConnectionTrackerService (and surfaced through IAgentHostService).
  • The agent host process implements it with the built-in node:inspector module: inspector.url() to read the current listener, or inspector.open(0, '127.0.0.1', false) to enable on a random local port if it's not already on.
  • The action calls getInspectInfo(true) and then INativeHostService.openDevToolsWindow(devtoolsUrl). On failure to enable, it shows a notification.

Differences from the extension-host equivalent

  • Inspector lives inside the utility process, not the main process. We use node:inspector directly rather than Electron's UtilityProcess.enableInspectPort() + stderr scraping, so no main-process plumbing.
  • No restart prompt. inspector.open enables the inspector live, so unlike the extension-host action there's nothing to restart.
  • Single host → no quick-pick.

Files

  • platform/agentHost/common/agentService.tsIAgentHostInspectInfo + getInspectInfo on the IPC and service interfaces.
  • platform/agentHost/node/agentHostMain.ts — implementation using node:inspector.
  • platform/agentHost/electron-browser/agentHostService.ts — renderer-side forwarder.
  • platform/agentHost/browser/nullAgentHostService.ts — null impl returns undefined.
  • workbench/contrib/chat/electron-browser/actions/debugAgentHostAction.ts — the Action2 (extracted so the Agents app can register it without pulling in the full chatDeveloperActions module).
  • workbench/contrib/chat/electron-browser/actions/chatDeveloperActions.ts — registers it in VS Code.
  • sessions/contrib/chat/electron-browser/debugAgentHost.contribution.ts (+ sessions.desktop.main.ts) — registers it in the Agents app.
  • eslint.config.js — allows importing inspector (Node built-in) under the same allow-list as os, crypto, etc.

(Written by Copilot)

Adds a Developer command, available in both VS Code and the Agents app,
that opens a Chrome DevTools window attached to the local agent host
utility  analogous to the existing 'Debug Extension Host Inprocess
Dev Tools' command.

The agent host process enables its inspector live via node:inspector
on demand, so no restart is required. The renderer reaches the
inspector URL through the existing agent-host IPC channel.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 23, 2026 22:28
@roblourens roblourens enabled auto-merge (squash) April 23, 2026 22:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new developer command to attach Chrome DevTools to the local agent host utility process by enabling (or reusing) a Node.js inspector listener and opening the corresponding devtools:// URL. This is registered both in VS Code’s chat developer actions and in the standalone Agents app.

Changes:

  • Introduces getInspectInfo(tryEnable) on IConnectionTrackerService and surfaces it via IAgentHostService.
  • Implements inspector enablement and DevTools URL creation in the agent host utility process using the Node inspector module.
  • Adds a new Action2 (Developer: Debug Local Agent Host Process In Dev Tools) and registers it in both VS Code and the Agents app.
Show a summary per file
File Description
src/vs/workbench/contrib/chat/electron-browser/actions/debugAgentHostAction.ts New Action2 that requests inspect info and opens a DevTools child window.
src/vs/workbench/contrib/chat/electron-browser/actions/chatDeveloperActions.ts Registers the new debug action in VS Code.
src/vs/sessions/sessions.desktop.main.ts Wires the Agents app contribution module.
src/vs/sessions/contrib/chat/electron-browser/debugAgentHost.contribution.ts Registers the new debug action in the Agents app.
src/vs/platform/agentHost/node/agentHostMain.ts Implements getInspectInfo using inspector.url()/inspector.open() and builds the DevTools URL.
src/vs/platform/agentHost/electron-browser/agentHostService.ts Forwards getInspectInfo from renderer to the IPC connection tracker.
src/vs/platform/agentHost/common/agentService.ts Adds IAgentHostInspectInfo + new getInspectInfo API on service/IPC interfaces.
src/vs/platform/agentHost/browser/nullAgentHostService.ts Adds a null/browser implementation returning undefined for inspect info.
eslint.config.js Allows importing the Node inspector builtin.

Copilot's findings

  • Files reviewed: 9/9 changed files
  • Comments generated: 1

Comment thread src/vs/platform/agentHost/node/agentHostMain.ts Outdated
Move the registerAction2(DebugAgentHostInDevToolsAction) call into the
existing openInVSCode.contribution.ts, which is already imported from
sessions.desktop.main.ts. Drops the standalone debugAgentHost.contribution.ts.

(Written by Copilot)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
zhichli
zhichli previously approved these changes Apr 23, 2026
Use URL parser instead of a regex so IPv6 hosts (ws://[::1]:PORT/...)
are accepted and wildcard hosts (0.0.0.0, ::) are normalized to loopback.

Addresses code review on PR #312246.

(Written by Copilot)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
connor4312
connor4312 previously approved these changes Apr 23, 2026
Hides the command from the command palette when AI features are disabled,
fixing the 'can disable AI features' smoke test.

(Written by Copilot)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@roblourens roblourens merged commit 5daa981 into main Apr 23, 2026
26 checks passed
@roblourens roblourens deleted the roblou/agents/debug-local-agent-host-process branch April 23, 2026 23:29
@vs-code-engineering vs-code-engineering Bot added this to the 1.118.0 milestone Apr 23, 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

Development

Successfully merging this pull request may close these issues.

5 participants