Repository navigation
Open
Labels
agent-readyMaintainer-approved for the Tale agent fleetepicTracking epic spanning multiple issuesfeatNew featurepriority: mediumMedium priorityservice: platformPlatform service
Description
Summary
Add an outbound, pluggable E2B execution backend so deployments that need sandbox scale-out can point at E2B Cloud or self-hosted e2b-dev/infra via config — without changing agent/product code.
Default stays Docker / Kubernetes. Tale keeps its own /v1/sessions + runnerd contract; E2B only owns microVM lifecycle/density.
Out of scope: inbound E2B API/envd compatibility (Tale does not expose an E2B-compatible surface). Revisit only if external e2b SDK clients need to target Tale.
Architecture
flowchart LR
Platform[Platform Convex]
Spawner[Tale Spawner API]
Backend{SessionBackend}
Docker[Docker backend]
K8s[K8s backend]
E2B[E2B backend]
Runnerd[runnerd in box]
Platform --> Spawner
Spawner --> Backend
Backend --> Docker
Backend --> K8s
Backend --> E2B
Docker --> Runnerd
K8s --> Runnerd
E2B -->|"Tale runtime template"| Runnerd
Extension point today: SessionBackend in services/sandbox/src/backend/types.ts (docker | kubernetes), factory in services/sandbox/src/backend/index.ts. Platform client: services/platform/convex/node_only/sandbox/helpers/session_client.ts.
Seam:
- Keep Tale contracts:
/v1/sessions, runnerd, Convex orchestration - Add
SANDBOX_BACKEND=e2b(deployment-level in Phase 1) E2bSessionBackenduses the official SDK for create/pause/destroy;resolveEndpoint()still points at in-box runnerd- E2B template =
@tale/sandbox-runtime(with runnerd) — do not reimplement runnerd on envd in Phase 1
Capability matrix (honesty bar)
| Capability | E2B backend strategy |
|---|---|
| exec / files / env / cancel / attach / held-stdin steer | Keep via runnerd in template |
| org quota / admission | Stay in Convex; map E2B concurrency/cost separately |
| LLM gateway virtual keys | Keep if gateway is reachable from E2B |
| Tier-2 per-exec credential overlay | Keep |
| stop/resume workspace | Map to E2B pause/resume; align destroy vs stop |
| egress SSRF fence | Do not assume sandbox-egress; E2B network policy or degrade |
| browser view / screencast | Phase 1 degrade/disable (or later Desktop) |
| DinD | Phase 1 unsupported |
http://convex/... blob stage |
Presigned / public URLs required |
Phased work
Phase 0 — Contract + matrix
- Document SessionBackend vs runnerd seam
- Write E2B capability matrix into
services/sandbox/docs/sessions.md - Document config:
E2B_API_URL/E2B_API_KEY/ template id (Cloud and self-host same client)
Phase 1 — MVP (config switch runs agent main path)
- Implement
E2bSessionBackend(create / resolveEndpoint / destroy / stop·pause / list / exists) - Package + CI-publish Tale runtime as E2B template
- Remove Compose-DNS assumptions: presigned blob staging; reachable LLM gateway
- Integration tests: create → exec → files → pause/resume → destroy
- Default backend unchanged; E2B opt-in via config
Phase 2 — Scaling product completeness
- Quotas + cost observability (Convex + E2B)
- Egress policy docs (Cloud vs self-hosted infra)
- Browser / DinD: explicit degrade or follow-up
- Optional: deployment-level
sandboxBackendin file config domain (not a new Convex table)
Explicit non-goals
- Inbound E2B protocol (REST/envd)
- Replacing Convex session / quota / credential model
- Platform speaking only the E2B SDK
- 100% parity with Docker sandbox (DinD, transparent egress, VNC degrade first)
- Making
e2b-dev/infrathe default install path (document as optional scale-out)
Risks
- Network boundary is the largest cost (gateway / blob / callbacks must be reachable from E2B Cloud)
- Runtime → E2B template publish must be in CI
- Phase 1 API key + template are deployment-scoped
- Self-hosted E2B infra is heavy (Terraform / GCP|AWS)
Success criteria
- Config-only switch:
docker/kubernetes↔e2b(E2B_API_URL→ Cloud or self-host) - Coding-agent main path observed green on E2B (create, exec, steer stdin, credential overlay, gateway VK, destroy)
- Capability degradations documented (and UI-visible where relevant)
References
- Plan: local Cursor plan
e2b_backend_seam(E2B as pluggable sandbox backend, outbound only) - E2B infra self-host: https://github.com/e2b-dev/infra
- Tale sessions doc:
services/sandbox/docs/sessions.md
Metadata
Metadata
Assignees
Labels
agent-readyMaintainer-approved for the Tale agent fleetepicTracking epic spanning multiple issuesfeatNew featurepriority: mediumMedium priorityservice: platformPlatform service
Activity
yannickmonney commentedon Nov 14, 2026
Decision
Build the E2B backend as a fourth opt-in sandbox backend (
SANDBOX_BACKEND=e2b, set per deployment in env). It is outbound-only and lands onmainin seven units. Tale keeps/v1/sessions, runnerd and Convex orchestration. E2B owns only the microVM lifecycle, through a fullSessionBackendbuilt on the officiale2bSDK, which is loaded only when this backend is selected.Rules
/relayendpoint. Inside the VM, runnerd serves loopback listeners for exactly the two names devices already relay:backend-api:3005andsandbox-llm-gateway:8080. Requests pass under the device hub's framing andrelay-policy.tsallowlist. No presigned URLs, and no public gateway or API.allowPublicTraffic=false, secure envd, TLS and the per-session runnerd HMAC token. A root standby script consumes a root-owned 0600 claim file, deletes it and drops to the profile user, as the Incus warm pool does. The token is never in E2B env or metadata.SANDBOX_EGRESS_ALLOWLISTis translated only from anchored literal hosts (^a\.b$) and subdomain forms (^(.*\.)?a\.b$); any other regex refuses boot. With an allowlist set, the policy is default-deny plus those domains.SANDBOX_EGRESS_DENIED_HOSTSrefuses boot with e2b. A rejected policy fails the create. E2B lets an allowed domain take precedence over the private-range deny; the docs say so and the live suite records it.SANDBOX_E2B_ALLOW_UNFILTERED_NETWORK=trueis the only unfiltered mode, and it warns.onTimeout=pause), and every sweep refreshes it for every live session, so Tale's idle reaper alone decides when a session stops. Resume kills every process left from the old incarnation, then restarts runnerd as a new incarnation. A paused sandbox that E2B no longer has reads as gone. Destroy = kill, readinghanded_off. Incarnation and pin live in a root-owned record inside the VM. Run one spawner per E2B key and instance.SANDBOX_E2B_API_KEY,SANDBOX_E2B_DOMAIN(defaulte2b.app),SANDBOX_E2B_TEMPLATE_AGENT,SANDBOX_E2B_TEMPLATE_DEFAULT, all passed explicitly to the SDK. No file-config key, no new table.Answers
resolveEndpointwidens to{baseUrl, headers?}.docker=false.SANDBOX_MAX_SESSIONS, warned to stay within the E2B team concurrency.sandboxBackend: rejected as a duplicate ofSANDBOX_BACKEND.Rationale
Layered ingress auth and a relay that reuses the audited device hub, with no wider surface, keep runnerd and Tale's services off the public internet. Egress uses E2B's own policy language: only allowlist forms that translate exactly are accepted, and the precedence caveat is documented. E2B's wall-clock timer must never pause an active turn, and a memory-snapshot resume must not revive the old incarnation's processes. Hence the timeout refresh for all sessions and the kill before runnerd restarts. Turning E2B Cloud on for a deployment Tale operates adds a US sub-processor; that is an activation choice, not a build blocker.
Units (all on
main)e2b(M)Cross-issue amendments (decisions taken together with #4870, #4942):