Skip to main content
Google ADK (Agent Development Kit) is Google’s framework for building agents, with Gemini as the default model. The E2B integration gives ADK workloads an isolated remote workspace for running code and commands instead of executing them on your host.

Choose an integration

Native ADK environment

Use Google’s built-in E2B environment for direct shell and file operations

Advanced E2B plugin

Give an ADK agent ready-made code, command, file, and background-process tools
Choose the native environment when your application directly controls the sandbox. Choose the advanced plugin when the agent itself should decide when to run code, manage files, or start a service.

Native: Google ADK environment

Google ADK includes the experimental E2BEnvironment for direct command execution and file access through ADK’s environment API. No additional integration package is required.
Create and close the environment explicitly in your application:
This path exposes the sandbox as a low-level workspace: your application calls execute, read_file, and write_file itself.

Advanced: E2B plugin

The e2b-adk plugin exposes sandbox operations as tools the model can call. It adds stateful code execution, shell commands, file management, and background processes backed by the E2B Code Interpreter. The plugin creates one sandbox lazily, shares it across tool calls, and closes it with the ADK runner. To use E2B with ADK:
  1. Create an E2BPlugin.
  2. Hand plugin.get_tools() to your Agent and register the plugin on the App.
  3. Run the agent — every tool call executes inside the sandbox, and the plugin creates and tears the sandbox down for you.

Install the dependencies

Install the plugin. It pulls in Google ADK and the E2B Code Interpreter SDK.
You need an E2B API key for the sandbox and a Gemini key for the model.

Example: Data analysis agent

A good fit for a sandbox is analysis the model shouldn’t do in its head. Here the agent is given a raw dataset and a question. Rather than eyeballing the numbers, it writes the data to a file, runs real pandas against it, and reports figures it actually computed — the sandbox is a calculator it can’t fool.

Create the plugin and agent

The plugin owns the sandbox. Pass its tools to the Agent and register it on the App; the instruction is what makes the agent run code rather than guess.

Run the analysis

Run the agent inside an InMemoryRunner. The sandbox is created lazily on the first tool call, kept alive while the agent works, and killed when the async with block exits — you never manage it yourself.
The agent writes sales.csv with write_file, then uses run_code to load it with pandas, compute revenue-per-dollar and per-month totals, and answer in prose — every number backed by an execution in the sandbox:
Pass verbose=True to run_debug to also print each tool call and its result as the agent works.

Full example

Example: Code generation agent

The same tools support a code generator that verifies its own work. The instruction tells the agent to execute every snippet in the sandbox before returning it, so what you get back has already run and passed its tests — no untested code reaches the user.

Tools

plugin.get_tools() returns six tools, all sharing the plugin’s single sandbox so state persists across calls. Each returns a dict with a success flag and reports 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 returns success: False.

Configuration

E2BPlugin accepts 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.
The plugin keeps the sandbox alive while the agent is working: every tool call pushes the expiry window forward by timeout (E2B’s default is 300s). An idle gap longer than timeout still expires the sandbox under E2B’s default lifecycle — pass lifecycle={"on_timeout": {"action": "pause"}, "auto_resume": True} to pause and auto-resume across idle gaps instead. See the repository README for the full option list.

Reference examples

Complete, runnable scripts live in the plugin repository.

Data analysis agent

Compute real answers from a dataset with pandas in the sandbox

Code generator

Return only code that has been executed and tested