For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.
Set up a sandbox template
Create a sandbox template, then start a Sandbox from it and run a command.
A Sandbox is an isolated scratch environment that a person, a script, or an agent creates to run commands. A sandbox template says what every Sandbox of one kind starts with: the container image that holds its programs, and the worker pool that runs it.
In this tutorial, you create a template for Python, start a Sandbox from it, and run a command in it. The kagent UI has no page for sandbox templates, so you work from the command line.

Before you begin
Install kagent, and make sure that the
kagentCLI andjqare on your path.Set the sandbox guest image. kagent runs its own guest program in every Sandbox, and the chart does not ship a default image for it, so a template does not become ready until you set one.
cat > sandbox-values.yaml <<'EOF' config: sandboxes: guestImage: ghcr.io/kagent-dev/kagent/sandbox-guest@sha256:354825706868fc4d39300fe7795f4fa04d1eb53c3c93fb5b65b5da76f8222db7 EOFApply the file to your kagent release. The commands read the installed chart version, so that the upgrade keeps that version and the release’s other values.
export KAGENT_CHART_VERSION=$(helm list -n kagent -o json \ | jq -er '.[] | select(.name == "kagent") | .chart | ltrimstr("kagent-")') helm upgrade kagent \ oci://ghcr.io/kagent-dev/kagent/helm/kagent \ --namespace kagent --version "$KAGENT_CHART_VERSION" \ --reuse-values -f sandbox-values.yaml --wait
Choose an image
The image holds every program that the Sandbox can run. A Sandbox has no network access unless you grant it, so a command cannot install a missing package later.
kagent accepts only an image that is pinned to a digest. To read the digest of a public image, run this command.
docker buildx imagetools inspect python:3.13-slim --format '{{json .Manifest.Digest}}'Create the template
Apply the template. It uses the
kagent-defaultworker pool and the snapshot location that the installation sets up.kubectl apply -f - <<EOF apiVersion: api.kagent.dev/v1alpha3 kind: SandboxTemplate metadata: name: python namespace: kagent spec: workload: image: docker.io/library/python:3.13-slim@sha256:e48f59cdba69a3cbd9ed2cf0f348d90d45a8d350d98134cf1070bc106ee9ed90 env: - name: LANG value: C.UTF-8 substrate: workerPoolRef: name: kagent-default snapshotPolicy: location: s3://ate-snapshots/kagent/ EOFWait until the template is ready. kagent builds a snapshot of the template first, which can take a minute the first time that a Worker pulls the image.
kubectl wait sandboxtemplate/python -n kagent --for=condition=Ready --timeout=5mIf the command times out, read the reason.
kubectl get sandboxtemplate python -n kagent \ -o jsonpath='{range .status.conditions[?(@.type=="Ready")]}{.status} {.reason} {.message}{end}'The reason
PreparationFailedusually means that the guest image from Before you begin is not set.List the templates that you can create a Sandbox from.
kagent sandbox templatesExample output:
NAMESPACE NAME IMAGE kagent python docker.io/library/python:3.13-slim@sha256:e48f59cdba69a3cbd9ed2cf0f348d90d45a8d350d98134cf1070bc106ee9ed90
Try the template
Create a Sandbox from the template, and save its ID. The request ID makes the command safe to retry.
export SANDBOX_ID=$(kagent sandbox create python --request-id "cli-$(uuidgen)" -o json | jq -r .id) echo $SANDBOX_IDRun a command in the Sandbox.
kagent sandbox exec $SANDBOX_ID -- python --versionExample output:
Process proc-2c32646d3e4cac9f0763a1da in sandbox 01a209a5-684a-7106-85ca-8851f2059dd6: started (stdout offset 0, stderr offset 0) Python 3.13.18 Process proc-2c32646d3e4cac9f0763a1da: PROCESS_STATE_EXITED, exit_code=0Delete the Sandbox when you are done.
kagent sandbox delete $SANDBOX_ID