Using Agent Sandbox as a Tool in Agent Development Kit (ADK)
The guide walks you through the process of creating a simple ADK agent that is able to use agent sandbox as a tool.
Installation
-
Install the Agent-Sandbox controller and CRDs to a cluster. You can follow the instructions from the installation section from the Getting Started page.
-
Install the Agent Sandbox router
-
Create a Python virtual environment:
python3 -m venv .venv source .venv/bin/activate -
Install the dependencies:
export VERSION="main" pip install google-adk==1.19.0 "git+https://github.com/kubernetes-sigs/agent-sandbox.git@${VERSION}#subdirectory=clients/python/agentic-sandbox-client" -
Create a new ADK project:
adk create coding_agent -
Replace the content of the
coding_agent/agent.pyfile with the following:from google.adk.agents.llm_agent import Agent from agentic_sandbox import SandboxClient def execute_python(code: str): with SandboxClient( template_name="python-sandbox-template", namespace="default" ) as sandbox: sandbox.write("run.py", code) result = sandbox.run("python3 run.py") return result.stdout root_agent = Agent( model='gemini-2.5-flash', name='coding_agent', description="Writes Python code and executes it in a sandbox.", instruction="You are a helpful assistant that can write Python code and execute it in the sandbox. Use the 'execute_python' tool for this purpose.", tools=[execute_python], )As you can see, the Agent Sandbox is called by a wrapper function
execute_pythonwhich, in turn, is used by theAgentclass as a tool. -
Run the agent in ADK’s built in server:
adk web
Testing
-
Open the agent’s page: http://127.0.0.1:8000.
-
Tell the agent to generate some code and execute it in the sandbox:

The agent should generate the code and execute it in the agent-sandbox.
Feedback
Was this page helpful?