Repository navigation
feat: show when a session's runner is away or can't reach its agent - #69
Merged
Merged
Conversation
… the agent The host reports over the session's uplink when it has had no working link to fctl-agent for 10 seconds (UplinkUp::AgentLink), and again after it reconnects. SessionDO notes when it last heard from the uplink, counts one that sends nothing for a minute as away, and gives viewers both in the snapshot and runner_connected, as optional fields. The session page says so at the end of the transcript and in the header, and shows no work in progress meanwhile: a tool call without a result spins only while the session runs and its work comes through. fctl attach prints the same. A runner gone for less than 10 seconds (a host restarting) goes unmentioned. Refs #46
A tool call whose result never reached the control plane (a crash, or a result lost on a reconnect) spun for as long as the page was open. It now runs only in the turn in progress. Documents what viewers learn about the runner, and what the session page and fctl attach say. Refs #46
…when the host noticed A host that wakes up (a laptop that slept, or a frozen process) finds its links silent for longer than a minute and attaches again within a second or two. Counting the 10 seconds from when the agent was last heard made it report the agent as unreachable at once, and as reachable a moment later. The time it reports is still when it last heard from the agent. Refs #46
…n-the-remaining-parts-of # Conflicts: # docs/getting-started.md
This was referenced Oct 18, 2026
kalaspuff
pushed a commit
that referenced
this pull request
Oct 18, 2026
In #46, runner `now` went quiet for half an hour while its agent kept working. After ten minutes the fleet marked the session stopped. And when a runner came back with an agent still at work, the fleet told its host to stop that agent "because the session was deleted": the agent was interrupted, and what it did meanwhile stayed in its sandbox's journal, because the session was no longer the runner's and the host's uplink was refused. This does item 7 of #46, and settles the decisions it left. ## What changes - **A session stopped only because its runner was away carries on when the runner comes back with it.** FleetDO remembers the sessions it stops for their runner's absence (`stopped_away`, in its storage). When that runner's hello reports one of them running, and no other run of it has started since, FleetDO assigns it to the runner again and gives the session back its runner. The host's uplink then gets in and replays the agent's journal, so the transcript fills in what the agent did meanwhile. The transcript says "Runner now is back with the agent still running, so the session carries on there." - **So does a session resumed meanwhile that no runner took.** With one runner, a message to the stopped session queues it ("Waiting for a runner"). When the runner comes back, the agent that still runs gets the message, rather than being stopped for a new run. - **Otherwise the old run stops, with a reason that says why**: - `Shutdown` when the session runs on another runner by then; - `Deleted` when its project was deleted; - `User` when someone stopped or archived it. All of them used to get `Deleted`. - **The stopped status says what happens**: "Runner now has been offline for 10 minutes. If it comes back with the agent still running, the session carries on there; a message resumes it on another runner." It used to end "Resume the session to continue elsewhere." - The decisions are pure functions in `fctl_domain::reconcile`, with unit tests. - Docs: `docs/architecture.md` (A runner that goes away), `docs/getting-started.md`, and ADR 0020. ## Found on the way, fixed here - **A session that moved to another runner was marked stopped when its old run ended.** When a runner came back after its session had moved, FleetDO stopped the old run, and the old run's end then marked the session stopped, though it ran on the other runner. FleetDO ignored only the ends of earlier runs on the same runner. It now also ignores a report from a runner the session doesn't run on (`reconcile::ended_earlier`). `main` takes this path too, with `StopReason::Deleted`. - **`fctl attach` printed "runner now is back" just before "stopped"** when the fleet gave up on a runner. SessionDO sent the runner's state before the session's, so `fctl attach` saw no absence for a session it still thought active. It now sends it after the summary. ## Decisions #46 left three questions for a person. The person who started this session asked for what was left of #46 to be done, so this takes the answers suggested in the issue, and ADR 0020 records them: 1. A session stopped only because its runner was away carries on when the runner comes back with it (above). 2. The grace period stays at ten minutes: the session page says at once that a runner is away (#69), and a session stopped for it comes back with its runner. 3. Disk: #93 settled it meanwhile (ADR 0019): hosts keep a floor of free disk, measured where their sandboxes are, including Docker's VM on macOS, and take no new sessions below it. Quotas per sandbox are left out. ## Compatibility Control plane only: no protocol change, no migration (FleetDO's new table is created with `IF NOT EXISTS`), and no host or agent release. Hosts already report their sessions in every hello. FleetDO's internal `ControlState` for SessionDO gains an optional `notice`. ## How I verified it - Unit tests: `fctl_domain::reconcile`: which reported runs carry on, are kept or stop, with which reason, and which ended runs are earlier ones. - `cargo xtask check`, before and after merging `main`. - End to end against `cargo xtask dev`, with its host started on its own so that I could kill it (`SIGKILL`: the process driver's agents keep running), and fake-claude slowed down (`FAKE_CLAUDE_DELAY_MS`). To keep the waits short, cases 1 to 4 and 6 ran on a control plane built with the grace period at one minute; case 5 used the real ten minutes. 1. **Carry on.** The host killed mid-turn. Ten seconds later `fctl attach` said `◌ runner dev-host is away (last heard from just now); the agent's work shows up here when it's back`: #46's item 6, from #69. The fleet then stopped the session with the new wording, while the agent finished its turn in the sandbox: journal at `agent_seq` 15, 5 acknowledged. With the host back, the session went idle, the transcript said the runner is back, and the replay brought the turn: `Bash(ls -la)`, `Write(away.md)`, the commit and the result. 2. **A message while the runner was away, and no other runner.** The message queued the session ("Waiting for a runner"). With the host back, the session carried on, the replay brought the turn the agent had finished meanwhile, and the agent then took the message and wrote its file in the same sandbox and conversation. 3. **Moved elsewhere.** With a second host, `dev-host-2`: the first host killed, the session stopped, and a message resumed it on `dev-host-2` in a new sandbox. When the first host came back, its old run stopped (`Shutdown`; FleetDO logged `ignoring the end of an earlier run`), and the session stayed idle on `dev-host-2`. Before the `SessionEnded` fix it showed "Stopped because the host is shutting down" instead. 4. **Archived while away.** The old run stopped when its host came back (`User`), and the session stayed stopped and archived. 5. **Ten minutes.** Case 1 with the grace period as shipped. The fleet stopped the session 10 minutes 2 seconds after the host was killed. When the host came back, the session carried on and the replay brought the agent's turn. Six seconds later the agent stopped on its own ("Stopped after being idle"): it had finished its turn ten minutes before, and the idle timeout is ten minutes too. 6. **After merging `main`** (#91, #93), case 1 again, with the host and the control plane built from the merge. ## Screenshots At 46cdef2, before merging `main`, which doesn't change these screens. The session page after its runner was killed mid-turn, stopped by the fleet, and brought back, with this branch's control plane and with `main`'s, against the same local state. | Before (`main`) | After | |---|---| |  |  | |  |  | |  |  | - **Before:** "Runner dev-host has been offline for 10 minutes. Resume the session to continue elsewhere." When the runner came back, the fleet stopped the agent ("Stopped (forced)"), and the turn it finished meanwhile never showed: 0 turns, no changes. - **After:** the stopped line says the session may carry on, a blue notice says the runner is back, and the agent's turn follows: listing files, writing `notes.md`, the commit, "Turn finished". The session waits for a message. Refs #46 Session: https://app.fctl.sh/s/ses_01M585PP4R26Y6BKA64816JD1W --------- Co-authored-by: fctl-sh[bot] <343971779+fctl-sh[bot]@users.noreply.github.com> Co-authored-by: fctl-sh[bot] <fctl-sh[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In #46 a session's transcript froze on a spinning tool call for half an hour while its agent kept working, and nothing on the page said so. The only sign was a dot beside the runner's name in the side panel: hidden at phone widths, and green as long as the session's uplink stayed open, which it does when only the host's link to the agent is broken. This is item 6 of #46: the session page says when the agent's work stops coming through, and why.
What the page says. At the end of the transcript, in place of work in progress:
The header says it in a few words too ("Runner not heard from since 02:26", "Agent unreachable since 02:26"), so it shows when the page is scrolled up, and the runner's dot turns amber when the agent can't be reached. Meanwhile nothing looks in progress: no spinning tool call, no "Working", no typing caret. A runner gone for less than 10 seconds, such as a host restarting, goes unmentioned.
fctl attachprints the same, and says when the runner is back.A tool call now spins only in the turn in progress. One from a turn that ended without its result (a crash, or the lost event below) used to spin for as long as the page was open.
How it knows.
UplinkUp::AgentLink,Reachincrates/fctl-host/src/liveness.rs): since when, which is when it last heard from the agent, and what went wrong last. It reports that it reaches the agent again when a link says hello, and repeats the report after every reconnect. The 10 seconds count from when the host noticed, because a host that wakes up from sleep finds its links silent and attaches again within a second or two.runner_last_seen_atandagent_unreachablein the snapshot, andlast_seen_atandagent_unreachableinrunner_connected.docs/architecture.md(Viewers, Sandboxes and drivers),docs/getting-started.mdanddocs/cli.mdsay how it works.Compatibility
Optional fields only, plus a new uplink message that older control planes log as unknown and ignore. Older hosts never report the agent link; their sessions still get the runner-away notice, which is all control plane. Older web apps and CLIs ignore the new fields:
runner_connectedgained fields instead of a new viewer message, which olderfctl attachwould warn about. The agent-link report needs a host release; there is no agent change and no migration.How I verified it
liveness::tests), the optional fields both ways (fctl-proto), whatfctl attachprints and when (stall::tests), the page's wording, days and grace (stall.test.ts), and when tool calls spin and the notice shows (transcript.test.tsx).cargo xtask check --quick.cargo xtask dev, with its host started on its own so that I could kill it, and fake-claude slowed down (FAKE_CLAUDE_DELAY_MS=1500in the project's environment) so that a tool call lasts a few seconds:fctl attachthen said the runner couldn't reach the agent since the freeze, with the host's latest reason. After SIGCONT the host attached again, the notice went away, the journal replayed and the turn finished.fctl attachconnected: 71 seconds later it said the runner was away, and right after SIGCONT that it was back. Frozen for longer than a minute, the host found its link silent and attached again within 2 seconds without reporting the agent as unreachable. The first version did report it, for a second, which is why the wait now counts from when the host noticed.Screenshots
At aa10df9, against
cargo xtask dev, withmain's web app beside it for the before. This session can't attach them (#40); they were sent to the person who started it. What they show:Found on the way
Resuming the frozen agent once lost a tool's result from the transcript for good: the agent sent newer events over its new link before the host's replay of the older one, SessionDO stored them, and then took the replayed one as already stored. It can happen whenever a link or an uplink reconnects during a turn, a deploy included. It's a control-plane fix of its own: #70.
What's left of #46
Refs #46
Session: https://app.fctl.sh/s/ses_01M57HG0XSAWK0CZXYRTVFZBV4