Skip to content

feat: stop idle sessions after ten minutes and resume them for a message - #67

Merged
kalaspuff merged 2 commits into
mainfrom
fctl/29-let-s-get-started-on-https-github-com-hy
Oct 18, 2026
Merged

kalaspuff merged 2 commits into
mainfrom
fctl/29-let-s-get-started-on-https-github-com-hy

Conversation

@fctl-sh

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

Copy link
Copy Markdown
Contributor

A session holds a slot on its runner from the moment it starts until its sandbox stops. A session that finished its turn and waited for a reply kept that slot for its project's idle timeout, two hours by default, so busy runners filled up with sessions that did nothing, and new work waited until someone stopped them by hand. This does the last item of #56: idle sessions stop after about ten minutes, and a follow-up picks the work up again.

What changes

  • Idle sessions stop after ten minutes unless the project sets another idle timeout. Projects that set one keep it. The default lives in fctl_domain::settings (DEFAULT_IDLE_TIMEOUT_MINUTES), and fctl projects set --idle-timeout MINUTES sets a project's own (fctl projects show prints it). The web app's field shows the new default with a line about what it does.
  • A message resumes a stopped session from the web app, fctl send, fctl attach and the API, for anyone who may message the agent. Before, only owners typing in the web app could resume one this way; fctl send, fctl attach and editors got "The session has ended. Resume it to continue." SessionObject queues the session when it stores the message, and the new run gets the message from the outbox. The run uses the Claude subscription the session ran on, as a message to an idle session does. Resume (owners, fctl resume) still runs it on the resumer's subscription, and is still the only way to start a failed session again. Messages to a failed session get "The session failed. Resume it to continue.", and editors see that note in place of the composer.
  • A resume goes back to the runner that has the sandbox. Until now a resume went to the least loaded runner, so with more than one machine it could start in a new sandbox, without Claude's conversation or the agent's uncommitted work. With a ten-minute timeout that would happen much more often. FleetDO now remembers which runner last took each session (a sandboxes table in its storage) and starts a resume there. While that runner is full, the session waits for it ("Waiting for studio, which has this session's sandbox") for up to ten minutes, then starts elsewhere. It starts elsewhere right away if the runner is offline or too small for the session's size now. This applies to Resume too.
  • Two runs of a session never overlap. A message that comes while the session stops queues it; FleetDO starts the new run once the runner no longer reports the old one ("Starting again once the last run has stopped"). While the session is queued, SessionObject ignores what the old run's uplink still reports about stopping. FleetDO's other end paths (a runner offline for ten minutes, a host that restarted without the sandbox) leave a session that was queued again in the queue, as the session-ended path already did.
  • fctl-agent's prompt for a resume in a new sandbox no longer says the old sandbox "was removed": the session may have moved to another machine.
  • Docs: docs/architecture.md (a new "Idle sessions" section), docs/getting-started.md, docs/cli.md, and ADR 0013 records the decisions.

Choices a reviewer may want to weigh in on

  • Whose subscription a wake uses. The session's own, so that whether the sandbox was still up changes nothing about who pays, and editors without a Claude connection can still follow up as they could within the idle timeout. The other option, the sender's subscription (as Resume does), would switch a session between people's subscriptions as they take turns replying.
  • Any stopped session wakes, including one a person stopped, not just those the idle timeout stopped. People stop sessions to free their machines, and a follow-up should pick the work up. The cost: an editor's message can restart a session its owner stopped.
  • Waiting ten minutes for the sandbox's runner before starting fresh elsewhere. Waiting keeps the conversation and uncommitted work; moving on keeps a busy machine from holding a follow-up for hours.

Compatibility

Control plane only: no protocol change, no migration (FleetDO's new table is created with IF NOT EXISTS), no host release needed. Hosts already stop idle sessions with the timeout in the spec, and a resume on the same host already restarts the stopped sandbox. The new default applies to sessions that start or resume after the deploy; running ones keep the timeout they started with. The fresh-resume prompt change reaches hosts with the next release. web/src/gen changes only in doc comments.

How I verified it

  • Unit tests: fctl_domain::schedule (a resume goes to its runner when it has room, waits for it when full and wait is set, starts elsewhere when it's offline, gone or too small), fctl_domain::settings (the default), fctl-agent's fresh-resume prompt.
  • cargo xtask check passes.
  • End to end with cargo xtask dev, a second process-driver host (dev-host-2, capacity 1) and a 1-minute idle timeout:
    1. A session went idle, stopped on its own after a minute ("Stopped after being idle"), and fctl send playground#1 "write notes.md" printed ✓ Sent to playground#1; the session resumes for it. It started on the same host within a second, and Claude's init had the same session_id as before (a9f40ebd…), so the conversation continued. It wrote and committed notes.md.
    2. fctl stop, then fctl send straight away: the session showed "Starting again once the last run has stopped" for about six seconds, then started. No "stopped" from the old run reached the transcript in between, and the conversation continued.
    3. With both hosts empty, where the tie goes to dev-host, a message to a session whose sandbox was on dev-host-2 started it on dev-host-2, same conversation.
    4. With dev-host-2 full and dev-host free, the session waited ("Waiting for dev-host-2, which has this session's sandbox") until dev-host-2 freed up a minute later, then started there.
    5. With dev-host-2 held for longer, it waited ten minutes and then started on dev-host in a new sandbox ("The earlier conversation went with the old sandbox; Claude starts a new one on the branch").
    6. An editor with no Claude connection typed into a stopped session in the web app (the viewer WebSocket path). It resumed on the session's subscription.
    7. A failed session (fake-claude crash four times): fctl send got The session failed. Resume it to continue., and the editor saw the note instead of the composer.

Screenshots

I took these with Playwright against cargo xtask dev, main beside this branch, but this session can't attach images to the pull request (#40). What they show, at 1440 px unless noted:

  • Session page, stopped session: the composer's placeholder changes from "Resume the session with a message…" to "Message the agent to resume the session…", and its hint (shown on focus) from "↵ resume" to "↵ send and resume · ⇧↵ new line". Same in both themes; it fits at 390 px.
  • Session page, failed session, as an editor: before, the composer offered "Resume the session with a message…", which failed with "Only the session's owner can do this". After, a note says "This session failed. Its owner can resume it."
  • Project settings, Sandbox: the idle timeout's placeholder changes from 120 to 10, and a line under the sizes reads "A session that waits for a message longer than the idle timeout stops, and its runner takes other work. A message resumes it." Both themes, and at 390 px.

Left for later

Draining a runner and what fctl host uninstall says (the first three items of #56) need the decisions listed in the issue, so they are not part of this pull request.

Refs #56

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

fctl-sh Bot added 2 commits October 18, 2026 13:23
Idle sessions held their runner's slot for two hours unless the project
set another timeout, so busy runners filled up with sessions that did
nothing and new work waited until someone stopped them by hand.

- The default idle timeout is ten minutes.
- A message to a stopped session resumes it, from every client and for
  anyone who may message the agent, on the subscription it ran on. A
  failed session still needs its owner's resume.
- FleetDO remembers which runner last took each session and starts a
  resume there, where Claude's conversation is, waiting up to ten
  minutes while it is busy.
- A resume waits for the last run to stop, and SessionDO ignores that
  run's late reports while the session is queued.

Refs #56
fctl projects set --idle-timeout MINUTES sets how long a session that
waits for a message keeps its sandbox and its runner's slot, and
fctl projects show says when the project's idle sessions stop.

Refs #56
@kalaspuff
kalaspuff merged commit 18e8e3b into main Oct 18, 2026
4 checks passed
@kalaspuff
kalaspuff deleted the fctl/29-let-s-get-started-on-https-github-com-hy branch October 18, 2026 13:51
kalaspuff pushed a commit that referenced this pull request Nov 14, 2026
…ge (#546)

## Summary

The spaghetti autopilot named "wake me when PR N merges" and "message
session X when PR Y merges" as the most common reasons it wrote watcher
scripts. Those scripts died at every handover. A crew session's pull
request that merged or closed while the session rested (its turn ended,
it stopped or failed) told the autopilot nothing until its check-in, up
to a day later. That hit hardest without the merge power, where people
merge, and with a session held back until another's merge.

Now, when GitHub says such a pull request merged or closed,
SessionObject wakes the autopilot. It's gathered a minute like other
crew wakes, whoever merged it. It counts the session as changed so that
the wake lists it, with `#67 merged` in its line. A session at work, one
waiting for its background work, or one just messaged (which counts
among those at work until its runner reports) doesn't wake it this way:
its turn's end does, with the pull request as it stands. The briefing
says so where it talks about merging, and the shared-layout lesson no
longer suggests a script to wait for the first merge.

I verified it with unit tests on the rule (which statuses wake, only a
pull request that newly ended) and in `cargo xtask dev`, through a
temporary route standing in for GitHub's webhook. With the autopilot
resting, nothing at work and its crew session stopped, marking that
session's pull request merged scheduled a wake at once. A minute later
the wake listed the session as `stopped (a message resumes it); pull
requests #67 merged`.

## Related pull requests

- #544
- #545

## Worth confirming

- **Decision:** a closed pull request wakes it too, not only a merged
one: the work it waited for won't land.
- **Decision:** the merge bumps the crew session's `updated_at`, which
the wake's news selects by, so the session also shows as recently
changed in lists. This applies only to sessions an autopilot started.

[fctl session](https://app.fctl.sh/s/ses_01M7DQEXFV9KNC4CY8ZZZ2KHZH)

<!-- FCTL_REVIEW_SUMMARY -->
---

> [!NOTE]
> **Medium risk.** It changes when autopilots are woken and bumps a
session's `updated_at` from the pull request refresh path, which the
working-session count in `CREW_WORKING` reads.
>
> **What it does.** Wakes an autopilot as soon as a pull request of one
of its crew sessions merges or closes while that session rests (idle,
stopped or failed), instead of at its next check-in. A session that is
working, waits for background work, or ended its turn and was just
messaged is left to wake the autopilot when its turn ends. The briefing
text and docs now describe this.
>
> **Working-count interaction.** The wake sets `updated_at` on the
session, which is why an idle session with a newer message is skipped:
`CREW_WORKING` counts it at work by `messaged_at >= updated_at`.
>
> <sub>[fctl
review](https://app.fctl.sh/s/ses_01M7DVSB36B7ZZ80H2ZN279X7A)'s first
look at
[`86494b4`](86494b4)
· 5 files, +154 −7 · [Review agent
settings](https://app.fctl.sh/p/fctl?tab=reviews)</sub>

<!-- /FCTL_REVIEW_SUMMARY -->

---------

Co-authored-by: fctl-sh[bot] <343971779+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