Skip to main content

CompactBench

Open benchmark for AI conversation compaction methods.

PyPI version Python License CI

CompactBench measures whether language models still behave correctly after long conversation history is replaced with a compacted representation. It runs adversarial, deterministic, multi-cycle benchmarks and publishes ranked results on a public leaderboard.

  • Deterministic generation — same template + seed + version always yields the same case
  • Hidden ranked set — public practice cases for development, hidden templates for ranked scoring
  • Multi-cycle drift — methods are evaluated across repeated compact → continue → compact loops
  • State-fidelity scoring — correctness of retained decisions, constraints, and entities, not output style
  • Versioned everywhere — benchmark suite, template, scorer, model, and method versions are recorded with every result

Install

pip install compactbench

Or with uv (recommended for development):

uv pip install compactbench

Quickstart

Run a built-in compactor against the starter suite using a local Ollama model:

compactbench run \
  --method built-in:hybrid-ledger \
  --suite starter \
  --provider ollama \
  --model llama3.2

Generate a single case deterministically for inspection:

compactbench generate --template buried_constraint_v1 --seed 42

Score an existing results file:

compactbench score --results results.jsonl

Writing your own compactor

Implement the Compactor interface and register it.

from compactbench.compactors import Compactor
from compactbench.contracts import CompactionArtifact, Transcript

class MyCompactor(Compactor):
    name = "my-method"
    version = "0.1.0"

    def compact(self, transcript: Transcript, config: dict) -> CompactionArtifact:
        ...

Then run:

compactbench run --method path/to/my_compactor.py:MyCompactor --suite elite_practice

See docs/writing-a-compactor.md for full details.

Leaderboard

The public leaderboard is at https://compactbench.github.io/compactbench/leaderboard.

Submissions are evaluated against hidden ranked benchmark cases by a maintainer-operated runner. To submit:

  1. Write and test your compactor locally against elite_practice.
  2. Open a PR to submissions/ with your method source and config.
  3. A maintainer runs it against the hidden set and merges if it qualifies.

See docs/submitting.md for the full submission protocol.

Project status

v0.1.0 launch-ready. All ten workorders from the implementation roadmap have landed:

  • Core: DSL parser, case generation, scoring engine, mock + real providers (Groq / Google AI Studio / Ollama)
  • Methods: four built-in compactors (naive-summary, structured-state, hierarchical-summary, hybrid-ledger)
  • Runtime: end-to-end compactbench run with drift cycles, JSONL event log, --resume
  • Leaderboard: PR-based submission workflow on GitHub-hosted runners, static site fed by a qualification + ranking core
  • Content: 15 public Elite practice templates + 15 hidden ranked templates across three launch families
  • Release: PyPI trusted-publishing workflow wired up; tag v0.1.0 to ship

See CHANGELOG.md for the full breakdown. Post-launch work (hidden-set content expansion, additional template families, shadow evaluation automation, custom domain) is tracked via GitHub issues.

Contributing

Bug reports, template proposals, and new compactors are welcome. See CONTRIBUTING.md.

Please also read our Code of Conduct.

License

Apache License 2.0 — see LICENSE.

Metadata

Release files for compactbench 0.1.0

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

Source distribution (sdist)

Source distribution for compactbench 0.1.0
File Size Uploaded
compactbench-0.1.0.tar.gz 58.9 kB Details

Built distribution (wheel)

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

Total release size: 129.7 kB

Release files / compactbench-0.1.0.tar.gz

Download URL compactbench-0.1.0.tar.gz
Size 58.9 kB
Tags Source
SHA-256 checksum
How to use checksums
5476f7a422a6e0d9b1b88b045e756eac49942470891742de4a99369e284903b3
BLAKE2b-256 checksum
How to use checksums
5b8e46a4656838c6afd32642cdb1df2bc4f856c1625e1e8bd15c08bf2e314aec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 17, 2026.

Transparency log

Release files / compactbench-0.1.0-py3-none-any.whl

Download URL compactbench-0.1.0-py3-none-any.whl
Size 70.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
08a8f6d36b8e4da75f8dbfdb118c897ea1e29175c522cb55c2027d56d5e5eb9c
BLAKE2b-256 checksum
How to use checksums
da242e99c0ff8c2f53946075b86072e8e4aeda2220c4ec5afca13560bef33ea2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 17, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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