Appearance
Google ADK
The Agent Development Kit builds agents from tools. Make one of those tools a sandbox and any code the model writes runs in a disposable Linux environment rather than in your process.
Setup
bash
pip install ovrin google-adk
export OVRIN_API_KEY="ovrin_..."
export GOOGLE_API_KEY="..."A sandbox as a tool
python
import ovrin
from google.adk.agents import Agent
client = ovrin.Client() # reads OVRIN_API_KEY
def run_python(code: str) -> dict:
"""Execute Python in an isolated sandbox and return its output.
Args:
code: The Python source to run.
"""
sandbox = client.sandboxes.create(template="python", timeout=300)
try:
result = sandbox.run(f"python -c {code!r}", timeout=120)
return {"stdout": result.stdout, "stderr": result.stderr}
finally:
sandbox.kill()
agent = Agent(
name="analyst",
model="gemini-2.0-flash",
instruction="Write and run Python to answer questions. Always verify by executing.",
tools=[run_python],
)ADK reads the docstring and type hints to build the tool schema, so the signature above is the contract the model sees.
Shell access too
Nothing restricts the tool to Python — the sandbox is a whole machine:
python
def run_shell(command: str) -> str:
"""Run a shell command in an isolated sandbox.
Args:
command: The command to run.
"""
sandbox = client.sandboxes.create(template="ubuntu", timeout=300)
try:
return sandbox.run(command, timeout=120).stdout
finally:
sandbox.kill()Cost control
Every tool call creates billable compute. Keep timeout tight, kill in a finally, and watch concurrency against your plan's limit — see Plans & billing.
Related
- LangGraph — the same pattern in another framework
- MCP server — skip the glue code entirely