Repository navigation
feat: run sessions in AWS Lambda microVMs - #665
Merged
Merged
Conversation
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.
This comment has been minimized.
This comment has been minimized.
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.
This comment has been minimized.
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.
This comment has been minimized.
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.
This comment has been minimized.
This comment has been minimized.
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.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…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.
This comment has been minimized.
This comment has been minimized.
…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
approved these changes
Dec 1, 2026
6 tasks
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.
Summary
A workspace can now run each of its sessions in an AWS Lambda microVM in its own AWS account. A new
lambdadriver forfctl hostruns 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, wherefctl-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 withfctl 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.
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.runners),GETandPUT /api/v1/runners/{id}/microvms, and scheduling that skips suspended sessions and putsfirstrunners first.fctl runners microvms show|set,fctl host install --driver lambda,fctl host microvm-image, and[lambda]inhost.toml.fctl attachsays when a microVM suspends and resumes.cargo xtask dev --microvmsruns a stand-in for Lambda (xtask/lambda) and a runner of its microVMs.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 checkpasses. End to end,cargo xtask dev --microvmsran 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
microvmsfeature, and every new protocol field is optional.Screenshots
At f723c9b, in
cargo xtask dev --microvmsagainst 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 same on a phone (dark, 390 px): the card's facts wrap between them, and the drawing goes under the text.
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.
Its settings further down (light): the image, size, whiles, warm pool and going first.
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.
The same on a phone (dark, 390 px).
Worth confirming
idlestatus rather than getting a new one: its page, its details, its message box andfctl attachsay the microVM is suspended, and lists show it as waiting.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.host.toml. Members see the runner's microVMs, and its settings in a sentence.ghcr.io/hyperstructure/sandboximage the Dockerfile starts from.nohupserver, 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