Skip to main content
E2BSandbox implements CloudSandbox. E2BSandboxToolkit exposes the same session through Agent tools. Import both from @agentium/core/toolkits.

Run code

This example creates a real remote sandbox when run. Save as e2b.ts, then use npx tsx e2b.ts.
e2b.ts
Expect output containing 42. The SDK import and sandbox creation are lazy; the first operation starts the session. Leave template unset to use the interpreter SDK’s default language-capable template.

Configure ownership

lifetimeSeconds bounds the remote session lifetime independently of each operation’s timeout. Every sandbox created by this adapter is owned and killed during close(). Concurrent starts share one creation; close is terminal. For Agent tools, create E2BSandboxToolkit, pass getTools() to your Agent, and close both the Agent and toolkit after active runs settle. Grant only the intended tool names in a harness.

Handle uncertain work

Remote cancellation and client deadlines do not prove code stopped. Check for external effects before replaying. Missing files return null only for provider-specific not-found responses. Errors from code, authorization, or connectivity remain failures. Output is bounded after the provider call; the provider SDK may buffer more internally. Account-level isolation and network policy are yours to configure. See sandbox lifecycle.