deeplethe/forkd
Fork() for AI agent microVMs. Spawn 100 children in ~100ms from a warm parent; BRANCH a live VM in ~150ms. KVM-isolated, snapshot CoW.
What it solves
forkd is a microVM sandbox runtime designed for AI agent fan-out. It eliminates the high cost of cold-booting VMs or containers when spawning many short-lived sandboxes for tasks like code interpretation, tool-use, or evaluation rollouts. By allowing children to fork from a warmed parent snapshot, it removes the need to repeatedly import heavy ML libraries (like NumPy or PyTorch) for every new request.
How it works
Built on Firecracker, forkd uses a "fork-from-warm" approach. A parent VM boots once and loads the necessary runtime (e.g., Python and dependencies). This state is paused and snapshotted to disk. When new sandboxes are needed, forkd spawns child microVMs that mmap the parent's memory image using MAP_PRIVATE. This leverages the Linux kernel's copy-on-write (CoW) mechanism, meaning children share the parent's resident memory until they diverge, allowing for near-instant spawn times.
It also supports a BRANCH operation, which allows a running sandbox to be snapshotted mid-execution (mid-thought) and resumed, enabling agents to fork their state and explore different paths in parallel.
Who it’s for
- AI Agent Developers: Those building code interpreters or Jupyter-kernel sandboxes where each turn requires a fresh, isolated environment.
- ML Evaluation Harnesses: Users running hundreds of parallel test rollouts (e.g., SWE-bench) without the overhead of Docker cold-starts.
- Security-conscious Developers: Those needing KVM-level hardware isolation for untrusted code execution in CI or per-user environments.
- Self-hosters: Developers seeking an open-source, Apache 2.0 alternative to managed sandbox SaaS providers.
Highlights
- Extreme Spawn Speed: Can fork 100 microVMs in approximately 101 ms.
- Hardware Isolation: Each child is a separate Firecracker microVM backed by KVM, providing stronger isolation than standard containers.
- Live Branching: Ability to snapshot and resume a running VM in as little as 56 ms (p50), allowing agents to fork mid-execution.
- Diff-Snapshot Chains: Supports stacking snapshots (e.g., base $\rightarrow$ numpy $\rightarrow$ pandas) to save disk space and avoid duplicating base images.
- Full Linux Environment: Unlike some function-level runtimes, children are real Linux VMs with multi-vCPU support and full TCP networking.