Skip to content

fix(control): let sessions carry on when their runner comes back - #94

Merged
kalaspuff merged 5 commits into
mainfrom
fctl/46-look-if-there-s-anything-left-to-do-on
Oct 18, 2026
Merged

kalaspuff merged 5 commits into
mainfrom
fctl/46-look-if-there-s-anything-left-to-do-on

Conversation

@fctl-sh

@fctl-sh fctl-sh Bot commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

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 (feat: show when a session's runner is away or can't reach its agent #69), and a session stopped for it comes back with its runner.
  3. Disk: feat(host): make room when the disk runs low #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: A stalled host freezes transcripts and stops sessions whose agents are still working #46's item 6, from feat: show when a session's runner is away or can't reach its agent #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 (fix(agent): keep sessions up while agents wait for background tasks #91, feat(host): make room when the disk runs low #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, light: the session stays stopped and shows none of the agent's work After, light: the runner is back, and the agent's turn follows
Before, dark After, dark
Before, light at 390 px After, light at 390 px
  • 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

fctl-sh Bot and others added 5 commits October 18, 2026 19:06
A runner away for ten minutes loses its sessions: FleetDO marks them
stopped. When the runner came back with an agent still at work, the
fleet stopped that agent as if the session had been deleted, and what
it did meanwhile never reached the transcript.

FleetDO now remembers the sessions it stopped for their runner's
absence. When the runner comes back with one, and no other run has
started since, the session carries on there: FleetDO assigns it again,
restores its runner so the host's uplink can replay the agent's events,
and the transcript says the runner is back. A session that moved to
another runner meanwhile, that someone stopped, put away or deleted,
still stops, with a reason that says which.

Refs #46
…back

ADR 0018 records the answers to #46's open questions: sessions stopped
for their runner's absence carry on when it comes back, the grace
period stays at ten minutes, and disk moves to #76.

Refs #46
…s up on it

When the fleet stopped a session because its runner stayed away,
SessionDO sent viewers the runner's state before the session's: no
runner, so no absence to report, for a session still running. fctl
attach took that for the runner's return and printed "runner … is
back" just before "stopped". SessionDO now sends the runner's state
after the summary.

Refs #46
A runner that comes back after its session moved to another runner
gets its old run stopped. When that run ended, FleetDO took its report
for the session's end and marked the session stopped, though it ran on
the other runner: it only ignored reports of earlier runs on the same
runner. A report from a runner the session doesn't run on is now
ignored too (fctl_domain::reconcile::ended_earlier).

Refs #46
ADR 0018 and 0019 went to #91 and #93 meanwhile, so this branch's ADR is
0020 now. #93 settled what hosts do about disk, which 0020 now points to.
@kalaspuff
kalaspuff merged commit 32df801 into main Oct 18, 2026
5 checks passed
@kalaspuff
kalaspuff deleted the fctl/46-look-if-there-s-anything-left-to-do-on branch October 18, 2026 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant