Agent Sandbox

Image

Create a Sandbox with custom dependencies.

Prerequisites

Architecture

The Agent Sandbox architecture separates the Template (the definition) from the Claim (your Python request) for a very specific reason: speed. When a user applies a SandboxTemplate to a Kubernetes cluster, the controller typically spins up a SandboxWarmPool. These are pre-initialized, running pods that have already pulled your specific Docker image. When a Python script calls client.create_sandbox("sandbox-template"), it instantly grabs one of these pre-warmed pods.

Workarounds

1. Install dependencies via sandbox.commands.run() function

from k8s_agent_sandbox import SandboxClient
client = SandboxClient()
sandbox = client.create_sandbox("python-sandbox-template")
# Dynamically install a package before running your main logic
sandbox.commands.run("pip install custom-package==1.0.0")
response = sandbox.commands.run("python -c 'import custom_package; print(\"Success!\")'")
Last modified April 30, 2026: reorder pages, remove duplicate (#717) (8e62071)