fork() for AI agents — snapshot, branch, and merge live agent state.
Project description
ProcessFork
fork()for AI agents. Snapshot a live agent — model fast-weights, KV-cache, sandbox filesystem, tool-effect ledger, and reasoning trace — into one content-addressed image. Branch it. Merge it. Push it. Replay it.
The 60-second demo
# 1. Snapshot a live agent state
$ pf snapshot --agent-id claude-code --fs-root .
sha256:1c2497b0dc23d21b8068b26f54c0d8b14b7fdf704c11a456dca7e36eaf6fbed6
⋮ 8 ms
# 2. Fork into 12 divergent branches
$ pf fork sha256:1c24… -n 12 --explore "fix the type error"
sha256:3ca3a0ff…
sha256:67711987… ⋮ 12 lines, ~10 ms each (CoW; manifest-level)
sha256:2db9ff46…
# 3. After exploring, merge the winner back
$ pf merge sha256:842640c0… --into sha256:1c24…
ancestor : sha256:1c24…
trace : clean (47 chars summary; ~12 re-prefill tokens)
world : clean (1 clean paths; 0 conflicts)
effects : merged blob = sha256:52e0c81c…
model : applied TIES + DARE
merged : sha256:a41afac1…
# 4. Ship to a registry; teammate clones on a different machine
$ pf push sha256:a41afac1… file:///mnt/registry # or hf:// / s3:// / oci://
$ pf --store /other/store clone file:///mnt/registry --into /tmp/restored
sha256:a41afac1…
✓ restored to /tmp/restored
This entire transcript runs end-to-end on a laptop today (no GPU
required). Run it: bash examples/02-cli-snapshot/run.sh.
What that buys you
| capability | enabled by |
|---|---|
| Try N alternative approaches in parallel | pf fork <CID> -n N |
| Restart from a known-good state | pf checkout <CID> |
| Time-travel debug a stuck agent | pf log + pf checkout |
| Hand a live session to a teammate | pf push hf://you/session-2026-… |
| Atomically merge two divergent threads | pf merge B --into A |
| Idempotent rollouts (RL fabric) | content-addressed CoW across forks |
The four layers
| Layer | What it captures |
|---|---|
| Model | LoRA / IA³ / full-finetune weight diffs, In-Place TTT |
| Cache | Paged KV-cache, content-addressed, copy-on-write |
| World | FS (overlayfs / APFS clones), env, in-flight subprocs |
| Effects | Append-only ledger of irreversible tool calls |
Plus the reasoning trace for typed, effect-aware three-way merge.
See docs/ for the architecture
deep-dive.
Install
cargo install processfork # Rust CLI
pip install processfork # Python SDK
npm install @processfork/sdk # TypeScript SDK
(Operator-side until v1.0.0 publishes; build-from-source instructions
live in docs/src/install.md.)
Hello, fork (Python)
import processfork as pf
store = pf.PfStore.open("~/.processfork")
cid = pf.snapshot_filesystem(
store,
agent_kind="claude-code",
fs_root="/tmp/sandbox",
env={"PWD": "/tmp/sandbox"},
messages=[{"role": "user", "content": "go"}],
)
report = pf.merge(store, cid, cid) # idempotent self-merge → "clean"
print(report["overall"])
Repository layout
crates/ Rust workspace (pf-core, pf-cache, pf-world, …, pf-cli, pf-py, pf-ts)
adapters/ 7 per-framework integration packages (Claude Code, LangGraph, vLLM, …)
benchmarks/ PFBench harness + Criterion microbenches
docs/ mdBook source
examples/ 8 self-contained runnable examples
landing/ GitHub Pages site
demo/ 60-second demo recording scripts
agent_docs/ Subsystem specifications (the engineering source of truth)
.claude/ Sub-agents, skills, hooks for the build agent
Tests
200+ tests pass on macOS arm64 (latest tag: phase-10-complete):
| surface | tests |
|---|---|
| Rust workspace | 154 unit + integration + doc |
| Python SDK smoke | 5 (pyo3 + maturin wheel) |
| TypeScript SDK smoke | 5 (napi-rs + node --test) |
| Adapter smoke | 36 (3 fully wired + 4 scaffolded) |
| GPU-gated skips | 2 (vLLM, SGLang bit-exact) |
Latest microbench (build host, no GPU): snapshot_synthetic_4layer = 7.9 ms against the 500 ms budget — ~63× headroom.
Building from source
cargo check --workspace
cargo test --workspace
Status
v1.0 is feature-complete on this build host. Operator-supplied
deliverables (PyPI / npm / crates.io publishes, real-hardware GPU
bit-exact replay, live HF / S3 push) are tracked in
agent_docs/release-checklist.md.
What's deferred to v1.0.1 / v1.1 (vLLM live FFI, cosign keyless,
browser DOM capture) is documented in each adapter's README.
License
MIT. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file processfork-1.0.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: processfork-1.0.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 994.5 kB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
408a211de9fd6db230b0398df8bcb3acedec7196d33d77f7b468d165f051fba8
|
|
| MD5 |
a9ed21eb63972e45ae453c6acec50a1b
|
|
| BLAKE2b-256 |
c9e4df556ebb7ac4fd5f06e7b35b3fb01bdfc8608adb073a12e94d395a1fafcc
|
File details
Details for the file processfork-1.0.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: processfork-1.0.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 938.0 kB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
051f1e05e339f470d0c394a110b7aed3afe9aee5d2dfe95fd00ba82e67c8427f
|
|
| MD5 |
3344c513cbbdf8cb606ffd0d4c3b231e
|
|
| BLAKE2b-256 |
f9e8f876b4872761143c560ddac0aecfc12e8e3cdcba79e2830641dd12fc7cef
|
File details
Details for the file processfork-1.0.0-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: processfork-1.0.0-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 804.9 kB
- Tags: CPython 3.9+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f55bc54c9fd6f4b5d8f53f990b312ac691ef28368c3098f3bb81518c5d30746
|
|
| MD5 |
df3ba7d2be242abbff56f8e779025b54
|
|
| BLAKE2b-256 |
525cb7ff0cbe660acbcf5d2ed3c6015a4e2bc719f4403c124f5d86f8cb89dc75
|