StateSet Sandbox - Production Guide
Overview
StateSet Sandbox is a secure, isolated execution environment for running code on behalf of AI agents. It provides containerized sandboxes with full lifecycle management, checkpointing, artifact storage, and usage tracking.Architecture
Component Details
Exec Agent Runtime
The sandbox base image includes both Node.js and Go exec agents. SetEXEC_AGENT_RUNTIME=go for a lower memory footprint (~8 MB vs ~45 MB RSS). The two runtimes are wire-compatible, so no controller changes are needed.
Database Tables
User Flow
1. Registration
Developer signs up via API or dashboard:2. SDK Installation
Node.js:- Rust:
sdk-rust/README.md - Ruby:
sdk-ruby/README.md - Go:
sdk-go/README.md - PHP:
sdk-php/README.md - Java:
sdk-java/README.md - Kotlin:
sdk-kotlin/README.md - Swift:
sdk-swift/README.md
3. Basic Usage
StateSetSandboxExtended:
4. Advanced: Checkpoints
Save and restore sandbox state:5. Advanced: Artifacts
Upload and download files:6. Advanced: Webhooks
Get notified of sandbox events:7. Templates
Create sandboxes from pre-configured templates:8. REPL Sessions
Interactive Python REPL with persistent session state. Variables, imports, and objects survive across execute calls — ideal for data exploration, iterative development, and AI agent workflows. Enable: SetREPL_ENABLED=true on the controller.
API Reference
Authentication
All API requests require authentication via header:Endpoints
Registration & API Keys
Sandboxes
Checkpoints
Artifacts
Webhooks
Usage & Billing
Templates
REPL Sessions
Webhook Events
Pricing
Plans
Usage-Based Pricing
Dashboard
Access at:https://sandbox.stateset.com/dashboard
Pages
Security
API Key Security
- Keys are hashed (SHA-256) before storage
- Original key shown only once at creation
- Keys can have scopes and expiration
- Rate limiting per key
Sandbox Isolation
- Each sandbox runs in isolated Kubernetes pod
- Network policies restrict pod communication
- Resource limits enforced (CPU, memory)
- Read-only root filesystem
- Non-root user execution
Data Protection
- All data encrypted in transit (TLS)
- Database encrypted at rest
- Secrets stored encrypted with KMS
- Audit logging for compliance
Environment Variables
Controller Configuration
Metrics Access
/metrics is protected in production. Configure your monitoring stack to include the auth header you use for metrics access.
If you use Prometheus Operator, apply k8s/prometheus/service-monitor.yaml and add your metrics auth header to the scrape config:
Warm Pool Profiles
Use warm pool profiles to pre‑warm the most common CPU/memory shapes and reduce cold starts. Profiles are matched oncpus + memory with optional isolation.
Example configuration:
isolation on sandbox creation, ensure the matching warm pool profile sets the same isolation.
Internal stats endpoint (production requires X-Internal-Token):
Tunnel Configuration
Tunnels expose a sandbox port through the API gateway. Optional settings:TUNNEL_BASE_URL=https://api.sandbox.yourdomain.comTUNNEL_DEFAULT_TTL_SECONDS=3600TUNNEL_MAX_TTL_SECONDS=86400
Artifact Storage (Cloud)
Google Cloud Storage (GCS)
Required settings:STORAGE_PROVIDER=gcsSTORAGE_BUCKET=your-bucket
remote_path is treated as a relative path and always stored under artifacts/<organization-id>/.
If you are not using Workload Identity, mount a service account key and set:
GCS_PROJECT_ID=your-gcp-project-idGCS_KEY_FILE=/var/secrets/gcp/key.json
Deployment
Kubernetes Resources
Custom Resource Definitions (CRDs)
Apply CRDs before deploying:SANDBOX_BACKEND=crd for declarative sandbox management. This enables kubectl get ssb (sandboxes) and kubectl get wp (warm pool entries).
Health Checks
- Liveness:
GET /health - Readiness:
GET /ready
Troubleshooting
Common Issues
401 Unauthorized- Check API key format:
ApiKey sk-sandbox-xxx - Verify key exists in the database and is not revoked
- Check Kubernetes connectivity
- Verify namespace exists
- Check resource quotas
- Verify database proxy is running (if used)
- Check workload identity / service account bindings
- Verify database credentials
Logs
Support
- GitHub Issues: https://github.com/stateset/sandbox/issues
- Documentation: https://docs.stateset.io/sandbox
- Email: support@stateset.io