github kubernetes-sigs/agent-sandbox v1.0.13

one hour ago

🚀 Announcing Agent Sandbox v1.0.13!

Agent Sandbox v1.0.13 is now available. This release makes Sandbox PodScheduled and Finished conditions persistent, strengthens Sandbox, SandboxClaim, and SandboxWarmPool reconciliation against deletion and adoption races, hardens sandbox-router startup validation when migrating from the legacy Python router, adds PID 1 orphan reaping and graceful shutdown signaling for Execute commands in sandboxd, expands interactive process, metrics, and cleanup capabilities across the Go, Python, and TypeScript SDKs, and adds a Harbor evaluation integration along with Claude and OpenAI Managed Agents examples.

⚠️ Action Required

  • Persistent PodScheduled and Finished status conditions (#2142):
    • The Sandbox PodScheduled condition is no longer removed when no backing Pod exists or after expiry. It now reports status: False with reason PodAbsent when no owned Pod exists and status: False with reason SandboxExpired after expiry. Clients inspecting PodScheduled must check its status field rather than condition presence.
    • The Finished condition on Sandbox and SandboxClaim stays absent until a backing Pod first reaches Succeeded or Failed, and is no longer removed once set (transitioning to status: False with reason NotFinished if a later or replacement Pod has not finished). Because Finished=True is now preserved while a Sandbox is suspended, ttlSecondsAfterFinished on its SandboxClaim continues running during suspension and can delete the finished Sandbox and its PVCs. Sandboxes suspended before upgrading already had Finished removed, so upgrading does not start their TTL.
    • Deleting or evicting a running Sandbox's Pod through the Kubernetes API (such as via kubectl drain) no longer sets Finished=True, starts ttlSecondsAfterFinished, or increments agent_sandbox_finished_total.
  • sandbox-router startup validation for ROUTER_AUTH_TOKEN (#2448):
    • The Go sandbox-router does not authenticate requests using the legacy Python router's ROUTER_AUTH_TOKEN environment variable and now refuses to start if ROUTER_AUTH_TOKEN is set to a non-empty value while --authz-mode is allow-all (the default) or tokenreview without --authz-tokenreview-require-token.
    • Before upgrading, either unset ROUTER_AUTH_TOKEN or switch to --authz-mode=scoped-token or --authz-mode=tokenreview with --authz-tokenreview-require-token, and issue clients credentials matching that authorization mode.

Highlights

Core & Extension Controllers

  • Persistent PodScheduled and Finished conditions (#2142): SandboxReconciler now keeps PodScheduled always present (False/PodAbsent when no owned Pod exists, False/SandboxExpired after expiry) and keeps Finished persistent once set—retaining it across suspension, Pod termination, and Pod lookup failures, and avoiding marking a Sandbox finished on API-driven Pod deletion or eviction—while SandboxClaimReconciler preserves its mirrored Finished condition instead of removing it.
  • Prevent re-adoption during orphan deletes (#2212): SandboxReconciler now reads the Sandbox directly from the Kubernetes API server (APIReader) before adopting an unowned Pod, Service, or PVC, skipping adoption if the Sandbox is deleted, deleting, or replaced by a new UID.
  • Replace deleted bound Sandbox on SandboxClaim (#2390): SandboxClaimReconciler confirms cached NotFound results for the status-recorded Sandbox against the API server before clearing the stale status.sandbox binding and adopting or creating a replacement Sandbox, preventing claims from staying Ready=True with a deleted Sandbox's serviceFQDN.
  • Protect adopted SandboxWarmPool members from deletion (#2415): SandboxWarmPoolReconciler now deletes pool-owned Sandbox resources with UID and ResourceVersion preconditions during scale-down, stuck-sandbox cleanup, and Recreate stale cleanup, skipping 409 Conflict responses so sandboxes concurrently adopted by a SandboxClaim are preserved.
  • Consistent EnvVarsInjectionRejected claim reporting (#2442): SandboxClaim rejections for overriding a template variable under the Allowed policy or targeting a containerName missing from the template now wrap ErrEnvVarsInjectionRejected and report Ready=False with reason EnvVarsInjectionRejected instead of retrying with ReconcilerError. Edit or recreate the SandboxClaim to recover.

Sandbox Router

  • Fail closed when ROUTER_AUTH_TOKEN is set without token-requiring authz (#2448): Config.Validate rejects configurations with a non-empty ROUTER_AUTH_TOKEN under --authz-mode=allow-all or --authz-mode=tokenreview without --authz-tokenreview-require-token.
  • Separate client cancellations from upstream errors (#2352): Requests canceled by the caller are now counted in sandbox_router_upstream_errors_total with reason="client_canceled" and logged at V(1) instead of reason="other" with an error-level log. Plain HTTP responses still return status 502 (with detail "The client canceled the request"), and gRPC callers still receive codes.Canceled.

sandboxd

  • Orphan process reaping as PID 1 (#2419): When running as PID 1, sandboxd now runs a background reaper triggered by SIGCHLD and a 10-second periodic rescan (using Linux /proc/<pid>/task/<tid>/children) to reap exited orphaned grandchildren without interfering with directly managed child processes.
  • Signal Execute commands on daemon shutdown (#2434): On shutdown (ShutdownProcesses), sandboxd now signals all active child processes started via gRPC Execute and ExecuteWithLimits (in addition to streaming Start) with SIGTERM, followed by SIGKILL after 2 seconds or --shutdown-timeout (whichever is shorter), instead of leaving them running until the server force-stops.
  • Keep command leader unreaped until cleanup finishes (#2369): sandboxd now waits for command leader exit via waitid(..., WEXITED|WNOWAIT) and delays cmd.Wait() until process-tree termination and cancel cleanup complete, avoiding signaling an unrelated process that reused the leader's PID.
  • Preserve file permissions on REST overwrite (#2451): REST PUT /v1/files/{path} now keeps an existing file's permission bits when overwriting without an explicit mode query parameter instead of resetting them to 0644. New files still default to 0644.
  • Map ENOTDIR to NOT_FOUND and INVALID_ARGUMENT in gRPC handlers (#2328): gRPC WatchDir and process Execute/ExecuteWithLimits/Start now return NOT_FOUND instead of INTERNAL when a parent path component is a non-directory (such as a regular file), and Execute/ExecuteWithLimits/Start return INVALID_ARGUMENT when cwd itself is not a directory.

SDKs

  • Go SDK:
    • Added ProcessHandle.WriteStdin() and ProcessHandle.CloseStdin() to send serialized stdin chunks (up to 1 MiB per RPC) and EOF to streaming processes started with Commands.Start() (#2358).
    • Added WithPTY(cols, rows) for Commands.Start() and ProcessHandle.ResizeTTY(ctx, cols, rows) with dimensions in [1, 65535]; Commands.Run() rejects WithPTY with gRPC codes.InvalidArgument (#2374).
    • For the sandboxd runtime, added Files.Stat() and Sandbox.Stat() (calling REST GET /v1/files/{path}?stat=true and returning *FileEntry) and updated Files.Read() and Files.ReadTo() to send type=file so reading a directory returns a 409 HTTPError instead of a JSON directory listing (reading the sandbox root "/" or "." continues to fail locally before making a request) (#2294).
    • Added Options.WaitForTermination (default false) so Sandbox.Close() deletes the SandboxClaim with foreground propagation pinned to its UID and waits for the claim to disappear (sharing CleanupTimeout; requires get permission on SandboxClaims), and updated Client.DeleteAll() and Client.EnableAutoCleanup() to close tracked sandboxes concurrently (#2325).
  • Python SDK:
    • Added opt-in enable_auto_cleanup() (must be called from the main thread) to both SandboxClient (sync) and AsyncSandboxClient (async) to delete tracked sandboxes on SIGTERM (with a 10-second cutoff, keeping claims explicitly named in create_sandbox() just like atexit cleanup) without overriding existing custom or ignored SIGTERM handlers (#2428).
    • Guarded claim deletion in both sync (K8sHelper.delete_sandbox_claim()) and async (AsyncK8sHelper.delete_sandbox_claim()) helpers to return early for empty strings or invalid DNS-1123 subdomain names (such as "." or ".."), preventing accidental deletion of all SandboxClaims in the namespace (#2468).
    • Fixed AsyncFileWatcher.watch() (async only) to cancel its gRPC WatchDir stream in a finally block on generator close or error (callers retaining the generator or needing deterministic cleanup should call await gen.aclose()) so early exits do not exhaust sandboxd's 64-watch limit (#2482).
    • Updated both sync and async files.read() / files.read_to() to send type=file (#2346) and files.list() to send type=directory (#2469) on the sandboxd runtime so mismatched path types fail with HTTP 409 instead of returning a directory listing or downloading a file into an error message.
    • Updated sync SandboxClient.create_sandbox() to catch BaseException during claim creation, readiness wait, and handle construction so KeyboardInterrupt or SystemExit rolls back a generated SandboxClaim (analogous to AsyncSandboxClient rolling back on asyncio.CancelledError) (#2438).
    • Switched label, environment variable name, and router_namespace validators to re.fullmatch so trailing newlines are rejected (#2377).
  • TypeScript SDK:
    • Added optional OpenTelemetry latency histograms in seconds (sandbox.client.discovery.latency, sandbox.client.suspend.latency, sandbox.client.resume.latency, rendered by the OTel Prometheus exporter as sandbox_client_{discovery,suspend,resume}_latency_seconds) across connection establishment, suspend(), and resume(), degrading to no-ops when @opentelemetry/api or a MeterProvider is absent (#2333).
    • Guarded SandboxClient.deleteSandbox() to return early for empty or invalid DNS-1123 subdomain claim names (such as ".", "..", or the empty claimName on handles returned by getSandboxByName()), preventing namespace-wide claim deletion (#2468).
    • Fixed buffered REST response body reads to cancel the stream reader directly when the caller's AbortSignal aborts, preventing hangs on Node 22 after response headers arrive (#2362).
  • Integrations (clients/integrations/):
    • Added clients/integrations/harbor (k8s_agent_sandbox_harbor:AgentSandboxEnvironment), a Harbor evaluation environment that manages per-image SandboxTemplate/SandboxWarmPool pairs, creates and deletes per-trial SandboxClaims via AsyncSandboxClient, runs commands and tar transfers over the pod exec API, and provides python -m k8s_agent_sandbox_harbor cleanup (#2125).
    • Added the get_sandbox_health tool to clients/integrations/mcp-server, wrapping AsyncSandbox.health() (GET /v1/health on sandboxd) and returning healthy: false on HTTP 503 (#2354).
    • Excluded openhands-sdk==1.63.0 in clients/integrations/openhands/pyproject.toml to avoid an upstream import error (#2353).

Examples

  • Managed Agents bridges (examples/managed-agents/): Added examples/managed-agents/claude-managed-agents (#2314) and examples/managed-agents/openai-managed-agents (#2357) demonstrating self-hosted sandbox execution bridged to SandboxWarmPool, SandboxClaim, and suspend/resume with workspace PVC retention, including cma-runner/oma-runner container images and kind test scripts.
  • OpenClaw per-sandbox gateway tokens: Updated examples/openclaw-fleet-gke and examples/openclaw-kata-aks-sandbox manifests to generate a random gateway token per sandbox at startup (persisted in the workspace in examples/openclaw-fleet-gke) instead of using a static token (#2404), and added token checks to examples/openclaw-fleet-gke/run-test-gke.sh (#2421).
  • Scoped RBAC in examples/ray-integration/direct-proxy (#2403): Bound claim-management RBAC to a dedicated ray-sandbox-manager ServiceAccount on Ray head and worker Pods and set automountServiceAccountToken: false on the SandboxTemplate.
  • VS Code example fixes (examples/vscode-sandbox) (#2413): Raised ephemeral storage requests and limits to 8Gi, enabled --auth=password in entrypoint.sh, fixed overlays/kata-mshv/patch-kata.yaml to patch individual fields without dropping container settings, and updated scripts/apply.sh and README.md to deploy the Go sandbox-router.
  • Warm-pool autoscaling consolidation (examples/keda-scale-to-zero) (#2464, #2479): Switched the HPA example to an AverageValue target (0.05) with namespace label matching (#2464) and folded examples/hpa-swp-scaling into examples/keda-scale-to-zero with environment-configurable load script settings (#2479).
  • Other example updates:
    • Passed namespace="gymnasium" in examples/agent-sandbox-gymnasium/jupyter/rl_training.ipynb and -n gymnasium in examples/agent-sandbox-gymnasium/README.md (#2454).
    • Updated examples/hermes-agents-as-a-service/10-sandboxtemplate.yaml to allow both amd64 and arm64 nodes via node affinity (#2437).
    • Installed libatomic1 in examples/playwright-sandbox/Dockerfile (#2425) and bumped mcp to 1.30.0 in examples/router-scoped-mcp-sandbox/Dockerfile (#2446).
    • Added examples/sandbox-headlamp-plugin/README.md pointing to the upstream Headlamp plugin setup guide (#1723, #2430) and removed examples/nemoclaw-sandbox (#2402).

Documentation & CI

  • Go 1.27.4 toolchain and dependency updates (#2388, #2367): Updated the Go toolchain and container builder images across the controller, sandboxd, sandbox-router, and examples to Go 1.27.4 for stdlib and toolchain security fixes (#2388), refreshed Go modules (including Kubernetes v0.37.2 and controller-runtime v0.25.3), and moved examples/python-runtime-sandbox and the legacy Python sandbox-router images to python:3.15-slim (#2367).
  • v1.0 API migration guide (docs/api-migration-guide.md) (#2124): Added instructions for rewriting stale v1alpha1 owner references (including on terminating resources), restarting kube-controller-manager to rebuild the garbage collector graph, verifying foreground deletion, and replacing installed CRDs with kubectl replace when upgrading from v0.5.x.
  • Go sandbox-router walkthroughs (#2423, #2455): Updated examples/quickstart/README.md, site/content/docs/getting_started/install_prerequisites/_index.md, and examples/ci-runner-sandbox/README.md to document deploying the Go sandbox-router from sandbox-router/deploy/ with a release tag.
  • OLM bundle and release tooling (#2449, #2363, #2356): Updated the OLM operator bundle manifests to 1.0.12 (#2449), improved dev/tools/generate-release-notes to ground generated release notes in per-commit diffs and release signals (#2363), and updated the release-notes Gemini model default to gemini-4-neon (#2356).

Installation

Standard Install (Core + Extensions)

Recommended for most users and GitOps engines (Argo CD, Config Sync, kustomize):

kubectl apply -f https://github.com/kubernetes-sigs/agent-sandbox/releases/download/v1.0.13/sandbox-with-extensions.yaml

Selective Install

Install components separately:

# Core only:
kubectl apply -f https://github.com/kubernetes-sigs/agent-sandbox/releases/download/v1.0.13/sandbox.yaml

# Extensions (opt-in):
kubectl apply -f https://github.com/kubernetes-sigs/agent-sandbox/releases/download/v1.0.13/extensions.yaml

Python SDK

pip install k8s-agent-sandbox==1.0.13

Contributors

We extend our sincere thanks to all contributors to this release:
@HasonoCell, @Heman10x-NGU, @MichaelChene, @Sean-790761, @aditya-shantanu, @aminbaa, @dongjiang1989, @ericcurtin, @hakman, @iluv7, @janetkuo, @lunarwhite, @payallenka, @pbxqdown, @rmalani-nv, @shrutiyam-glitch, @sidtuladhar, @tatavartilikhitha, @tomergee, @vincent0426, @wjun29, @yankovitchg

New Contributors

Full Changelog: v1.0.12...v1.0.13

Don't miss a new agent-sandbox release

NewReleases is sending notifications on new releases.