| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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.
pip install e2b-adkOr with uv:
uv pip install e2b-adkYou 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.
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())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) |
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, …)
)Run one with the credentials above:
uv run --extra examples python examples/data_analysis.pyMIT — see LICENSE.
| Back | FazBrowse Home | New Git URL |