
Show HN: Forked – Git for AI agent state
Your agent crashed after charging the card. You retried it. Nobody got
以下正文同步自 Hacker News 最新,版权归原站所有,已转换为易读排版。
Your agent crashed after charging the card. You retried it. Nobody got charged twice, because the effect log replayed the stored result instead of re-running the charge.
forked lets AI agents fork, rewind and replay their structured state (messages, memory, plans, tool results), with a side-effect log that keeps emails, payments and API calls effectively-once across retries and rewinds (recorded idempotency keys replay their stored result; strict when a session has a single writer at a time, as in forked cloud).
forked versions the agent's own structured state, not whole sandboxes: no file or process snapshots, just a persistent key→JSON map with git-like branches, commits and diffs, plus the effect log.
Use it three ways. Same API in all three, switch via baseUrl:
cargo run -p forked-server -- --db forked.db
or: docker build -f forked-server/Dockerfile -t forked-server . && docker run -p 8080:8080 forked-server
import { ForkedClient } from "@forked-run/client";
const forked = new ForkedClient({ baseUrl: "http://localhost:8080" }); const session = await forked.createSession(); const main = session.branch();
await main.put({ plan: ["draft", "review", "send"], step: 1 });
const alt = await main.fork("alternative"); // O(1), nothing is copied await alt.put({ step: 2 });
const history = await main.log(); await main.checkout(history[1].hash); // rewind, byte-exact
await session.recordEffect({ // replays stored result on retry key: "send-email:42", kind: "email.send", result: { messageId: "abc" }, });
Using LangGraph? @forked-run/langgraph is a drop-in checkpointer where time travel becomes a real branch rewind, see clients/langgraph.
State is a persistent, structurally shared tree (a HAMT): commits rewrite only the touched path, forks write a single ref, diffs skip identical subtrees by hash.
Everything is content-addressed (SHA-256, deterministic CBOR): the same state always has the same hash, on every backend.
Storage needs only blob put/get + one compare-and-swap on a ref, so backends range from an in-memory map to SQLite and Cloudflare Durable Objects.
Effect records live inside commits, so "commit + record effects" is atomic under that single CAS on every backend. Rewinds never undo an effect: replaying a recorded idempotency key returns the stored result.
Specs: docs/FORMAT.md (on-disk format), docs/API.md (HTTP API).
Path What it is
forked-core engine: persistent map, commits, fork/checkout, log, diff, effects, Storage trait. Compiles for wasm32-unknown-unknown.
forked-memory in-memory adapter (tests, local dev)
forked-sqlite SQLite adapter (bundled, zero system deps)
forked-api shared HTTP contract: DTOs + one dispatcher used by both servers
forked-server self-hostable axum server + Dockerfile
clients/ts @forked-run/client TypeScript SDK
clients/langgraph @forked-run/langgraph LangGraph checkpointer
clients/mcp @forked-run/mcp MCP server, gives any MCP agent (Claude Code, Cursor, …) checkpoint/rewind/effect tools
examples runnable use-case walkthroughs: safe retry (effectively-once effects), time-travel debugging, best-of-N exploration
Everything a single developer needs is and stays open source (Apache-2.0). forked cloud runs these same crates, its account/billing/console layer lives in a private repo, but it speaks the exact forked-api contract above, so nothing it does is behaviorally special.
Rust: engine, adapters, server
cargo test --workspace cargo clippy --workspace --all-targets -- -D warnings cargo build -p forked-core --target wasm32-unknown-unknown
TypeScript SDK + checkpointer
cd clients/ts && npm install && npm run check && npm run build cd clients/langgraph && npm install && npm run check
End-to-end smoke test + use-case examples
cargo run -p forked-server -- --db memory --addr 127.0.0.1:8099 & node clients/langgraph/examples/smoke.mjs cd examples && npm install && FORKED_URL=http://127.0.0.1:8099 npm run all
forked-core must keep building for wasm32-unknown-unknown: no threads, no OS I/O, no tokio, no Send bounds on storage futures, no panics in normal paths, forked cloud runs it inside Cloudflare Durable Objects.
正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。