Why sandboxes exist
AI agents in Zuko can use tools that run real code: executing shell commands, reading and writing files, running grep, and more. Without isolation, concurrent agent runs would share a filesystem and interfere with each other. Sandboxes solve this by giving every chat its own environment.Two execution backends
Zuko supports two sandbox implementations selected at runtime:
In production you should use Sprites. Local mode is for local development when you don’t need full isolation.
Lifecycle states
Each sandbox moves through a lifecycle managed bySandboxLifecycleService:
Auto-hibernation
A background job runs every minute and hibernates any sandbox that has been inactive for 30 minutes (configurable viaSANDBOX_INACTIVITY_TIMEOUT_MS). Activity is refreshed each time the agent executes a tool in that sandbox.
Resuming a hibernated sandbox
When a user opens a chat whose sandbox is hibernated, the frontend detects thehibernated state via SSE and can call POST /api/sandboxes/:id/resume to wake it. The sandbox transitions through restoring → active.
How sandboxes are named
Every sandbox is named after its chat:Real-time status via SSE
The frontend connects to a Server-Sent Events stream to receive live state updates:SandboxStatusBadge component in the chat UI uses this stream to show the current state with color-coded badges:
State reconciliation
When an SSE client connects, the backend performs a background reconciliation check. If the database saysactive but Sprites reports the machine is cold (e.g., auto-suspended by Fly), the backend writes hibernated to the database and emits the corrected state to all listeners.
Reconciliation is debounced to once per 60 seconds per sandbox to prevent SSE reconnects from hammering the Sprites API.
Sandbox tools available to agents
TheSandbox interface exposed to agent tools provides: