E2B
E2B is one of the two
sandbox providers. E2B_API_KEY turns it on, and
SANDBOX_PROVIDER=e2b makes it the default for a new sandbox. One agent can
also pin it with sandbox_provider. A sandbox that already exists always
stays on the provider Managoat made it on.
E2B_API_KEY=e2b_... # enables the provider
E2B_TEMPLATE=fountain # a template built from images/e2b/ (see below)
# E2B_BASE_URL=https://api.e2b.app
# SANDBOX_PROVIDER=e2b # make it the instance default
Summary
| Role | Sandbox provider. |
| Turned on by | E2B_API_KEY |
| Env vars | E2B_API_KEY, E2B_TEMPLATE, E2B_BASE_URL |
| Suspend | An explicit pause, with a snapshot of filesystem and memory. |
| Capabilities advertised | :suspend, :network_policy, :attach |
| Needs first | A template built from images/e2b/. The stock base has no agent CLIs. |
Template
The stock base template carries no agent CLI. Build the reference template
once for each account.
E2B_API_KEY=... scripts/sandbox-image/build-e2b.sh
The script runs e2b template create fountain against images/e2b/. Then it
creates one sandbox from the new template. It checks the shape that the
provision pipeline assumes, then it destroys the sandbox. E2B_TEMPLATE
selects a different template name.
e2b template create takes the name and rebuilds that template in place. So
the template id that an instance points at stays the same. Sandboxes that
already run keep the copy that they started from.
The key must belong to the account the instance uses. A template that another account builds is not visible to the instance. Rebuild the template when you want newer agent CLIs. Nothing rebuilds it for you.
scripts/sandbox-image/smoke-e2b.sh runs the same smoke against an existing
template, without building, on any E2B-compatible endpoint that
E2B_BASE_URL names.
The image recreates the sandbox shape that the provision pipeline assumes. That is a
sprite user with passwordless sudo, /home/sprite, node, npm, bun, git and
the three agent CLIs. So no provision code exists for one provider alone.
How the contract maps
| Managoat operation | E2B mechanics |
|---|---|
| Create or adopt by name | E2B assigns the ids. The minted name rides in sandbox metadata, and a lookup filters on it server-side. A create race leaves a duplicate, and the reaper converges it. |
| Suspend and resume | Real calls. pause snapshots filesystem and memory, keeps them without a time limit, and costs storage alone. connect restores. The idle bound truly parks. |
| TTL | Each E2B sandbox that runs has one. A live command heartbeats it. Managoat creates a sandbox with autoPause: true. A heartbeat that arrives late then pauses the sandbox and keeps its state, and does not kill it. An operation that finds the sandbox auto-paused resumes it first. |
| Exec and streams | envd, the daemon in the sandbox, over Connect-RPC with the JSON codec. That is plain HTTPS, and not gRPC. |
| Reattach after a deploy | envd does not replay the output of a process you reconnect to. So a detachable command runs under a shim that journals, with tee to /tmp/fountain/<tag>.*. A reattach replays the journal from byte zero through a tail streamer, and reads the real exit code from the shim's exit file. |
| Network policy | Native default-deny. denyOut 0.0.0.0/0 plus the allowlist, and you can update it on a sandbox that runs. The provision-open-then-lock flow works unchanged. |
Operational notes
- Plans. An agent turn can take more than one hour. E2B's Hobby tier caps continuous runtime at 1h, so you need Pro.
- Capacity. Managoat counts live E2B sandboxes on their own, against
SANDBOX_FLEET_CEILING_E2B(defaultSANDBOX_FLEET_CEILING, 20). Set it to the concurrency your E2B plan allows. A start past it gets503 fleet_full; sprites do not count against it. - Reaper. Reconciliation lists both
runningandpausedsandboxes, filtered to metadata that Managoat stamped. It never touches a sandbox without that metadata. - One team per instance. The E2B team behind
E2B_API_KEYbelongs to one Managoat instance, the same rule as for Sprites. Create adopts any sandbox whosefountain_namemetadata matches the name it minted, and destroy finds its target by the same lookup. A second instance on the same team stamps the same metadata, so Managoat cannot tell its sandboxes apart. Sharing the key is unsupported. - Egress. The callback host,
PUBLIC_URL, must be reachable from inside the sandbox. Alimitedenvironment gets it through the same allowlist mechanics that Sprites uses.
Verify
Create a conversation on an agent pinned to e2b, and watch it reach its
first turn. A run that stops short of that is a failure to provision, and the
stage events name the step.