Running code an agent wrote inside a Docker container is a gamble: shared kernel, slow enough cold starts (500ms–2s) that teams skip sandboxing on the hot path, and a steady drip of container-escape CVEs. SmolVM (launched April 17, 2026, close to 500 HN points) runs a libkrun microVM on Hypervisor.framework, KVM or the Windows Hypervisor Platform, documents under 200ms to agent ready, and lets you spin up a fresh VM per agent invocation. Firecracker is still the right choice for long-lived tenant workloads; gVisor for low-trust research tooling; Docker for cached build steps. Route per-request ephemeral AI code execution to SmolVM, not a container.
Update (November 25, 2026): Added a SmolVM vs Microsandbox comparison, since both run on libkrun; the rest of the post is unchanged.
Update (November 11, 2026): SmolVM has moved fast since launch (v1.34.1 as of November 10, 2026): it now runs on Windows, ships SDKs, and supports branching and checkpoints. Corrected how it works (libkrun is the VMM on every platform, on top of Hypervisor.framework, KVM or the Windows Hypervisor Platform), rewrote the code example against the real CLI flags, replaced a misattributed CVE with CVE-2025-31133, replaced unverified SmolVM timing and memory figures with the project's documented ones, and added Firecracker's documented startup, memory and CPU figures (current release v1.18.0); the rest of the post is unchanged.
Across the production agent systems we've audited, the same pattern keeps showing up: an internal agent writes data-cleaning scripts, drops Python into a /tmp directory, and runs it with subprocess.run: on the same host as the orchestrator, the auth service, and the customer database. The reasoning is always the same: "It's behind a VPN." The VPN does not help when the prompt that asks for a script is written by a user on the other side of that VPN. The agent does what agents do, which is produce plausible code from whatever instruction it's given, and the host executes it.
This is the "agent wrote code, do I dare run it?" problem, and it has had the same bad answer for two years: wrap the exec in a Docker container and hope. Docker shares the kernel. A kernel CVE or a runc escape dissolves the boundary. Cold starts of 500ms to 2 seconds make teams skip sandboxing on hot paths altogether. For AI-generated code, where the instruction itself is attacker-influenceable through prompt injection, that is the wrong threat model. On April 17, 2026, smol-machines/smolvm launched and collected close to 500 Hacker News points because it finally closed the gap: a microVM runtime with sub-200ms boots, designed for ephemeral per-invocation agent sandboxing. This post is the head-to-head across SmolVM, Firecracker, Docker, and gVisor, and the decision framework we use at Particula Tech to pick the right one per workload.
The Threat Model: Why Docker Alone Keeps Failing
Every time we audit an AI coding agent or a tool-using agent in production, we find the same pattern: generated code runs in a Docker container on the orchestrator host, with --privileged or with a bind mount to /var/run/docker.sock, because someone needed it to build an image or talk to the host. The shared-kernel model then becomes the problem:
docker.sock mounted in, which is operationally equivalent to full root on the host with extra steps.The fix is a separate kernel per invocation, a microVM. That used to mean Firecracker on Linux with KVM, a jailer process, and an ops team. As of April 17, 2026, it also means SmolVM on your laptop.
SmolVM in 200 Words
SmolVM (the smolvm runtime from smol machines, Apache-2.0) is a microVM runtime you drive from a CLI or embed through SDKs for Node, Python, Rust and Go. It launched April 17, 2026, and collected close to 500 HN points because it filled a gap the Firecracker ecosystem never addressed: a microVM you can spawn as easily as you spawn a subprocess, from any developer machine, documented at under 200ms to agent ready.
Under the hood, libkrun is the VMM on every platform, running on Hypervisor.framework on macOS, KVM on Linux, and the Windows Hypervisor Platform on Windows, with a guest kernel from the project's libkrunfw. Any OCI image boots as a microVM with no Docker daemon. Networking is off unless you pass --net, and egress can be limited to named hosts with --allow-host. The lifecycle maps cleanly to one agent invocation: smolvm machine run creates a VM, runs one command, and deletes it on exit. Since launch it has added copy-on-write branches and checkpoints of running machines, and .smolmachine packs that run as self-contained executables.
The project is moving fast (v1.34.1 shipped November 10, 2026). Its own security model says the boundary is the VM: every folder you mount, host you allow and secret you forward becomes something the workload can use, so the sandbox is only as tight as what you hand it.
Head-to-Head: SmolVM vs Firecracker vs Docker vs gVisor
A few things jump out. Docker is the worst on isolation by a wide margin and the best on ecosystem; gVisor sits awkwardly in the middle on both. Firecracker wins density and prewarm speed; SmolVM wins single-shot cold start and developer ergonomics. For AI-generated code execution, the two columns that matter most are "isolation boundary" (you want hardware virt) and "cold start (single-shot)" (per-invocation, no pool). That puts SmolVM and Firecracker ahead, with SmolVM winning when your workload is "one agent invocation, start from zero, on any OS."
Pick SmolVM when the same sandbox has to run on Windows developer machines, or when you want branches and checkpoints of a running VM. Pick Microsandbox when you want a coding agent such as Claude Code to manage its own sandboxes over MCP with no glue code. Either way, the boundary is only as tight as what you hand the VM: mounts, allowed hosts and forwarded secrets matter more than which libkrun front end you chose.
SmolVM vs Microsandbox
Microsandbox is the closest alternative to SmolVM, and the two are more alike than SmolVM and Firecracker. Both are Apache-2.0, both use libkrun as the VMM, and both boot OCI images as hardware-isolated microVMs without a Docker daemon, so the isolation boundary is the same. The differences are in how you drive them:
| Dimension | Docker | gVisor | SmolVM | Firecracker |
|---|---|---|---|---|
| Isolation boundary | Shared kernel | User-space kernel | Hardware virtualization | Hardware virtualization |
| Cold start (single-shot) | 500ms - 2s | 300 - 800ms | < 200ms to agent ready (documented) | <= 125ms to guest init (VMM only, documented) |
| Cold start (prewarmed pool) | 50 - 200ms | N/A | Copy-on-write branches of a live VM | < 50ms (snapshots) |
| Runs on macOS dev machines | Yes (via VM) | Linux only | Yes (native), also Linux and Windows | Linux + KVM only |
| Memory overhead per instance | 20 - 50 MB | 15 - 30 MB | Elastic guest RAM (virtio balloon) | <= 5 MiB VMM overhead (documented) |
| Concurrency on one host | Hundreds | Hundreds | No published figure | 1000+ |
| Escape-class CVEs (2024-26) | Multiple | Few | None yet (new) | None |
| Ecosystem maturity | Massive | Moderate | Young (v1.34, Nov 2026) | Mature (AWS uses it, v1.18) |
| Setup effort | Minimal | Moderate | Minimal (single binary) | High (jailer + KVM) |
| Dimension | SmolVM | Microsandbox |
|---|---|---|
| VMM | libkrun | libkrun |
| Platforms | macOS, Linux and Windows, native | Linux (KVM) and macOS on Apple Silicon |
| Main interface | smolvm CLI, plus SDKs | msb CLI, plus SDKs |
| Agent integration | Wrap the CLI or SDK in your own tool | Ships an MCP server, so a coding agent can create and run sandboxes as tools |
| Lifecycle extras | Copy-on-write branches, checkpoints, .smolmachine packs | Sandboxes managed through its CLI and SDKs |
Firecracker Startup Time, Memory Footprint and CPU Overhead
Firecracker publishes its performance promises as a specification that its CI enforces on every pull request, measured on AWS m5d.metal and m6g.metal hosts. These are the figures to quote, as of Firecracker v1.18.0 (released November 9, 2026):
Two cautions when you compare these with anyone else's numbers. The 125 ms boot stops at guest init: jailer setup, TAP device creation, IP allocation and drive attach all happen outside it, and so does your own process starting. And the 5 MiB is the VMM's own overhead, not the guest's RAM, which you still allocate per VM. SmolVM's "under 200ms to agent ready" is measured at a different boundary, so the two are not a like-for-like race. The full accounting of where the rest of the boot goes and how to size a host is in Firecracker vs libkrun: boot time, memory, and sizing.
| Metric | Documented figure | What it measures |
|---|---|---|
| VMM startup | 8 CPU ms to API socket (wall clock 6 to 60 ms, typically about 12 ms) | The Firecracker process becoming ready, before any guest boots |
| Boot time | <= 125 ms | From the InstanceStart API call to the guest's /sbin/init, minimal kernel and rootfs, serial console off |
| Memory overhead | <= 5 MiB | VMM threads for a 1 vCPU, 128 MiB guest; grows with workload (for example many vsock connections) and excludes the MMDS data store |
| CPU overhead | > 95% of bare metal | Compute-only guest performance (integration test pending) |
| Network | Up to 14.5 Gbps at <= 80% of one host core, 25 Gbps at 100% | Guest throughput with a dedicated emulation core (test pending) |
| Added I/O latency | 0.06 ms average | Virtualization layer latency (test pending) |
| Storage | Up to 1 GiB/s at <= 70% of one host core | Guest storage throughput (test pending) |
When Each Sandbox Wins
Match the sandbox to the workload. Getting this wrong means either paying for isolation you don't need or running with isolation you do.
SmolVM, per-request ephemeral AI code execution. An agent generates a script, you want it to run once in 200ms with no persistent state, and you want the same code path to work on a developer laptop and a CI runner. This is SmolVM's sweet spot and the exact workload nothing else fits cleanly.
Firecracker, heavy tenant workloads on Linux. You are running multiple long-lived VMs on Linux hosts with KVM, you care about density (100+ VMs per host), and you want snapshot-based prewarming to push cold starts under 50ms. This is the AWS Lambda / Fargate model and it still beats everything else for that shape of workload.
Docker, cached build steps and trusted workers. Your agent needs to run pnpm install, docker build, or a CI pipeline step where the code is not attacker-influenced and the cache matters. Docker's ecosystem and layer caching are still unbeatable for this.
gVisor, untrusted HTTP workloads and research tooling. You are hosting untrusted code behind an HTTP interface (function-as-a-service, code playgrounds) where syscall overhead is acceptable and operational simplicity beats raw speed. gVisor is fine here. For agent code execution specifically, reach for a microVM first.
All four of these assume the code you run is untrusted. If instead you just want to confine a local coding agent running your own code, where the real risk is prompt injection reaching your secrets rather than a hostile workload, you can sandbox the agent with OS kernel primitives and skip the VM entirely.
We spell out the broader isolation-vs-cost tradeoff, including when the answer is to move execution entirely off a shared platform, in our cloud vs on-premise AI security and cost comparison.
Wiring SmolVM to an Agent: A 40-Line Pattern
Here is the minimum viable pattern for running AI-generated code through SmolVM from a TypeScript orchestrator, using the smolvm machine run CLI (the Node SDK's Machine.create and exec give you the same lifecycle in-process). The same shape works for Claude Code tool handlers, Codex CLI custom commands, or OpenHands runtimes.
// sandbox.ts, run agent-generated code in an ephemeral SmolVM
import { spawn } from "node:child_process";
import { mkdtempSync, writeFileSync, readFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
interface SandboxResult {
stdout: string;
stderr: string;
exitCode: number;
wallMs: number;
}
export async function runGeneratedCode(
code: string,
opts: { timeoutMs?: number; allowedHosts?: string[] } = {}
): Promise<SandboxResult> {
const stage = mkdtempSync(join(tmpdir(), "agent-exec-"));
writeFileSync(join(stage, "main.py"), code, { mode: 0o400 });
const started = Date.now();
const hosts = opts.allowedHosts ?? [];
// Networking is off unless --net is passed; --allow-host limits egress
const network = hosts.length === 0
? []
: ["--net", ...hosts.flatMap((h) => ["--allow-host", h])];
const args = [
"machine",
"run", // ephemeral: create, run one command, delete on exit
"--image",
"python:3.12-alpine",
"--volume",
`${stage}:/work:ro`,
...network,
"--cpus",
"1",
"--mem",
"512", // MiB
"--",
"python3",
"/work/main.py",
];
return new Promise((resolve) => {
// Wall-clock budget: Node kills the smolvm process, and the VM with it
const vm = spawn("smolvm", args, {
timeout: opts.timeoutMs ?? 10_000,
killSignal: "SIGKILL",
});
let stdout = "",
stderr = "";
vm.stdout.on("data", (b) => {
stdout += b.toString();
});
vm.stderr.on("data", (b) => {
stderr += b.toString();
});
vm.on("close", (code) => {
resolve({
stdout,
stderr,
exitCode: code ?? -1,
wallMs: Date.now() - started,
});
});
});
}Three pieces worth pointing out. The staging directory is mounted read-only, the VM cannot modify the host's copy of the code, even if it tries. The default network policy is deny-all: SmolVM gives the guest no network unless you pass --net, and --allow-host narrows egress to named hosts. The budget is hard: CPU and memory are capped at spawn with --cpus and --mem, and the orchestrator enforces wall-clock time by killing the smolvm process, which hosts the VMM, so the VM dies with it. Note that --allow-host example.com also allows its subdomains; use --allow-host-pattern when you want an exact host only. These three together are the minimum safe defaults. Shipping without any of them is the same mistake we wrote about in the n8n CVE-2026-21858 RCE chain: generated code running with too much trust, in the wrong place, with no kill switch.
This pattern composes naturally with the parallel-agent workflow we documented in our oh-my-codex worktree guide: one sandbox per worker, one VM per exec, one audit trail per invocation. It also slots cleanly into the zero-trust agent model we walked through in our analysis of Microsoft's ZT4AI framework: every tool invocation authenticated, scoped, sandboxed, and logged.
Production Gotchas We've Hit
A sandbox is not a product. The microVM is the isolation primitive, but the production operational surface has sharp edges.
Network Egress Is Where Most Teams Leak
Deny-all is the default you want, and it is the default almost nobody ships with. Teams allowlist *.pypi.org so the sandboxed code can pip install, and that allowlist becomes a DNS-exfiltration path because pip fetches arbitrary package names. The fix: pre-install dependencies into the VM image rather than allowlisting the package index. If the sandboxed code needs HTTP at runtime, allowlist specific API hostnames, not ecosystem registries.
Filesystem Mount Strategy Matters
Read-only code mounts are the easy part. Write scratch space is where the footguns live. If you give the VM a writable scratch mount on the host filesystem, you've reintroduced a side channel: agent A writes a payload file that agent B reads on the next invocation. Use an ephemeral tmpfs mount inside the VM for scratch (size-capped), and a separate, one-way write mount for the exec result. When the VM dies, the tmpfs dies with it.
GPU Passthrough Is a Reality Check
If your agent writes code that needs a local GPU, training, inference, CUDA, the microVM story gets much worse. SmolVM exposes the host GPU through virtio-gpu with Venus (Vulkan) on macOS and Linux and documents CUDA API remoting to an NVIDIA host, but neither is PCI passthrough, both depend on host driver stacks, and neither is available on Windows. In practice, keep GPU workloads outside the sandbox: run CPU-bound generated code inside SmolVM, and route model calls to a separate, authenticated inference service. For orgs that actually need sandboxed GPU compute, the answer is Firecracker on a Linux host with PCI passthrough, or bare-metal with strong auth, not a cross-platform microVM.
Cold Start Regresses with Image Size
The "under 200ms" number is the project's best case. A bigger image takes longer to prepare, and the first run of a registry image also pays for pulling it. Three options: ship multiple images (a Python sandbox, a Node sandbox, a "minimal" sandbox) and pick by task; prebuild one with smolvm pack create --image python:3.12-alpine so dependencies are baked in; or start a warm machine once and give each invocation a copy-on-write child with smolvm machine branch. Branching plays the role that snapshot-restored pools play for Firecracker at Lambda scale.
Observability Needs to Survive the VM's Death
When the VM dies, everything inside it dies. If your agent's debug output matters, capture it to a file on a one-way scratch mount before the VM exits, then read it from the host after. Do not try to stream logs over a VM-to-host socket under load, the data race on VM shutdown loses the last few hundred ms of output, which is exactly where the interesting failures happen. Once you have picked a runtime, the next question is capacity: where the boot time actually goes and what the per-VM memory really costs. That accounting is in Firecracker vs libkrun: boot time, memory, and sizing.
The Bottom Line: Match the Sandbox to the Risk
Running AI-generated code is a capability question and a trust question. The capability is easy, any container or VM can exec the code. The trust question is what the isolation boundary has to hold, and for code an agent wrote in response to a user-supplied prompt, the boundary has to hold against a hostile workload every time. Docker doesn't. gVisor mostly doesn't for syscall-heavy code. Firecracker and SmolVM do, and the choice between them is mostly about where you run and how often you cold-start.
Across the agent platforms we've shipped this pattern into, coding agents on developer laptops, multi-tenant SaaS agent platforms, and internal tools that execute model-generated SQL and Python, the recipe is the same every time: hardware-virtualized microVM per invocation, deny-all network with explicit allowlist, read-only code mount, hard budget, audit every exec. SmolVM made the developer-side of that recipe cheap enough that you can put it in dev, CI, and prod without a platform team rewriting the world. If you would rather not run the isolation layer yourself at all, managed AI code execution sandboxes like Modal, E2B, Daytona, and Vercel Sandbox cover the same threat model as a hosted service. For how the same isolation thinking applies to the rest of the AI-in-the-loop development stack, from IDE agents to CI/CD, start with the AI development tools pillar and our Cursor AI development best practices guide.
Three days of running a Claude Code instance through a microVM sandbox is worth more than a quarter of security-review meetings about "what if the agent writes something bad." Let the sandbox answer the question.
FAQ
Quick answers to the questions this post tends to raise.



