E2B (AI Code Sandbox Runtime)

E2B: cloud-side runtime for executing AI-generated code in isolated micro-VMs. Python and TypeScript SDKs are pure RPC clients over Connect-RPC against an envd daemon (Rust + protobuf).

✓ 0 reported success·v0.1.0·

Overview

E2B is the cloud-side runtime for executing AI-generated code in isolated micro-VMs (github.com/e2b-dev/E2B). The Python and TypeScript SDKs are pure RPC clients over Connect-RPC against an envd daemon (Rust + protobuf, hosted in the separate e2b-dev/infra repository). SDK exposes a 2x2 surface: {Sandbox, AsyncSandbox} × {Template, AsyncTemplate}. Sandbox/AsyncSandbox carry four sub-modules accessible as instance properties: files: Filesystem / commands: Commands / pty: Pty / git: Git. Polymorphism lives in the gRPC .proto schemas (process_pb2, filesystem_pb2), not in Python @abstractmethod. This skill embeds 42 constraints (3 fatal) covering typical pitfalls: TS users forget kill() — TS Sandbox has NO Symbol.dispose and no auto-cleanup; API keys passed via envs={...} leak via commands.list() to anyone holding the sandbox handle; three timeouts that look the same but aren't (files.write() default 60s silently kills large uploads).

Blueprint Source

finance-bp-141

e2b-dev/E2B557b7231 source file

Constraints

3total
3fatal
3 must-not-violate

Evidence Quality

Confidence90%

High confidence — strong evidence base

3 non-negotiable constraints

FATALdomain_rulee2b-C-001

WHENWriting TypeScript SDK code that calls Sandbox (any e2b npm package consumer scenario).

ACTIONWrap each Sandbox.create() in try/finally and `await sandbox.kill()` in the finally block — the TS Sandbox class does NOT implement Symbol.dispose / Symbol.asyncDispose, so a `using` block does not auto-cleanup.

CONSEQUENCEIf a TS caller misses `await sandbox.kill()`, the sandbox keeps billing until the 5-minute default timeout reclaims it server-side; every leak adds up to 5 minutes of billable time, and long loops or exception paths multiply cost.

FATALdomain_rulee2b-C-004

WHENImplementing a stateful agent loop that needs to retain in-sandbox filesystem/process/RAM state across multiple conversation turns.

ACTIONPass lifecycle={'on_timeout': 'pause', 'auto_resume': True} explicitly to Sandbox.create() — omitting it equals auto_pause=False (hard-coded at main.py:219), and on timeout the sandbox is KILLED and all state is lost.

CONSEQUENCEWithout a lifecycle config, the sandbox is destroyed at timeout, all filesystem/process/RAM state is lost, the next connect() hits a deleted sandbox raising SandboxNotFoundException, and the agent's multi-turn context chain breaks.

FATALdomain_rulee2b-C-026

WHENPlanning the maximum duration of a single sandbox task / picking an E2B tier.

ACTIONDo NOT let a single Sandbox task run beyond the tier cap — Hobby tier hard cap is 1h, Pro tier is 24h, enforced server-side; the platform KILLs the sandbox regardless of any timeout the SDK passes.

CONSEQUENCEExceeding 1h on Hobby kills the task at 1h and loses all in-memory state; if the caller has no progress checkpoint, the entire task rolls back. The same applies to 24h on Pro.

FAQ

Discussion (0)

No comments yet. Be the first to share!

Changelog

v0.1.02026-04-25·Contributors: tangweigang-jpg

v0.1.0: Initial release on Doramagic.ai. AI code sandbox runtime on e2b-dev/E2B with bilingual metadata, 42 anti-pattern constraints (3 fatal), and 3 FAQs.

v0.1.02026-04-25·Contributors: tangweigang-jpg

v0.1.0: Initial release on Doramagic.ai. AI code sandbox runtime on e2b-dev/E2B with bilingual metadata, 42 anti-pattern constraints (3 fatal), and 3 FAQs.