Running an isolated Linux computer for every AI agent is easy on a whiteboard and expensive in production. Here is the exact architecture we use in Casama to keep per-bot sandboxes safe under gVisor, fast to wake, and readable while asleep.
Bottom line
Casama isolates every AI teammate on its own gVisor-backed Linux container with a dedicated internal bridge network, fixed peer IPs for the egress proxy and supervisor, warm sleep that stops the container while preserving its home volume for ~1-second resumes, and zero-wake sleeping file reads through Docker's archive API so file previews and agent lookups never wake a parked sandbox.
1. Per-bot gVisor isolation with fixed-peer private networks
Standard Docker containers share the host Linux kernel. When an LLM generates arbitrary shell commands, installs npm or Python packages, or browses untrusted pages, a kernel-level escape or host network pivot is unacceptable.
Every Casama bot computer runs under gVisor (runsc) on its own internal Docker bridge network (Internal: true), with no direct internet route. Outbound HTTP/HTTPS traffic leaves only through our open-source egress proxy (infra/egress-proxy), which enforces per-bot domain rules and injects vaulted credentials on the wire so the model never sees raw secrets.
Under gVisor, Docker's embedded DNS does not always resolve peer services cleanly across deploys. When we create a bot's private network, we reserve deterministic low addresses in the subnet for its three peers — egress proxy (.0.2), supervisor (.0.3), and TURN relay (.0.4) — leave the upper half of the CIDR block to Docker's IPAM, and write /etc/hosts explicitly before the container starts. When a deploy recreates the supervisor or egress container, every running bot reconnects to the exact same fixed peer IP without dropping its session.
2. Warm sleep: ~1-second resume without cold tar restores
Early on, sleeping an idle computer meant archiving /home/casama into object storage, destroying the container, and restoring the tarball on the next message. That worked for long idle stretches, but waking a bot for a quick follow-up 10 minutes later paid a cold-restore penalty every time.
We split sleep into two tiers:
- Warm sleep (
park): When a bot goes idle, the supervisor stops the container (POST /containers/{id}/stop?t=10) while keeping the stopped container, its home volume, and its network intact. Zero CPU is billed while parked. When the user messages again, the supervisor starts a fresh container directly on the existing home volume (marked with aHOME_READYsentinel), skipping object-storage restore entirely. - Cold sleep (
archiveParked): After 24 hours idle (or if host disk pressure crosses our threshold), the supervisor streams/home/casama/.straight out of the stopped container via Docker's host-side/containers/{id}/archiveAPI — outside gVisor, roughly 20x faster than runningtarinside the sandbox — compresses it, verifies the archive is non-empty and intact, uploads it to object storage, and only then removes the container, volume, and private network.
3. Zero-wake sleeping file reads
A surprising source of wasted sandbox wakes has nothing to do with running code: users opening the Files tab, previewing a PDF or spreadsheet a bot generated yesterday, or a bot checking a saved note before deciding what to do.
With zero-wake sleeping file reads, our supervisor reads files directly from a parked container's filesystem via Docker's archive stream (or falls back to the cold .tar.gz snapshot in object storage with a streaming tar scanner capped for safety). Listing directories, generating thumbnails, and previewing .pptx, .xlsx, .pdf, or .md artifacts all work in milliseconds while the bot's computer stays asleep.
4. Handling Docker's 31-subnet bridge pool limit
One real-world lesson from running hundreds of per-bot internal networks: Docker's default bridge address pool caps at 31 subnets unless expanded in daemon.json, and failed warm-pool starts can strand peer containers on orphaned networks. We run an orphan-network sweeper at startup and on demand whenever POST /networks/create hits subnet exhaustion, disconnecting only peer containers (egress, supervisor) from networks with no live or parked bot container attached.
Inspect the open-source parts & 2026 matrix
- Open-source apps,
computerd, computer images, egress proxy, safety rules, CLI, and MCP server: github.com/casama-ai/casama - 2026 AI Agent Safety & Sandboxing Matrix (16 Agents Audited + public JSON)
- How to run Amazon Ergo (1.1T) as an AI agent
- Try Casama Cloud or self-host (free for personal use)
