Sandbox, so code written for Modal runs with one changed import.
Create a sandbox
Install the SDK and set a floo API key. The SDK needs Python 3.10 or later.Sandbox.create boots nothing. The first exec boots a machine and answers in under half a second.
Sandbox performance and state has the measured times, p50 and p95, and what survives a stop or a pause.
Which calls need a machine
A machine stays attached for
keep_warm seconds after its last command, 30 by default, then stops. File calls do not keep it attached. What the command changed on disk is in the workspace before the machine stops, so the next file call sees it.
Set the window per sandbox, from 0 to 86,400 seconds:
Keep processes across idle time
A persistent sandbox pauses with its memory and processes when it is idle, and runs again where it was on the next call.Size a sandbox
A sandbox is small, medium or large. One you do not size is small.cpu and memory take a number or a (request, limit) pair, as on Modal, and you get the smallest size that has both. cpu=2 is a medium, and so is memory=1024. More than a large raises InvalidError.
Run an agent as a worker
A sandbox created with a command runs it from the start and finishes when it exits. Use one to run the agent loop itself on floo.Sandbox.create needs no API key and makes a child sandbox on the same host, 16 at once. A child takes cpu and memory as any sandbox does. A worker whose programs are idle pauses, and runs again on its next call or its stdin.
Network and secrets
A sandbox reaches the public internet and nothing of floo’s or another sandbox’s. Narrow it withblock_network=True, outbound_cidr_allowlist=[...] or outbound_domain_allowlist=[...].
modal.Secret.from_name("NAME") gives a sandbox one of its app’s secret variables. Your program never holds the value: it holds a placeholder, and floo puts the value in its place as a request leaves the sandbox.
The value is sent only as an Authorization, X-Api-Key, Api-Key, X-Goog-Api-Key, X-Auth-Token or Private-Token request header, alone or after one scheme word such as Bearer. A placeholder anywhere else (a URL, a body, another header) reaches the host unchanged, and that host answers 401.
Pricing
File calls that need no machine bill no compute. Sandboxes bill to your credits on one Sandboxes line, at the same rates on every plan.
Differences from Modal
- Sign in with
FLOO_API_KEY, not a Modal token id and secret. - An option of
Sandbox.createthat floo does not take is refused by name. It is never ignored. exectakes no PTY.- A pause keeps processes as well as files.
- GPUs are not available.
- Tunnels (
encrypted_ports) are not available yet. - Sandboxes run in one US region.
Upgrade the SDK
When a release changes how the SDK talks to floo, floo keeps serving the release before it. An SDK older than that is refused on every call, with a message that says to upgrade. Install the latest release the same way you installed the SDK, and run the program again.When floo updates a sandbox host
floo updates sandbox hosts in place, without ending your sandboxes. A sandbox keeps its id, files, env, secrets and time left. An update pauses the sandboxes on a host for a few seconds. A call made meanwhile waits, and the SDK makes it again by itself. If a host stays away for more than five minutes, the call raisesResourceExhaustedError.
What happens to what was running:
- A sandbox where a command is running, a sandbox with no disk, and a worker with its children run on where they were, commands included. Open network connections close, so reconnect.
- A sandbox that mounts volumes cannot run on. Its commands started with
execend, and your program is told why. Run them again. - These end, each with its reason: a worker, a child, or a sandbox with no disk that mounts volumes; a child whose worker ended; and a sandbox that mounts volumes whose own command does not restart.
- A few updates change the machines sandboxes run on. A sandbox that would have run on then ends instead, unless it has a disk and its command restarts. That command runs again from the start and says so.
Limits
- A sandbox’s
timeoutis 300 seconds unless set, 24 hours at most. A worker alone may settimeout=None. - When every machine on a host is busy, a call that needs one waits in line, up to 5 minutes, then raises
ResourceExhaustedError.Sandbox.createwaits the same way when a host holds all the sandboxes it can. - An organization runs 32 sandboxes at once. Past that,
Sandbox.createraisesResourceExhaustedErroruntil one finishes or is terminated. - The workspace holds 64 MiB of file content per sandbox. Larger content lives on the sandbox’s disk and needs a machine to read.
- A sandbox’s disk holds what its commands write, beside its image: 4 GiB for a small, 8 GiB for a medium and 16 GiB for a large. A write past that fails with “No space left on device”.