Skip to content

feat: show when a session's runner is away or can't reach its agent - #69

Merged
kalaspuff merged 4 commits into
mainfrom
fctl/30-get-working-on-the-remaining-parts-of
Oct 18, 2026
Merged

kalaspuff merged 4 commits into
mainfrom
fctl/30-get-working-on-the-remaining-parts-of

Conversation

@fctl-sh

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

Copy link
Copy Markdown
Contributor

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:

  • "Runner now hasn't been heard from since 02:26. The agent's work shows up here when it's back, and messages you send reach the agent then." when the session's uplink closed, or went quiet.
  • "Runner now hasn't been able to reach the agent in its sandbox since 02:26: nothing came from fctl-agent for a minute. It keeps trying. The agent's work shows up here when it gets through, …" when the host says it can't reach fctl-agent.

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 attach prints 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.

  • The host reports over the session's uplink once it has known for 10 seconds that no link to fctl-agent works (UplinkUp::AgentLink, Reach in crates/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.
  • SessionDO notes when it last heard from the uplink, in the socket's attachment at most every 5 seconds, and counts an uplink that sent nothing for a minute as away. Hosts ping every 20 seconds, but a frozen or cut-off host (a laptop that slept) can leave its socket open. SessionDO has no timer while its sockets hibernate, so viewers' pings, every 25 seconds, and new viewers check. Viewers get runner_last_seen_at and agent_unreachable in the snapshot, and last_seen_at and agent_unreachable in runner_connected.

docs/architecture.md (Viewers, Sandboxes and drivers), docs/getting-started.md and docs/cli.md say 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_connected gained fields instead of a new viewer message, which older fctl attach would warn about. The agent-link report needs a host release; there is no agent change and no migration.

How I verified it

  • Unit tests: when the host reports (liveness::tests), the optional fields both ways (fctl-proto), what fctl attach prints 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.
  • Against 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=1500 in the project's environment) so that a tool call lasts a few seconds:
    • A frozen agent. I stopped the session's fctl-agent with SIGSTOP as its tool call reached the transcript. A minute later the host dropped the link and kept attaching again. The page and fctl attach then 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.
    • A killed host. SIGKILL mid-turn: 10 seconds later the page said the runner hadn't been heard from since then. Restarted, the host recovered the sandbox, the notice went away and the turn finished.
    • A frozen host. SIGSTOP mid-turn with fctl attach connected: 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.
● running
I'll take a look at that. You asked: "check the tests". Let me inspect the repository first.
⏺ Bash(ls -la)
◌ runner dev-host can't reach the agent in its sandbox (last reached 3m ago): fctl-agent did not say hello within 30 seconds; it keeps trying

Screenshots

At aa10df9, against cargo xtask dev, with main'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:

  • A frozen agent, light and dark at 1440 px, and light at 390 px. Before: the tool call spins with "Working" under it, and nothing else. After: the tool call shows its icon, the transcript ends with the amber notice that the runner hasn't been able to reach the agent since 01:49 PM, and why, and the header says "Agent unreachable since 01:49 PM".
  • A killed host, light at 1440 px, and dark at 390 px. Before: the same spinner and "Working". After: "Runner dev-host hasn't been heard from since 01:54 PM", with the grey runner dot.

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

  • Item 1, the trigger, needs host.log from the runner.
  • Item 7, and the grace period and disk, wait on the decisions in the issue.

Refs #46

Session: https://app.fctl.sh/s/ses_01M57HG0XSAWK0CZXYRTVFZBV4

fctl-sh Bot added 4 commits October 18, 2026 13:21
… 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
@kalaspuff
kalaspuff merged commit 09e45b9 into main Oct 18, 2026
4 checks passed
@kalaspuff
kalaspuff deleted the fctl/30-get-working-on-the-remaining-parts-of branch October 18, 2026 14:13
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, light: the session stays stopped and shows none of the
agent's
work](https://app.fctl.sh/api/v1/published/A7JpF3Jwg6y9vIN1k7W9Cqsp99h6WITrSrJU4Z3LfK4/before-light.png)
| ![After, light: the runner is back, and the agent's turn
follows](https://app.fctl.sh/api/v1/published/RJBgDDw10URrj8Pknm9r7GEtSJdo0hCT45VdBZqejl4/after-light.png)
|
| ![Before,
dark](https://app.fctl.sh/api/v1/published/8T3PzGdBfZ8nmMv5LleJjFc67jKDv1TF9FNjUek2fGD/before-dark.png)
| ![After,
dark](https://app.fctl.sh/api/v1/published/hAhLLBQbvDwfiPWVLKnkhjsVwzB4kqHbbljC1DTXKaP/after-dark.png)
|
| ![Before, light at 390
px](https://app.fctl.sh/api/v1/published/oE72upiGw3yr5WuA0uJ2nJCEZwe0ZMcIp1yn9bBNK13/before-light-390.png)
| ![After, light at 390
px](https://app.fctl.sh/api/v1/published/5HvIJs7XAhWJtFEX5CF2kYzjvuCf2dSedUlR9VPtiWk/after-light-390.png)
|

- **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>
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