E2B Bridge Runtime

worker-bridge-e2b connects an OnlyBoxes control node to remote E2B sandboxes. The worker manages sessions and task dispatch locally, while E2B provides the execution environment.

When to use

  • You want managed remote sandboxes without running Docker or KVM on the worker host
  • You need E2B templates tailored to different Python and terminal workloads
  • You accept the network latency and external service dependency of a remote execution backend

How it works

  1. The worker connects to the OnlyBoxes control node over gRPC.
  2. It creates, extends, and destroys sandboxes through the E2B Control API.
  3. It executes commands and reads files through envd inside each sandbox.
  4. pythonExec uses a new sandbox per request; terminal sessions reuse a sandbox until their lease expires.

Prerequisites

  • An E2B API key
  • An E2B Python template with Python and uv
  • An E2B terminal template with /bin/bash and python3
  • Network access to the OnlyBoxes control node and E2B endpoints

Starting the worker

Download the matching worker-bridge-e2b binary from the GitHub releases page, then run:

WORKER_CONSOLE_GRPC_TARGET=<console_grpc_target> \
WORKER_ID=<worker_id> \
WORKER_SECRET=<worker_secret> \
WORKER_E2B_API_KEY=<e2b_api_key> \
WORKER_E2B_PYTHON_TEMPLATE=<python_template_id_or_alias> \
WORKER_E2B_TERMINAL_TEMPLATE=<terminal_template_id_or_alias> \
./onlyboxes-worker-bridge-e2b

Workers require TLS by default. Set WORKER_CONSOLE_INSECURE=true only for a trusted plaintext development connection.

Configuration file

Set WORKER_CONFIG_FILE to use a specific config.toml. Otherwise, the worker looks next to its binary and then in the current working directory.

Configuration precedence is: WORKER_* environment variable, E2B-compatible environment variable alias, config.toml, then built-in default.

id = "wk_..."
secret = "..."
console_grpc_target = "console.internal:50051"
e2b_api_key = "..."
e2b_python_template = "python-template"
e2b_terminal_template = "terminal-template"
terminal_max_active_sessions = 0

[labels]
region = "us"

See the annotated configuration template for all available keys.

Environment variables

Connection and identity

VariableRequiredDefaultDescription
WORKER_IDYesWorker ID from the dashboard
WORKER_SECRETYesOne-time secret from worker creation
WORKER_CONSOLE_GRPC_TARGETNo127.0.0.1:50051Control node gRPC address
WORKER_CONSOLE_INSECURENofalseSet true only to allow a trusted non-TLS connection
WORKER_NODE_NAMENogeneratedHuman-readable node name
WORKER_LABELSNoJSON or comma-separated key=value labels

E2B

VariableRequiredDefaultDescription
WORKER_E2B_API_KEYYesE2B Control API key; alias: E2B_API_KEY
WORKER_E2B_PYTHON_TEMPLATEYesTemplate used by pythonExec; alias: E2B_PYTHON_EXEC_TEMPLATE
WORKER_E2B_TERMINAL_TEMPLATEYesTemplate used by terminal sessions; alias: E2B_TERMINAL_EXEC_TEMPLATE
WORKER_E2B_API_URLNohttps://api.e2b.appControl API base URL; alias: E2B_API_URL
WORKER_E2B_DOMAINNoe2b.appSandbox domain suffix; alias: E2B_DOMAIN
WORKER_E2B_SANDBOX_URLNoOverride the envd base URL; alias: E2B_SANDBOX_URL
WORKER_E2B_REQUEST_TIMEOUT_SECNo60Control API and envd connection timeout
WORKER_E2B_PYTHON_TIMEOUT_SECNo300Lifetime of a one-shot Python sandbox; alias: E2B_SANDBOX_TIMEOUT_SEC

Terminal

VariableRequiredDefaultDescription
WORKER_TERMINAL_LEASE_MIN_SECNo60Minimum requested session lease
WORKER_TERMINAL_LEASE_MAX_SECNo1800Maximum requested session lease
WORKER_TERMINAL_LEASE_DEFAULT_SECNo300Default session lease
WORKER_TERMINAL_OUTPUT_LIMIT_BYTESNo1048576Limit for each output stream and file reads
WORKER_TERMINAL_EXPORT_MAX_BYTESNo0 (unlimited)Maximum exported file size
WORKER_TERMINAL_EXPORT_MODENosandboxsandbox uploads directly from E2B; worker proxies file bytes
WORKER_TERMINAL_SESSION_MAX_INFLIGHTNo128Concurrent operations allowed in one session
WORKER_TERMINAL_MAX_ACTIVE_SESSIONSNo0 (unlimited)Maximum terminal sessions managed by this worker process

The Worker advertises terminalLeaseRenew as an internal Console-only capability. It accepts {"session_id":"required","lease_ttl_sec":300}, extends an existing lease monotonically, synchronizes the E2B sandbox timeout, and returns the confirmed absolute expiry without executing a command. Its independent max_inflight declaration uses the configured WORKER_TERMINAL_EXEC_MAX_INFLIGHT value.

WORKER_TERMINAL_MAX_ACTIVE_SESSIONS is independent of the per-session and capability concurrency limits. 0 leaves the count unlimited; a positive value counts sessions that are being created, ready, being destroyed, or undergoing E2B cleanup. Existing sessions remain usable when the limit is full, while a new session returns 429 session_capacity_exceeded. The limit applies only to this worker process, not to all workers sharing an E2B API key; negative or invalid values fall back to 0.

Terminal commands share the sandbox filesystem but run in separate /bin/bash -l -c processes. They do not preserve the current directory, shell variables, or process environment between calls.

Capability concurrency

VariableRequiredDefaultDescription
WORKER_ECHO_MAX_INFLIGHTNo128Concurrent echo calls
WORKER_PYTHON_EXEC_MAX_INFLIGHTNo32Concurrent pythonExec calls
WORKER_TERMINAL_EXEC_MAX_INFLIGHTNo64Concurrent terminalExec calls
WORKER_TERMINAL_RESOURCE_MAX_INFLIGHTNo128Concurrent terminalResource calls

Heartbeat and logging

VariableRequiredDefaultDescription
WORKER_HEARTBEAT_INTERVAL_SECNo5Heartbeat interval in seconds
WORKER_HEARTBEAT_JITTER_PCTNo20Heartbeat jitter percentage
WORKER_CALL_TIMEOUT_SECNoceil(2.5 * interval)Timeout for console hello and heartbeat acknowledgements
WORKER_LOG_LEVELNoinfodebug / info / warn / error
WORKER_LOG_FORMATNojsonjson / text
WORKER_LOG_ADD_SOURCENofalseInclude source file and line