# Omnigent on E2B [E2B](https://e2b.dev) sandboxes give you disposable cloud machines for running Omnigent hosts, two ways: - **CLI-launched**: `omnigent sandbox create` / `connect` provisions a sandbox from your terminal, ships your local checkout into it, and registers it as a host with your server. - **Server-managed**: the server provisions a sandbox automatically when a session is created with `"host_type": "managed"` and terminates it when the session is deleted. > [!IMPORTANT] > **E2B boots from a pre-built *template*, not a registry image.** Unlike > the Modal / Daytona / CoreWeave launchers — which pull > `ghcr.io/omnigent-ai/omnigent-host` directly — E2B cannot start an > arbitrary registry image at create time. You must first build the > Omnigent host image into an E2B template (a one-time step, below); the > launcher's `template` field then names *that template*, not a > `ghcr.io/...` reference. This is the one real difference from the other > sandbox providers. This directory is **not** a server deploy target. ## Prerequisites ```bash pip install 'omnigent[e2b]' # installs the e2b SDK extra npm i -g @e2b/cli # the E2B CLI, for building the template ``` Create an API key in the [E2B dashboard](https://e2b.dev/dashboard) and make it available where the launcher runs — your shell for the CLI flow, the **server** process for managed sandboxes: ```bash export E2B_API_KEY=e2b_… e2b auth login # one-time, authenticates the E2B CLI too ``` > [!NOTE] > **Lifetime is capped and cannot be disabled.** An E2B sandbox carries a > single timeout (default 5 minutes; account maximum **24 h on Pro, 1 h on > Hobby**) with no "never expire" option. Omnigent requests the 24 h > maximum at creation, but E2B **rejects** (does not clamp) a request above > the account cap, so `provision` automatically **retries clamped to the > account's maximum** (e.g. 1 h on Hobby) — verified live. Set > `OMNIGENT_E2B_MAX_LIFETIME_S` to request a specific lifetime and skip the > retry. A managed session outliving the cap relies on the dead-sandbox > relaunch path (same posture as Modal's 24 h limit), so a **Pro account** > is recommended for anything beyond short demos. ## Build the host template (one time) E2B builds a template from a Dockerfile whose base image must be **Debian-based** and **single-stage**. The Omnigent host image (`python:slim`, Debian) satisfies both — so the template Dockerfile is a one-liner that layers nothing on top of the published image: ```bash mkdir -p omnigent-e2b && cd omnigent-e2b cat > e2b.Dockerfile <<'EOF' # Single-stage, Debian-based — both E2B requirements. The host image # already bakes the full omnigent install plus git / tmux / curl, so # nothing else is needed here. FROM ghcr.io/omnigent-ai/omnigent-host:latest EOF e2b template build --name omnigent-host --dockerfile e2b.Dockerfile ``` `omnigent-host` is the default template name the launcher looks for ([`DEFAULT_E2B_TEMPLATE`](../../omnigent/onboarding/sandboxes/e2b.py)), so a deployment that uses that name needs no further config. Use a different name (or pin a `:sha-` host image) and point the launcher at it with `sandbox.e2b.template` / `OMNIGENT_E2B_TEMPLATE`. To run your own host image, build the `host` target of [`deploy/docker/Dockerfile`](../docker/Dockerfile) (`--platform linux/amd64`), push it anywhere E2B can pull from, and `FROM` that ref in `e2b.Dockerfile` instead. Rebuild the template whenever the host image changes (the CLI flow still overlays your *local* wheels on top per-sandbox, so day-to-day code changes don't need a template rebuild). ## CLI-launched sandboxes Provision a sandbox and ship your local checkout into it: ```bash omnigent sandbox create --provider e2b ``` This starts a sandbox from the `omnigent-host` template, builds wheels from your local checkout, and overlays them on top — so the sandbox runs *your* code, not whatever the template was built from. Then register it as a host with your server: ```bash omnigent sandbox connect --provider e2b \ --sandbox-id \ --server https://your-host ``` `connect` runs `omnigent host` inside the sandbox and holds the connection open in your terminal — Ctrl-C tears it down (and kills the remote process; E2B exposes a real kill handle). New sessions targeting that host now run in the sandbox. Running multiple sandboxes against one server? Pass a unique `--host-name