Skip to main content

benchbook: a Postgres ledger for agent swarms

PyPI Python License

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_ref to your observability tool.

Docs

Each page and when to read it:

License: Apache-2.0.

Metadata

Release files for benchbook 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for benchbook 0.1.1
File Size Uploaded Provenance Actions
benchbook-0.1.1.tar.gz 1.6 MB Without provenance Details for benchbook-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for benchbook 0.1.1
File Interpreter ABI Platform Actions
benchbook-0.1.1-py3-none-any.whl Python 3 none any Details for benchbook-0.1.1-py3-none-any.whl

Total release size: 2.1 MB

Release files / benchbook-0.1.1.tar.gz

Download URL benchbook-0.1.1.tar.gz
Size 1.6 MB
Tags Source
SHA-256 checksum
How to use checksums
e0797f2ad64e5045dd11b1b369a7d1dd0f4d5c8268c303d5503062402588e419
BLAKE2b-256 checksum
How to use checksums
ef084f615a69f635c890eab5713a82df41e9b2b71bd9ef2817d378b5d4f83d4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.13 {"installer":{"name":"uv","version":"0.13.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / benchbook-0.1.1-py3-none-any.whl

Download URL benchbook-0.1.1-py3-none-any.whl
Size 461.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a3cc1e7df139a058e29443559700afeee19f492d29a4f0b7151430171865cd4e
BLAKE2b-256 checksum
How to use checksums
5925baa806bcff612629b60c6ab755ba8edd28e0cd29ebbe410ec9d8a6067d04
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.13 {"installer":{"name":"uv","version":"0.13.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for benchbook 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page