Skip to main content

agent-sandbox E2B SDK patch — one-line switch to use Agent Sandbox via the E2B Python SDK

Project description

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 e2b agent-sandbox-e2b

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 any e2b import; 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_DOMAIN / E2B_API_URL environment variables > built-in defaults.

# 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
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",
)

Compatibility

Release builds verify the patch against the latest E2B SDK from PyPI before publishing. 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agent_sandbox_e2b-0.0.3.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agent_sandbox_e2b-0.0.3-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file agent_sandbox_e2b-0.0.3.tar.gz.

File metadata

  • Download URL: agent_sandbox_e2b-0.0.3.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for agent_sandbox_e2b-0.0.3.tar.gz
Algorithm Hash digest
SHA256 b58e45aafba5479ff22a3a51081c8fe3b7d6012dd8cd95f1d77739e236d2beb4
MD5 4e543cb73f84d16ad74ec7916b51ef12
BLAKE2b-256 bfbf9733ac23f2d59c49d4ac3daa6e0aac05819304f7819b77a0afc4d620c7b9

See more details on using hashes here.

Provenance

The following attestation bundles were made for agent_sandbox_e2b-0.0.3.tar.gz:

Publisher: sdk-python-publish.yml on scitix/Agent-Sandbox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file agent_sandbox_e2b-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for agent_sandbox_e2b-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b278768375eb30b4d1df6bd19c21352d1de7dfd983735b1cf53fc0801b2b185d
MD5 8f81fb4466c26582042544dc2a4cded9
BLAKE2b-256 e2caa051d1f5c48af1c9382cb8c80a370f6ebdb9fd7d58411e524e623ce9a756

See more details on using hashes here.

Provenance

The following attestation bundles were made for agent_sandbox_e2b-0.0.3-py3-none-any.whl:

Publisher: sdk-python-publish.yml on scitix/Agent-Sandbox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page