
benchbook
io.github.Jake-Network/benchbook
Shared ledger for agent swarms: workers record results by tool, and the lead reads a brief and SQL
Documentation
benchbook: a Postgres ledger for agent swarms
Subagents' results go to a database, not your lead agent's context, and their "done" is re-run before you trust it. On SWE-bench Verified, 7 of 39 completions Claude Code reported as done failed the benchmark's tests on re-run (17.9%).
benchbook re-runs the commit a subagent reports as done, in a clean worktree, before the report counts: on its own
with the Claude Code plugin, by benchbook check verify elsewhere. The experiments agents record and the check runs
and completions its hooks see go into one Postgres ledger, which the lead reads by SQL instead of from the subagents'
reports.
A lead agent that fans work out to dozens of subagents gets every result back as natural-language text. With enough workers those reports fill its context window, and what they said is lost at the next compaction or session. benchbook keeps a ledger beside your repository: each worker records its experiments, check runs and completions the moment they end and hands back only record ids, and the lead pulls what it needs from the ledger.
Start
uv tool install --python 3.13 benchbook # no Docker needed
benchbook install --no-cli --mcp # Claude Code plugins: the hooks, plus the MCP server and the worker agent
Keep --python 3.13: without it uv may pick a free-threaded Python, and the install stops at pixeltable-pgserver with
"no wheels with a free-threading compatible ABI tag".
A coding swarm. cd your-repo && benchbook init proposes your test and lint commands as checks. Then work as
usual; the one convention is that an implementer ends its report with DONE <sha>.
An experiment swarm. benchbook init --goal "Minimise validation loss" --metric val_loss --direction min, then in
Claude Code /benchbook-mcp:benchbook-lead Minimise val_loss of train.py; 3 rounds, 4 workers, and benchbook serve
to watch at http://127.0.0.1:7466.
What you get
- Results in the ledger, ids in the context. Workers record every run, failures included, and hand back a short summary with record ids. The lead reads a budgeted brief (best result, open work, what not to repeat) and queries details by SQL when it needs them.
- Nothing lost. Every evaluation a worker records, and every run of a declared check the hooks can read, is a row the moment it ends. A hook keeps a subagent's report even when the agent ignored the rules.
- Nothing repeated. The same experiment (config, code and seed) is refused, and a new seed counts as a replicate. A failed approach, in code implementation as in experiments, stays in the brief with its failure signature.
- Across sessions and compaction (experimental): a new or compacted session starts from the brief, not from what someone remembered.
- Results are checked before they are built on. An experiment result becomes the baseline only after other
agents replicate it, and a worker's
DONE <sha>is re-run on that commit in a clean worktree (coding work). These guarantees catch mistakes; on a shared database, per-agent tokens bind each write to its agent (honest limits).
Hooks never write to stderr and exit 0, except the completion gate, which exits 2 to keep a task open, and a worker's report with over 600 characters besides the ids of records it wrote, which the SubagentStop hook sends back once for a shorter rewrite; outside a benchbook project they do nothing.
Commands for the lead
benchbook brief --here # what the swarm has done on this branch, in a token budget
benchbook status # verified, undecided, reported only, mismatched; open findings; hook health
benchbook sql "SELECT ..." # anything else, read-only
benchbook get c:7f3a91c2 # one record in at most 400 tokens
The GitHub Action re-runs each piece a pull request completes. Codex, Cursor, Gemini CLI, OpenCode and Pi get the brief and the check recording (harnesses); a Python SDK and the CLI work without any harness.
Measured so far
- The lead's peak context is lower, and it reads less than half the report tokens. Circle packing at 8 and 16 workers: peak lead context was 40.2k against 47.9k and 58.5k against 88.0k with plain subagents; 7.0k and 14.1k report tokens reached the lead, against 15.7k and 32.0k. Wider swarms are not yet measured like for like ("Fan-in after the lead-context changes" in the results).
- About the same API cost as plain subagents. Circle packing at 8 workers, 3 runs each: USD 1.11 against 1.16 per run (0.96x, the ranges overlap), with each evaluation checked, run and recorded in one Bash call. Neither side lost a result, and the share of duplicate evaluations was similar (32.6% against 31.3%). benchbook made about twice the model calls, mostly cache reads ("A against C after one-call recording" in the results).
- Memory across restarts is not proven. In four one-trial pilots a lead reading the brief answered fewer state questions than one keeping progress files. No pilot reached compaction.
- Workers' "done" needs checking. On SWE-bench Verified, 7 of 39 completions Claude Code reported done failed the benchmark's tests on re-run (17.9%, 95% CI 9.0% to 32.7%).
Methods, every pilot and the raw reports: docs/results.md.
What it fits
- Coding work with a test suite, split across many agents or sessions, each piece ending at a commit the checks can judge.
- Experiments that are all three: A number per attempt (every attempt yields a metric), Re-runnable (the same config runs again with only the seed changed) and One space, explored together (several workers search it at once). On many GPUs: autoresearch.
Works with
- Your orchestrator. Claude Code, Codex, Cursor or your own loop runs and routes the agents; benchbook records what they did.
- Your tests and reviewers. A re-run checks exactly what your declared checks cover, so better checks give stronger evidence.
- Agent memory and tracing. mem0 or Letta remember for one agent, and benchbook is the shared record of a swarm;
records can carry a
trace_refto your observability tool.
Docs
Each page and when to read it:
- Concepts: how the ledger, briefs, claims and verification work, and the honest limits. Read this first.
- Coding work: pieces,
DONE <sha>re-runs and the false completion rate; start here for a coding swarm. In depth: re-runs, the brief, pieces and path occupancy, out-of-scope findings, CI evidence. - Claude Code: what each hook does in a session, installing the two plugins, the lead and worker loop.
- Other harnesses: what Codex, Cursor, Gemini CLI, OpenCode and Pi record, and how to install each.
- GitHub Action: re-run each piece a pull request completes and keep one summary comment on it.
- autoresearch on many GPUs: many autoresearch agents on one shared ledger; skills such as pi-autoresearch record into it too.
- Circle-packing demo: an experiment swarm on a CPU, scripted in one minute or with Claude Code.
- Results: every measurement with its method and raw reports.
- Schema and SQL: the tables and the read-only
v_*viewsbenchbook sqlreads. - Python SDK: the
LedgerAPI, for your own loop without a harness. - Several machines: one shared Postgres, the read-only role and per-agent tokens.
- Releasing: how a
v*tag becomes a PyPI release.
License: Apache-2.0.
benchbookpip install benchbook