Skip to main content

e2b-adk

A Google ADK plugin backed by E2B sandboxes. Attach it to an ADK agent and the agent can generate and run code, execute shell commands, read and write files, and start long-running processes — all inside an isolated E2B sandbox, with no infrastructure of your own.

Under the hood every tool call runs in the E2B Code Interpreter, so the model's code executes in a real Python kernel instead of being trusted blind.

Install

pip install e2b-adk

Or with uv:

uv pip install e2b-adk

Credentials

You need an E2B API key for the sandbox and a model key for the agent's LLM (Gemini is ADK's default):

export E2B_API_KEY="..."
export GOOGLE_API_KEY="..."

Get an E2B key at e2b.dev/dashboard.

Quickstart

Create the plugin, hand its tools to an Agent, and register the plugin on the App. The plugin owns the sandbox lifecycle — you never create or tear one down yourself.

import asyncio

from google.adk.agents import Agent
from google.adk.apps import App
from google.adk.runners import InMemoryRunner

from e2b_adk import E2BPlugin


async def main() -> None:
    plugin = E2BPlugin()
    agent = Agent(
        model="gemini-2.5-flash",
        name="coder",
        instruction="Write and run Python to answer the user. Verify with run_code.",
        tools=plugin.get_tools(),
    )
    app = App(name="demo", root_agent=agent, plugins=[plugin])

    async with InMemoryRunner(app=app) as runner:
        # run_debug prints the conversation as it runs.
        await runner.run_debug("Compute the 20th Fibonacci number.")


asyncio.run(main())

Tools

plugin.get_tools() returns six tools. Each returns a JSON-serializable dict with a success flag — tools report failures in the result rather than raising, so a bad call never aborts the agent run. success means the tool ran: code that raised or a command that exited non-zero still returns success: True with the failure captured in error / exit_code. Only a call that could not run at all (sandbox unavailable, timeout) returns success: False.

Tool Does Key result fields
run_code Run code in a stateful kernel (variables persist across calls) stdout, stderr, text, error
run_command Run a shell command (each call is independent) stdout, stderr, exit_code
write_file Write a file in the sandbox path
read_file Read a file back path, content
list_files List a directory entries ([{name, type}])
start_background_command Start a long-running process; optional preview URL for a port pid, preview_url (+ readiness when port is set)

Configuration

E2BPlugin takes keyword-only options, all optional. Anything you don't set falls back to the E2B SDK's own default — the plugin overrides none of them.

E2BPlugin(
    # Common options
    api_key=None,               # defaults to the E2B_API_KEY env var
    template=None,              # E2B sandbox template
    metadata=None,              # dict[str, str] attached to the sandbox
    envs=None,                  # dict[str, str] environment variables
    timeout=None,               # sandbox timeout in seconds (re-applied on every tool call)
    plugin_name="e2b_plugin",
    # Passed straight through to AsyncSandbox.create() — see the E2B SDK docs
    secure=None,
    allow_internet_access=None,
    mcp=None,
    network=None,
    lifecycle=None,             # e.g. pause/auto-resume; defaults to E2B's behavior
    volume_mounts=None,
    # **opts: any other AsyncSandbox.create() / connection param (proxy, request_timeout, …)
)

Examples

Run one with the credentials above:

uv run --extra examples python examples/data_analysis.py

v1 notes

  • Sequential tool calls. One sandbox is shared per plugin; calls are meant to run one at a time, not concurrently. Concurrent calls are safe for the sandbox lifecycle (creation is locked) but share one filesystem and kernel.
  • Text-only output. Tools return text — stdout/stderr/file contents. Rich results (charts, dataframes, images) are not surfaced yet.
  • Lazy, shared sandbox lifecycle. The sandbox is created on the first tool call and reused for the agent's lifetime, then killed when the runner exits.
  • Keep-alive while active, expiry when idle. While a sandbox SDK operation is active, a best-effort heartbeat refreshes its timeout (E2B's default is 300s), including when a foreground call runs longer than that timeout. A final refresh starts the full idle window when the operation ends. An idle gap longer than timeout still expires the sandbox under E2B's default lifecycle (on_timeout: kill), and later tool calls return failure results — pass e.g. lifecycle={"on_timeout": {"action": "pause"}, "auto_resume": True} to pause and auto-resume across idle gaps instead.
  • Bounded output. Output larger than 10 KB per field is truncated with a …[truncated N bytes] marker so a single call can't flood the model's context.

License

MIT — see LICENSE.

Metadata

Release files for e2b-adk 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for e2b-adk 0.1.1
File Size Uploaded Provenance
e2b_adk-0.1.1.tar.gz 32.1 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for e2b-adk 0.1.1
File Interpreter ABI Platform
e2b_adk-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 56.6 kB

Release files / e2b_adk-0.1.1.tar.gz

Download URL e2b_adk-0.1.1.tar.gz
Size 32.1 kB
Tags Source
SHA-256 checksum
How to use checksums
8a306e2b7635c232288830200207b45dda8f333c0f4cd3fd7027516889acb9c8
BLAKE2b-256 checksum
How to use checksums
1d2fa1ac9f9a6d370ee9f54f735517e5c0f87c79c6f4aa9987089d3f4ccdac96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 23, 2026.

Transparency log

Release files / e2b_adk-0.1.1-py3-none-any.whl

Download URL e2b_adk-0.1.1-py3-none-any.whl
Size 24.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4d9382b67cef0e9b17373c43be3d038e311911558edca9596844291c9aafbd6e
BLAKE2b-256 checksum
How to use checksums
7faa9edaab0b04a1a184c84d8e417af88b37e58e5f1fd933f4c4175f3ee7b48b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 23, 2026.

Transparency log

Security for e2b-adk 0.1.1

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for e2b_adk-0.1.1.tar.gz

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 23, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page