Repository navigation
Description
Summary
On an SSH-managed remote agent host, scheduled Automations and send_remote_message work only while an Agents window is connected. After the last window disconnects (for example, the laptop sleeps), the server idle-retires and nothing brings it back until a window reconnects. Due runs are deferred, not failed. Remote messages to that host are rejected.
The only built-in way to keep a self-hosted host available is GitHub-environment registration. That mode holds the server lifetime and, since #348787, installs CLI-owned execution credentials. It requires the organization's remote-control policy ("Store local sessions in the Cloud" = "View and control") and keeps the host resident indefinitely. Organizations that don't enable cloud session storage have no way to run scheduled agent work on their own SSH hosts while no client is connected.
Environment
- VS Code 1.146.0 stable, commit
69047191fc427f2f92828279aae1d90d8eeda7ab; behavior re-checked in source at maindcb1ee528d4177b2afb7fcac4d97d421d2740574(2026-11-17) - Linux SSH-managed agent hosts, macOS Agents window, Copilot SDK provider
- Organization remote-control policy not enabled (
--github-environmentis refused: "GitHub environment hosting is disabled by remote-control policy")
Current behavior
- Lifetime. The server lifetime token is held only by active sessions, connected WebSocket clients, or a registered GitHub environment (serverAgentHostManager.ts#L138, #L384). An enabled automation with an imminent trigger does not hold it. We observed
ServerLifetime: all consumers inactive, shutting downabout six minutes after the laptop slept, with no turn active. - Credentials. An SSH host's Copilot credential is pushed by the connected client. Host-owned execution credentials are installed only in GitHub-environment mode (#L235-L238). A server restarted without a client reports
isReadyForAutomationfalse (copilotAgent.ts#L3987), so due runs are deferred (agentHostAutomationService.ts#L1240) until a window connects. - Routing.
send_remote_messagerejects a target whose provider is "not registered and connected in this Agents window" (remoteSessionMessageRouter.ts#L130). Connecting a managed SSH host already launches it on demand, but the router doesn't attempt that connection. - Send Later (scheduled follow-ups into an existing chat) is limited to the local desktop host (AUTOMATIONS.md#L64).
Net effect: a recurring automation on a self-hosted SSH host runs only while some window is connected. Otherwise it waits and catches up, coalesced, on the next connection.
Requested behavior
Any of these would help, in increasing order of reach:
- Reconnect on demand. When the Agents window routes a message (or a user sends) to a known SSH/WSL host that is disconnected, attempt the normal managed connection before rejecting. Keep the current error for hosts that can't be reached.
- Schedule-aware lifetime. Let enabled automations whose next trigger falls within a configurable horizon hold the lifetime token, so the server, and the client credential it holds, survive until a due run instead of retiring minutes before it. Hosts with no imminent triggers still retire.
- Clientless scheduled execution without cloud session storage. Under an explicit local opt-in that doesn't require GitHub-environment registration or the remote-control policy, allow a self-hosted host to use CLI-owned OAuth execution credentials (the agentHost: use CLI host OAuth credentials for Mission Control #348787 path). Have the CLI supervisor relaunch the server at the next due trigger time and let it retire after the run. This makes schedules independent of any client, with no resident process while idle.
Upgrade behavior should stay as today: relaunches use the version-matched CLI the managed SSH launcher already installs.
Related
- agentHost: Keep remote hosts alive while agents are running #338392 keeps remote hosts alive while agents are running; it covers active turns, not future triggers.
- sessions: Share SSH, WSL and tunnel agent hosts as GitHub environments #347402 / agentHost: use CLI host OAuth credentials for Mission Control #348787 share self-hosted hosts as GitHub environments with CLI-owned credentials; this is the policy-gated path described above.
- Agent host: chat created while the remote host connection is down cannot be restored (Session identity was not advertised) #344932 (chat created while the remote host is disconnected can't be restored) is a different failure: restore, not activation.
- Allow restarting a remote agent host (SSH/WSL/Dev Container) from the UI #348798 (restart a remote agent host from the UI) is manual recovery, not activation.
We'll add a comment describing our interim local stopgap once it is running.
Filed by an AI assistant at the user's explicit request, based on source inspection and one observed idle retirement. No cold-start experiment was run.
Activity
wcushing-st commentedon Nov 17, 2026
Interim local stopgap, as mentioned above, in case the design helps with item 3:
copilot -p <prompt> --no-ask-user --allow-all-tools --deny-tool 'shell(sudo:*)' --secret-env-vars COPILOT_GITHUB_TOKEN.COPILOT_GITHUB_TOKENcomes fromgh auth token, and that existing OAuth login is the only credential. Neither the Agent Host nor any window is involved.flock. A failed run (nonzero exit, or the queued items still unclaimed afterwards) is recorded and pauses runs for an hour. The script checks this issue once a day and flags itself for removal when it closes.What it lacks, which item 3 would provide:
ghOAuth login.Posted by an AI assistant at the user's request.
miguel-jose-fernandes-meopt commentedon Nov 29, 2026
Same behavior with "code agent host --tunnel" (dev tunnel, not SSH)
Environment:
What happens:
Even though the service runs 24/7, the automations stop a few minutes after the last browser/VS Code client disconnects:
ServerLifetime: all consumers inactive, shutting down
Server process exited: Ok(ExitStatus(unix_wait_status(0)))
Agent host supervisor idle for 300s with no connected clients; shutting down
The tunnel CLI starts the server with --enable-remote-auto-shutdown. This flag is built into the CLI, and neither "code agent host" nor "code tunnel" has an option to turn it off. systemd's Restart=always doesn't help because the tunnel process never exits. Only the server under it retires, and it comes back only when a client reconnects.
Our workaround:
We patch ~/.vscode/cli/servers/*/server/bin/code-server to drop that single argument before running server-main.js:
for a do shift; [ "$a" = "--enable-remote-auto-shutdown" ] || set -- "$@" "$a"; done
Request:
A supported, simple way to run Agents Window automations on a specific machine/environment without a user having to stay connected 24/7. For example: