# From fork() to Fleet: Designing an Agent Sandbox Cloud — Abhishek Bhardwaj, OpenAI <!-- ref: @content/youtube/aie/2026-07-13-from-fork-to-fleet-designing-an-agent-sandbox-cloud-abhishek-bhardwaj tags: [agent-infrastructure, sandboxing, micro-vms, virtualization, persistence, snapshotting, orchestration, security] triggers: [need for secure code execution, performance issues with existing sandboxes, exploring agent infrastructure options] trigger_prompt: When you're looking to build a secure and efficient environment for executing untrusted code, especially in AI applications. version: 2 updated_at: 2026-10-18T05:41:12.544Z --> Design an agent sandbox cloud using micro VMs for secure and efficient code execution. **[Watch on YouTube](https://www.youtube.com/watch?v=OqM67QG_Ikk)** # From fork() to Fleet: Designing an Agent Sandbox Cloud — Abhishek Bhardwaj, OpenAI *Synthesized from Abhishek Bhardwaj on AI Engineer, 2026-07-13.* Abhishek Bhardwaj works on OpenAI's RL and agent infrastructure team, building both the reinforcement-learning infra and the production systems that run untrusted model-generated code for ChatGPT and Codex Web; he previously worked on CrosVM at Google. ## Core Thesis Bhardwaj argues that code execution was the unlock that made models reliable on verifiable-reward domains like math and code, which makes the sandbox — not the model — the load-bearing infrastructure piece. Walking the isolation ladder from `fork()`/`exec()` through containers to gVisor to hardware virtualization, he concludes that only micro VMs put a hardware boundary between untrusted code and the host, and teams should start there rather than grieving their way to it. His second claim: compute was the first unlock, durable disk state is the next one — snapshot/restore is what turns a sandboxed Linux box into a true long-horizon knowledge worker. ## Key Insights - Models answer "what is 3+3" from pretraining but fail "how many R's in strawberry" — giving them a code-execution tool lets them hill-climb on any verifiable-reward domain. Training loop: task → model emits tool call → harness executes → grader scores → backprop. - Research and product sandboxes optimize differently: research wants **throughput** (many parallel rollouts), product wants **latency** (slow sandbox start = churn). Reliability and security matter to both — a failed run burns GPU tokens, and a rooted training sandbox threatens model weights. - Two Linux attack vectors: getting root (still ring 3, but can read SSH keys and encryption data) and a kernel-mode exploit in ring 0 — the latter Bhardwaj calls "a New York Times article waiting to happen." - `fork()`/`exec()` is the fastest option (native performance) and the worst on everything else — direct kernel access plus a fork-in-a-while-loop noisy-neighbor problem that takes down the node. - Containers = namespaces (PID, network, mount — resource isolation) + cgroups (CPU/memory limits). seccomp shrinks the syscall attack surface, but you rarely know which syscalls an agent needs in advance, so the feedback loop is bad for magical agent experiences. - gVisor implements the Linux API in a user-space kernel — the Sentry (written in Go) plus the Gopher daemon for file system access. Exploits land in ring 3, but Sentry and Gopher still sit on the host kernel, so a two-step chained exploit still reaches it. - Hardware virtualization is the real boundary: the guest kernel runs in ring 0 but in **VMX non-root** mode, while the host kernel and hypervisor run ring 0 in **VMX root**. Full control inside the guest, zero control over the host — at the cost of a performance penalty on every context switch. - VMMs (QEMU, Cloud Hypervisor) exist mostly to configure kernel/rootfs/CPU/memory and call into `/dev/KVM`. Paravirtualization via **virtio** lets guest drivers know they're virtualized and exit efficiently to host-side block and network backends. - The 2023 shift to Rust-based VMMs: **CrosVM** came first (Bhardwaj's team at Google, for Linux VMs on Chromebooks), **Firecracker** forked CrosVM and powers AWS Lambda, **Cloud Hypervisor** is the general-purpose multi-company option. QEMU's cruft — many architectures, many C-written devices — was historically where escape attacks landed. - "Micro" in micro VM describes the VMM, not the guest: fewer supported devices means a smaller memory footprint and faster boot. - Micro VM trade-offs are real: memory reclaim is reactive via the balloon driver, and GPU access is awkward — virtio-GPU gives high-level graphics library access, while VFIO gives direct metal access but only to one sandbox at a time, no multi-tenancy. - Persistence counterintuitively buys reliability and scale: periodic checkpointing lets a sandbox restore on a different node after a node or cluster failure, and enables intentional moves for cluster upgrades or node A/B testing. - Snapshotting also enables Monte Carlo tree search over solution space — checkpoint, explore, backtrack, checkpoint again, across days of rollouts. Bhardwaj cites a personal 3-day Codex "gold mode" run and expects horizons to keep growing. - Block-level snapshotting beats file-level: Linux disks are block devices, inodes map file offsets to logical blocks, and zipping only changed blocks avoids write amplification. Sharing a folder (Google-Drive style) forces a VM exit per file system operation; a block device lets the guest use its own caches and exit only when it truly needs the host. - Explicit persistence via copy-on-write on XFS: zero-latency copy of a `base.image` into a writable layer, `FIEMAP` to identify changed block extents, zip and upload. The save API can return before the upload finishes — "lie" to the caller and upload in the background. - Always-on persistence: write a POSIX-compliant file system over GCS/S3 exposed inside the guest via **NBD**, with a tiered block cache (in-cluster cache → object storage). NFS is rejected as neither performant nor POSIX-compliant, and models are best at standard POSIX behavior. - Snapshot lineage informs scheduling: since restoring means pulling down N layers, the cluster scheduler can score nodes by how many layers they already hold and route to the node needing the fewest downloads. ## Actionable Takeaways 1. **If you're building agent sandbox infrastructure, start with micro VMs.** Bhardwaj's "seven stages of sandboxing" — containers → gVisor → V8 isolates → eventually a full VM anyway — costs about two years. Skip it. 2. **Pick a Rust-based VMM** (Cloud Hypervisor, Firecracker, or CrosVM) over QEMU for memory safety and a smaller device surface. 3. **Jail each emulated device separately** with seccomp — give the block backend only block permissions and the net backend only network permissions, so compromising one device doesn't own the system. 4. **Boot a micro VM through the VMM API, not a config file:** fork the Cloud Hypervisor binary → it exposes an API over a Unix domain socket → call `create` with rootfs, kernel, CPU, memory → call `start` → it calls into `/dev/KVM`. 5. **Run a PID 1 inside the sandbox that exposes an API server**, and talk to it from the harness over vsock (or the node's IP stack) for save-state and device-attach operations. 6. **Make snapshots incremental, not full** — saving gigabytes per turn is both slow and financially untenable at ChatGPT/Codex scale. 7. **Return from the save API before the upload completes.** Snapshot and restore latency are both product-facing; restore is just create-from-snapshot. 8. **Decide three snapshot axes explicitly:** incremental vs. full, whole rootfs vs. configurable folders (e.g. just `/workspace`), and block-level vs. file-level diffing. 9. **For low-latency creation, combine warm pools with memory snapshots.** A pure warm pool burns idle CPU and memory; a micro VM memory snapshot starts just-in-time in milliseconds; a hybrid grows the pool from snapshots. 10. **Score scheduling on snapshot-layer locality** — route a restore to the node that already holds the most layers of that snapshot's lineage. 11. **Choose security over performance when they conflict.** Bhardwaj's rule: systems tricks can paper over performance problems, but nothing papers over a breach. ## Notable Quotes > "System tricks can cover performance issues, but they cannot hide security breaches." — Abhishek Bhardwaj > "If you get a kernel exploit, it's a New York Times article waiting to happen." — Abhishek Bhardwaj > "It's kind of a slap on the face for 20 years of cloud computing that everyone's running this locally on their laptops." — Abhishek Bhardwaj > "In the end, everyone always wants a VM because they tried everything." — Abhishek Bhardwaj > "Imagine if I gave you a computer without a disk. Every time you close the laptop, your data and your work goes away." — Abhishek Bhardwaj --- *Related: `@protocol/memento` · `@content/youtube/yifan-bth/the-openclaw-security-settings-i-actually-change` · `@content/youtube/tiago-forte/i-connected-claude-to-everything-then-i-saw-the-gap` · `@content/youtube/cole-medin/ai-makes-us-way-faster-but-fries-our-focus-heres-what-i-do-about-it` · `@content/youtube/cole-medin/omnigent-the-new-meta-harness-for-every-coding-agent-claude-code-codex-pi-more`* --- *You're reading a protocol on [protocol.supply](https://protocol.supply) — hosted, searchable knowledge for AI agents. Think Agent Skills, as an API: bootstrap once (`curl -sL https://api.protocol.supply/bootstrap`), search (`/search?q=…`), fetch (`/@repo/slug`).* *Any skill can become a protocol, and any protocol installs as a local skill — tell your agent "install this as a skill" or see [`@protocol/protocol-to-skill`](https://api.protocol.supply/@protocol/protocol-to-skill).*