agent-sandbox-e2b
A one-line patch that redirects the E2B Python SDK to a self-hosted Agent Sandbox deployment — no code changes to your existing E2B workflows required.
Agent Sandbox is a Kubernetes-native sandbox service for agentic AI scenarios (reasoning evaluation, training rollouts, code execution). It exposes an E2B-compatible API so you can reuse the E2B SDK while running on your own infrastructure.
Installation
pip install agent-sandbox-e2b # or: uv pip install agent-sandbox-e2b
e2b comes with it, capped at the newest version this release was checked
against (see Compatibility). Don't pin e2b separately to
something newer: the resolver will refuse it, and that refusal is the point.
Quick Start
Call patch_e2b() before importing Sandbox. It redirects all SDK requests to your Agent Sandbox cluster.
import os
os.environ["E2B_API_KEY"] = "agbx_your_api_key"
from agent_sandbox_e2b import patch_e2b
patch_e2b() # zero-argument: uses default in-cluster addresses
from e2b import Sandbox
sandbox = Sandbox.create("POOL_NAME", timeout=3600, secure=False)
sandbox.commands.run("echo hello")
sandbox.kill()
Note:
patch_e2b()must be called before anye2bimport; otherwise the SDK connects to the official E2B service.
Cross-Cluster Usage
Prefix the pool name with a cluster ID to route requests across clusters:
sandbox = Sandbox.create("CLUSTER_ID::POOL_NAME", timeout=3600, secure=False)
Custom Image Override
Override the pool's default image at creation time:
# Using metadata key
sandbox = Sandbox.create(
"POOL_NAME",
timeout=3600,
secure=False,
metadata={"agentbox.scitix.ai/image": "registry.example.com/my-env:v2"},
)
# Shorthand syntax
sandbox = Sandbox.create(
"CLUSTER_ID::POOL_NAME//registry.example.com/my-env:v2",
timeout=3600,
secure=False,
)
Configuration
patch_e2b() accepts optional arguments to override the target addresses:
| Parameter | Default (in-cluster) | Description |
|---|---|---|
domain |
agent-sandbox-data-plane.agentbox-system.svc.cluster.local |
Data-plane Envoy gateway address |
api_url |
http://agent-sandbox-e2b-api.agentbox-system.svc.cluster.local |
E2B-compatible API URL |
https |
False |
Use HTTPS for the data plane |
Priority: explicit argument > E2B_HTTPS / E2B_DOMAIN / E2B_API_URL environment variables > built-in defaults. E2B_HTTPS is truthy for 1/true/yes/on (case-insensitive).
# Local debugging via port-forward
patch_e2b(https=False, domain="localhost:9081", api_url="http://localhost:9082")
# Via environment variables (CI/CD)
# export E2B_DOMAIN=agent-sandbox-data-plane.agentbox-system.svc.cluster.local
# export E2B_API_URL=http://agent-sandbox-e2b-api.agentbox-system.svc.cluster.local
# export E2B_API_KEY=agbx_your_key
# export E2B_HTTPS=true # required when the data plane is behind an HTTPS ingress
patch_e2b()
When using the Helm chart in a namespace other than agentbox-system, pass the
installed namespace explicitly:
from agent_sandbox_e2b import patch_e2b
patch_e2b(
domain="agent-sandbox-data-plane.my-namespace.svc.cluster.local",
api_url="http://agent-sandbox-e2b-api.my-namespace.svc.cluster.local",
)
API key format (agbx_ keys)
Agent Sandbox issues API keys with an agbx_ prefix. Newer E2B SDKs
(>= ~2.24.0) added a client-side key-format check
(e2b.api.validate_api_key, pattern \Ae2b_[0-9a-f]+\Z) that rejects any key
not starting with e2b_, raising AuthenticationException before a request is
ever sent. patch_e2b() automatically neutralizes this local check (the
real authentication happens at the Agent Sandbox gateway), so agbx_ keys work
across both old and new E2B SDKs with no extra configuration:
os.environ["E2B_API_KEY"] = "agbx_..." # accepted after patch_e2b()
patch_e2b()
The override is applied inside patch_e2b() and is a no-op on older SDKs that
don't have the check. If you ever need the original behavior, do not call
patch_e2b() (or re-assign e2b.api.validate_api_key back yourself).
Compatibility
The patch hooks into SDK internals, and the SDK decides which API routes to
call. A new e2b can break either one, so each release states what it was
checked against and caps its dependency to match:
- Dependency cap.
pip install agent-sandbox-e2bresolvese2bto at mostSUPPORTED_E2B_MAX_VERSION. Asking for a newere2balongside it is an unsatisfiable requirement, which you see at install time rather than as a 404 at runtime. - Runtime warning. If the cap was bypassed (
--no-deps, a prebuilt image, a source checkout),patch_e2b()warns that the installede2bis newer than the one checked. - What gets checked. The release workflow installs the latest
e2b, confirms the hook points still exist, and runscheck_sdk_routes.py. That script fails ifSandboxcalls any route the server's E2B spec doesn't declare.
import agent_sandbox_e2b
print(agent_sandbox_e2b.SUPPORTED_E2B_MAX_VERSION)
Matrix
The server side matters as much as the patch. e2b 2.51.0 moved create and
connect to POST /v2/sandboxes. A server that doesn't serve those routes
answers every Sandbox.create with 404: 404 page not found, whatever patch
version you have.
| agent-sandbox-e2b | Checked up to e2b |
Notes |
|---|---|---|
| 0.0.11+ | stamped at release (SUPPORTED_E2B_MAX_VERSION) |
e2b is a direct, capped dependency. Route coverage is checked. |
| 0.0.10 | 2.46.4 | Up to and including this release, the cap applies only through the [e2b] extra, so pip install e2b agent-sandbox-e2b installs the newest e2b regardless. Use pip install 'agent-sandbox-e2b[e2b]' to get the cap. |
| 0.0.8 – 0.0.9 | 2.37.0 | |
| 0.0.7 | 2.32.1 | |
| 0.0.5 – 0.0.6 | 2.28.0 | |
| 0.0.4 | 2.25.1 | |
| 0.0.2 – 0.0.3 | 2.21.1 | |
| 0.0.1 | <3.0.0 (no check) |
Older rows come from each release's published Requires-Dist. The check back
then covered hook points only, not routes, which made no difference until
2.51.0.
e2b SDK |
Server needs |
|---|---|
| ≤ 2.50.x | any Agent Sandbox release (v1 create/connect) |
| ≥ 2.51.0 | a release that serves POST /v2/sandboxes and POST /v2/sandboxes/{id}/connect |
If the server can't be upgraded yet, pin the SDK: pip install 'e2b<2.51'.
To check a given SDK against a given server spec yourself (from a source checkout; the script is not shipped in the wheel):
python check_sdk_routes.py path/to/pkg/openapi/e2b/openapi.yaml
After patching, all standard E2B SDK operations work unchanged:
sandbox.commands.run("python --version")
sandbox.commands.run("id", user="root")
sandbox.files.write("/tmp/hello.py", b"print('hello')\n")
sandbox.files.read("/tmp/hello.py")
sandbox.set_timeout(1800) # extend idle timeout dynamically
sandbox.kill()
Links
Metadata
Release files for agent-sandbox-e2b 0.0.13
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| agent_sandbox_e2b-0.0.13.tar.gz | 7.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| agent_sandbox_e2b-0.0.13-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.0 kB
Release files / agent_sandbox_e2b-0.0.13.tar.gz
| Download URL | agent_sandbox_e2b-0.0.13.tar.gz |
|---|---|
| Size | 7.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a37720f94bc899bbed6a4b772c0ae4d726391cc3fde771a738835eff2a8bc545
|
|
BLAKE2b-256 checksum How to use checksums |
2c7a8feccfe2c4e1536ae039f8e54a52f4a49eabf7ec7a45b970fdbde8ce3772
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.
Transparency logRelease files / agent_sandbox_e2b-0.0.13-py3-none-any.whl
| Download URL | agent_sandbox_e2b-0.0.13-py3-none-any.whl |
|---|---|
| Size | 8.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b5be075d88bcc1edafacc348661304a73ea405b79dc062a916be3cf1fcbec895
|
|
BLAKE2b-256 checksum How to use checksums |
dc55f10783b83f5afebc67de9551005dfac53e3bbc3bfcc2831d3c9703465993
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.
Transparency log