Repository navigation
agentHost: Keep remote hosts alive while agents are running - #338392
Logan Ramos (lramos15) merged 4 commits into
Conversation
The --idle-timeout supervisor on remote agent hosts only counted connected clients, so it shut the agent host down 300s after the last client disconnected, even while a turn was still running. It now also counts the agent host server process as activity. The server already stays up while a turn is running and exits on its own once idle. Server exit is detected from the process itself rather than from its output pipes closing. Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Process reaping introduces a PID-reuse race that could terminate an unrelated process tree.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Keeps remote agent hosts alive while agent turns remain active and improves process-exit tracking.
Changes:
- Treats the server process as idle-timeout activity.
- Detects exit directly from the child process.
- Adds lifecycle and forced-kill regression tests.
| File | Description |
|---|---|
src/vs/platform/agentHost/node/sshRemoteAgentHostHelpers.ts |
Updates lifecycle documentation. |
cli/src/tunnels/idle_timeout.rs |
Documents server activity semantics. |
cli/src/tunnels/agent_host.rs |
Refactors process ownership, termination, and tests. |
cli/src/commands/args.rs |
Updates idle-timeout help text. |
cli/src/commands/agent_host.rs |
Shares activity tracking with the manager. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
The task that owns the server process reaps it before the running-server state is cleared, so kill_running_server could run kill_tree on a PID the OS had already reassigned. Kill requests now go through that task, which either reaps a process that exited on its own or kills it before reaping. Co-authored-by: Copilot <[email protected]>
|
Non-blocking simplification suggestion: |
start_server already spawns run_server and awaits only its readiness barrier, so run_server now waits for the process to exit or a kill request itself instead of handing the process to a second task. This leaves one owner for the process through startup, kill, and reap. The output reader stays a separate task because descendants can keep the pipes open after the server exits. Co-authored-by: Copilot <[email protected]>

Remote agent hosts started with
--idle-timeout(managed SSH, WSL, and dedicated tunnel hosts) shut down 300 seconds after the last client disconnected, even while an agent was still running, which killed the in-progress turn.The CLI supervisor now counts the agent host server process as activity. The server already stays up while a turn is running and exits on its own once idle, so running agents no longer count as idle. Server exit is now detected from the process itself instead of its output closing, so a leftover child process can't keep the supervisor alive.
Notes for reviewers: