Skip to content

agentHost: Remember and reuse CLI processes for ssh#307770

Merged
roblourens merged 3 commits intomainfrom
roblou/missing-guineafowl
Apr 5, 2026
Merged

agentHost: Remember and reuse CLI processes for ssh#307770
roblourens merged 3 commits intomainfrom
roblou/missing-guineafowl

Conversation

@roblourens
Copy link
Copy Markdown
Member

Co-authored-by: Copilot copilot@github.com

Co-authored-by: Copilot <copilot@github.com>
Copilot AI review requested due to automatic review settings April 4, 2026 02:08
@roblourens roblourens enabled auto-merge (squash) April 4, 2026 02:08
@roblourens roblourens self-assigned this Apr 4, 2026
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

This PR adds SSH remote agent-host process reuse by persisting remote CLI agent-host state (PID/port/token) in a state file and attempting to reconnect to an existing process before starting a new one, reducing orphaned code agent-host processes on reconnect.

Changes:

  • Add reusable SSH helper utilities to read/write/validate a remote .agent-host-state file and to clean up stale processes.
  • Update the SSH connect flow to (1) detect an existing remote agent-host, (2) reuse it when possible, and (3) fall back to cleanup + fresh start when reuse is not connectable.
  • Add node tests covering helper behavior and the end-to-end connect/reuse/cleanup flow via in-process mocks.
Show a summary per file
File Description
src/vs/platform/agentHost/node/sshRemoteAgentHostService.ts Integrates remote agent-host reuse into the SSH connect flow; refactors to allow test overrides and uses DisposableMap for connection lifecycle.
src/vs/platform/agentHost/node/sshRemoteAgentHostHelpers.ts New helper module for shell-safe paths, platform detection, token redaction, and state-file based process reuse/cleanup.
src/vs/platform/agentHost/test/node/sshRemoteAgentHostHelpers.test.ts Unit tests for helper utilities (token validation, state parsing/cleanup, state writing).
src/vs/platform/agentHost/test/node/sshRemoteAgentHostService.test.ts Connect-flow tests validating caching, reuse via state, stale cleanup, relay-failure fallback, and sanitization behavior.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 3

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

This PR extends the SSH-based remote agent host bootstrap to persist and reuse a previously-started code agent-host process by recording its PID/port/token on the remote machine, reducing orphaned processes and reconnect overhead.

Changes:

  • Add remote “agent host state file” helpers to record and detect an existing running agent host via PID/port/token.
  • Update SSHRemoteAgentHostMainService.connect() to reuse an existing agent host when possible, and fall back to starting fresh on relay failures.
  • Add new unit tests for the helper utilities and the connect/reuse/fallback flow.
Show a summary per file
File Description
src/vs/platform/agentHost/node/sshRemoteAgentHostService.ts Implements process reuse via remote state file lookup + relay fallback behavior; refactors native module loading for testability.
src/vs/platform/agentHost/node/sshRemoteAgentHostHelpers.ts New helper module for shell-safe paths, state file read/write, reuse detection, and cleanup.
src/vs/platform/agentHost/test/node/sshRemoteAgentHostHelpers.test.ts Adds coverage for state parsing/validation, shell escaping, URL building, and cleanup/write behavior.
src/vs/platform/agentHost/test/node/sshRemoteAgentHostService.test.ts Adds connect-flow tests for caching, reuse via state file, stale PID behavior, and relay-failure fallback.
src/vs/workbench/contrib/chat/test/common/model/objectMutationLog.perf.test.ts Adds an opt-in perf benchmark for Chat ObjectMutationLog (appears unrelated to agentHost SSH changes).

Copilot's findings

  • Files reviewed: 5/5 changed files
  • Comments generated: 2

Co-authored-by: Copilot <copilot@github.com>
@roblourens roblourens merged commit 21cd6ee into main Apr 5, 2026
19 checks passed
@roblourens roblourens deleted the roblou/missing-guineafowl branch April 5, 2026 21:16
@vs-code-engineering vs-code-engineering bot added this to the 1.115.0 milestone Apr 5, 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.

3 participants