forkd

Active
GitHub Rust Apache-2.0

Description

Firecracker-based microVM sandbox runtime designed for AI agent fan-out execution, supporting spawning 100 child sandboxes in ~100 ms with KVM isolation and memory snapshot copy-on-write.

Key Features

  • Millisecond fork — 100 microVMs spawned in ~101 ms, single BRANCH in 56 ms, 100x faster than cold boot
  • KVM hardware isolation — Hardware-level memory isolation based on Firecracker, each child is an independent VM
  • Snapshot copy-on-write — Parent VM boots once and snapshots to disk, children share parent memory pages via MAP_PRIVATE
  • Live BRANCH — Supports pausing, snapshotting, and resuming running sandboxes to fork mid-execution
  • Complete SDK family — Python/TypeScript/MCP SDKs and REST API interfaces
  • Per-child network namespace — Independent network stack per sandbox via per-child-netns

Use Cases

💡 Provide large-scale parallel sandbox execution for AI agent batch tasks
💡 Branch multiple subtasks mid-execution for concurrent processing
💡 Isolate tool calls between different agents to prevent cross-contamination
💡 Reduce repeated runtime initialization overhead in AI workflows
💡 Provide lightweight isolated test environments for CI/CD pipelines

Quick Start

# Install
pip install forkd
# Start forkd daemon (requires Linux ≥ 5.7, KVM, userfaultfd enabled)
sudo forkd daemon --enable-kvm
# Use Python SDK
python3 -c "
from forkd import Controller
c = Controller()
parent = c.spawn_sandboxes('pyagent', n=1, live_fork=True)[0]
branch = c.branch_sandbox(parent['id'], mode='live', wait=False)
print('Branch created:', branch)
"

Related Projects