Skip to content

feat: run sessions in AWS Lambda microVMs - #665

Merged
kalaspuff merged 22 commits into
mainfrom
fctl/1743-agent-sessions-on-aws-lambda-microvms
Dec 1, 2026
Merged

kalaspuff merged 22 commits into
mainfrom
fctl/1743-agent-sessions-on-aws-lambda-microvms

Conversation

@fctl-sh

@fctl-sh fctl-sh Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A workspace can now run each of its sessions in an AWS Lambda microVM in its own AWS account. A new lambda driver for fctl host runs on any machine that may manage the account's microVMs (an instance's or task's role, keys, or a role it assumes) and drives them through Lambda's API and each microVM's endpoint, where fctl-agent microvm-serve, the image's program, answers Lambda's lifecycle hooks and serves the host the same exec protocol as the Firecracker driver, over a WebSocket only the host's key opens. The runner's owner or its workspace's admins choose its microVMs' settings on the Runners tab or with fctl runners microvms set: an image fctl builds from the sandbox image in their bucket and rebuilds as fctl updates, or one of their own; the size (512 MiB to 8 GiB, bursting to four times), architecture, execution role, egress connectors, KMS key and log group; when microVMs suspend and go; the warm pool; and whether sessions start there first. FleetDO hands them to the host, and the host reports its microVMs back.

A session's microVM suspends once the session has waited 90 seconds (by default) with nothing running, no turn and no background task, after its agent saved the session's snapshot. The session stays idle, its page says "microVM suspended", and anything for the agent (a message, a follow-up, a GitHub event) resumes it as it was. After 60 minutes suspended (by default), or as Lambda's 8 hours near, the host lets it go and the session stops; the next message carries it on in a new microVM from its snapshot. Warm microVMs, started then suspended, are taken by sessions of every kind as they start. Suspended sessions don't count against the runner's capacity, a full runner lets the longest-suspended one go for a new session, and a runner set to go first takes the workspace's sessions before its other runners.

  • Host and agent: the driver, its image builds and warm pool, suspend and resume in the session loop, and fctl-agent's checkpoint (HostToAgent::Checkpoint) and quiet state. A microVM AWS hasn't let go of (a terminate that failed, a run whose answer never came) stays on the host's books and is terminated again until AWS says it's gone.
  • Control plane: migration 0079 (three nullable columns on runners), GET and PUT /api/v1/runners/{id}/microvms, and scheduling that skips suspended sessions and puts first runners first.
  • CLI: fctl runners microvms show|set, fctl host install --driver lambda, fctl host microvm-image, and [lambda] in host.toml. fctl attach says when a microVM suspends and resumes.
  • Web: a section on the Runners tab (the life of a session's microVM, drawn; a card per runner with a pip per microVM; setup steps), a wide sheet with each microVM, the image, the host's AWS policy and the settings form, and the suspended state on the session page.
  • Development: cargo xtask dev --microvms runs a stand-in for Lambda (xtask/lambda) and a runner of its microVMs.
  • Docs: ADR 0106, the architecture, setup in Runners in your cloud, the CLI reference, Development and llms.txt.

Unit tests cover the domain's rules, the agent's checkpoint, the microVM server's HTTP and WebSocket handling, the protocol's compatibility with older peers, the control plane's API (in Node), the CLI and the web components; cargo xtask check passes. End to end, cargo xtask dev --microvms ran the whole path against the stand-in: a session took a warm microVM (its agent attached in about 40 ms) and the pool refilled; a minute after its turn its snapshot was saved and its microVM suspended; a message resumed it as it was; after 5 minutes suspended the host let it go and the session stopped; and a message then carried it on in a new microVM with its conversation restored. None of this has run against real AWS Lambda, since this sandbox has no AWS account: #664 tracks that.

Deploying needs migration 0079, which only adds nullable columns. MicroVMs need hosts and agents of this release; FleetDO sends the settings only to hosts that announce the microvms feature, and every new protocol field is optional.

Screenshots

At f723c9b, in cargo xtask dev --microvms against the stand-in for Lambda.

The Runners tab's microVMs section (light, 1440 px): the life of a session's microVM, drawn, and the dev runner's card with a pip for each of its 10 microVMs, one suspended with its session and one warm.

The Runners tab's microVMs section, light

The same on a phone (dark, 390 px): the card's facts wrap between them, and the drawing goes under the text.

The Runners tab's microVMs section on a phone, dark

A runner's microVMs in the wide sheet (dark): the counts, the image, each microVM with its session, the host's AWS policy behind Show it, and the start of the settings.

A runner's microVMs sheet, dark

Its settings further down (light): the image, size, whiles, warm pool and going first.

A runner's microVM settings, light

A session whose microVM is suspended (light, 1440 px): "microVM suspended" with a moon beside Waiting, the transcript's line, the message box, and the details' runner row.

A session whose microVM is suspended, light

The same on a phone (dark, 390 px).

A session whose microVM is suspended on a phone, dark

Worth confirming

  • Decision: A session whose microVM is suspended keeps the idle status rather than getting a new one: its page, its details, its message box and fctl attach say the microVM is suspended, and lists show it as waiting.
  • Decision: Once a microVM is let go, its session is stopped, with a reason that says a message carries it on, as any idle session that stopped would be. Where the workspace keeps no snapshots, the reason says the session starts again from its task and branch.
  • Decision: Review agents' sessions take warm microVMs but never suspend: they save no snapshots and stop once their review is posted.
  • Decision: The settings belong to the runner and live in the control plane, changed by its owner or its workspace's admins after they confirm it's them, rather than in host.toml. Members see the runner's microVMs, and its settings in a sentence.
  • Decision: A runner of microVMs shows only in its own section of the Runners tab, below the pools, never among the machines. Going first is off by default.
  • Decision: A runner at its most microVMs lets the longest-suspended session's microVM go for a new session, rather than making the new one wait, but only one whose snapshot was saved, and each once: where none has one, the new session waits for room.
  • Assumption: Lambda's microVM API (2025-09-09), its hooks and its endpoint's headers work as AWS's docs say: the driver was written from them and has run only against the stand-in (Try the lambda driver against real AWS Lambda microVMs #664).
  • Assumption: Lambda's image build can pull the public ghcr.io/hyperstructure/sandbox image the Dockerfile starts from.
  • Assumption: Processes an agent started outside Claude Code's background tasks (a nohup server, say) may freeze while the microVM is suspended and go with it. Background tasks keep a session from suspending.

Related pull requests

fctl session


Warning

High risk. It adds a new AWS Lambda microVM driver that starts, suspends, resumes and terminates billed cloud resources with assumed-role credentials, stores their state on the host, and touches the control plane, the database and the web app.

What it does. Lets a runner run agent sessions in AWS Lambda microVMs. The host starts, suspends, resumes and terminates microVMs, and keeps a warm pool. A session's snapshot is saved to S3 so a microVM can be let go and the session resumed later. Runners get microVM settings in the control plane and the web app, and docs explain how to set it up in your own cloud. Since the last review, the host remembers which suspended sessions it asked to give up their microVM, per suspension, so an ask no longer outlives the session's run or a resume.

Cloud resources and IAM. Whoever deploys it must give the host's AWS role the Lambda and S3 permissions in docs/runners-in-your-cloud.md. A microVM the host fails to terminate keeps billing until Lambda's 8-hour limit.

fctl review's first look at f74068c · 103 files, +12732 −158 · Review agent settings

fctl-sh Bot added 9 commits December 1, 2026 20:03
A new lambda driver runs each session in an AWS Lambda microVM: the
host resumes the one a session has, takes a warm one or runs a new one,
and reaches fctl-agent microvm-serve in it over WebSockets through the
microVM's endpoint. Sessions stay idle while their microVM is suspended:
after the settings' while with nothing running, the agent saves the
session's snapshot and the host suspends the microVM, resumes it for
whatever comes for the agent, and lets it go once suspended for the
settings' while. The runner's settings come from the control plane.
PUT and GET /api/v1/runners/{id}/microvms keep a runner's microVM
settings in D1 and send them to its host; FleetDO keeps what the host
says of its microVMs, counts suspended sessions as room, and places
sessions on runners whose settings say first before others. SessionDO
tells viewers when a session's sandbox is suspended.
…o xtask dev

fctl runners microvms show and set read and change a runner's microVM
settings; fctl host microvm-image writes what Lambda builds an image of
your own from; fctl host install --driver lambda checks that the machine
may manage microVMs. cargo xtask dev --microvms runs a host of the lambda
driver against a stand-in for Lambda MicroVMs, whose microVMs are
fctl-agent microvm-serve on this machine.
…ll of a microVM

A host of microVMs probes its driver every 2 seconds, in memory, and sends
a heartbeat when its microVMs or whether its driver is ready changed, so
that a runner whose settings or image just came takes sessions at once.
The stand-in's microVMs keep their homes under the temporary directory,
whose short paths leave room for the session socket, and suspending one
stops every process in it, as a real suspend does.
…ose microVM is suspended

The Runners tab has a section on AWS Lambda microVMs: what they do for
sessions, a drawing of a session's microVM over its life, each runner of
them as a card with a pip for each microVM it may have, and how to set one
up while there is none. A card opens a sheet with every microVM, its
image and, for those who manage the runner, its settings, checked as the
server checks them.

A session whose microVM is suspended says so beside its status, with a
moon and what a message does when hovered, in its details, and in its
message box.
Its conversation and the work it hadn't pushed only where its snapshot
was kept; where the workspace keeps none, a message starts it again from
its task and branch, as the Runners tab now says too.
…whole

The sheet is 520 px wide from 768 px, where its settings take two
columns; its contents are padded as wide as its header. A runner's card
wraps between its facts on a phone, and each microVM says what it does as
a phrase (Running for 5m, Warm, just started).
The architecture's AWS Lambda microVMs section and ADR 0106; setting up a
runner of them in Runners in your cloud, with the host's policy and the
build role; fctl runners microvms, fctl host microvm-image and the
[lambda] table in the CLI reference; cargo xtask dev --microvms in
Development; a recipe in llms.txt.

A runner's sheet shows the policy its host needs for its settings, open
by itself while AWS refuses the host something, which the host's error
now points to.
Native Clippy builds the control plane's tests too, without crate::testing,
and Clippy denies indexing there.
@fctl-review

This comment has been minimized.

Comment thread crates/fctl-control/src/do_fleet.rs Resolved
fctl-sh Bot added 4 commits December 1, 2026 21:43
Making the vm server serve Lambda microVMs too turned Firecracker's off by
default: a VM stopped without its memory saved lost what its disk hadn't
written, which the Firecracker sandboxes job caught.
…they're gone

The upkeep lets go only of microVMs whose session's run ended: a session
that runs lets its own go, saving its snapshot first. A microVM AWS hasn't
let go of (a terminate that failed, a run whose answer never came) is kept
as going-… and terminated again every 30 seconds, finding an unanswered
run's id by asking again with its client token. Saves write one at a time,
the newest last. The image's archive goes to S3 with the keys the host
calls Lambda with, a role it assumes included.
…n't answer

FleetDO sent no settings at all, which clear the host's, when reading them
failed; it now sends none only where the runner has none.
The field kept only the parsed list, so the line break or space after an
ARN vanished as it was typed.
@fctl-review

This comment has been minimized.

A run that failed is kept to let go of only where Lambda may have run it:
a timeout, a connection that broke once made, or a 5xx other than a
throttle or no capacity. A throttled or refused run, or one that never
left, is forgotten, and the warm pool waits while Lambda throttles or
can't be reached. Every microVM the host keeps counts against the most it
may have, those it lets go of too. A run a restart cut short, warm ones
included, is let go of once unanswered for 10 minutes, and a session finds
another rather than replaying a request that may have changed.
@fctl-review

This comment has been minimized.

A later try's throttle no longer hides a timeout before it, and an answer
that doesn't read means Lambda carried the request out, so neither forgets
a microVM Lambda may run. A new session lets a suspended session's
microVM go only where sessions and warm microVMs fill the limit: those
the host lets go of free their room by themselves.
@fctl-review

This comment has been minimized.

fctl-sh Bot added 2 commits December 1, 2026 22:14
A replay's throttle or lack of capacity says nothing of the first try,
which may have run the microVM: only a request Lambda refuses as invalid,
which it would never have carried out, is forgotten.
@fctl-review

This comment has been minimized.

@fctl-review

This comment has been minimized.

Comment thread crates/fctl-host/src/daemon.rs Resolved
fctl-sh Bot added 2 commits December 1, 2026 22:43
…ch once

A new session on a full runner asks the longest-suspended session whose
snapshot was saved to let its microVM go, and never the same one twice:
one without a saved snapshot would keep its microVM, and the new session
would wait for room in vain.
The form compared its draft and the saved settings as JSON strings, so an
emptied list (which the server leaves out) or keys in another order kept it
changed after a save. Cleared connectors are unset, as the server keeps
them.
@fctl-review

This comment has been minimized.

Comment thread crates/fctl-host/src/daemon.rs Resolved
…session

The host remembered the sessions it asked to let their microVM go for
good once nothing was full, and also one that declined as it resumed: it
now keeps each ask with the suspension it was made in, dropping it once
the session's run ends or it resumes, on every start.
@kalaspuff
kalaspuff merged commit aa96742 into main Dec 1, 2026
13 of 14 checks passed
@kalaspuff
kalaspuff deleted the fctl/1743-agent-sessions-on-aws-lambda-microvms branch December 1, 2026 23:13
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