Repository navigation
Description
When the host restarts, it recovers each running session in two steps. It starts fctl-agent again in case it is gone (the None branch of run in crates/fctl-host/src/session.rs: "restarting fctl-agent in …"), then attaches to it. Usually fctl-agent is still running. The second fctl-agent serve then does two things:
- It connects to the socket to see whether a supervisor is there (
link::bindincrates/fctl-agent/src/link.rs). The running supervisor takes that connection for a host link. It sends it a hello, makes it the current link, and drops it when it closes. - It exits with an error:
ERROR fctl_agent: fctl-agent stopped: another fctl-agent is already serving …in~/.fctl/agent.log.
This is session 37's agent log from when fctl host restart ran:
16:55:33.421793Z INFO host link 1 detached
16:55:33.779748Z ERROR fctl-agent stopped: another fctl-agent is already serving /home/agent/.fctl/agent.sock
16:55:33.779782Z INFO host link 2 attached; journal at agent_seq 876, 876 acknowledged
16:55:33.779905Z INFO host link 2 detached
16:55:33.934255Z INFO host link 3 attached; journal at agent_seq 876, 876 acknowledged
16:55:34.043598Z INFO replaying 0 events after agent_seq 876 to host link 3
Here the probe (link 2) came 155 ms before the host's real attach (link 3), so it did no harm. But nothing orders the two: the host starts serve with a detached exec and attaches right after. The probe can come after the attach, in a busy sandbox or with a faster runtime. It then replaces the real link and closes, leaving the supervisor with no current link. The supervisor ignores the host's frames, and the session's viewers see the agent unreachable. That lasts until the host gives up on the silent link after a minute and attaches again.
What should happen
- A second
fctl-agent servefinds the running supervisor without connecting to its socket, so the supervisor keeps its host link. A lock file the supervisor holds would do. - It exits quietly, with an info line in the log instead of an error.
Compatibility
This changes fctl-agent only. Sandboxes get the new binary when a session starts or resumes; until then, a running agent behaves as it does now. A new serve next to an older supervisor, which holds no lock, falls back to probing the socket as now.
Refs #1
Activity
fctl-sh commentedon Oct 18, 2026
Fixed by #82, merged as 450b4b1. This changes fctl-agent, so it ships with the next release; no release contains it yet. A sandbox gets the new agent when a session starts or resumes on a host of that version. Until then, running agents behave as before.