Skip to main content

copeca · cost per correct answer

Live site License: MIT Build

🌱 What is copeca? →  ·  the visual overview

A neutral, reproducible, verifiable benchmark for CLI-based coding agents.
Copeca measures cost per correct answer — the expected dollar cost before getting a right answer — to A/B-compare MCP servers, context compressors, hooks, and harness improvements against a clean baseline.

cost_per_correct = total_spend / correct_count

Why this metric. "-90% tokens removed!" is a marketing number if it ignores whether the answer was right. A tool that saves 90% of tokens but makes 20% more mistakes has worse cost-per-correct. Copeca adjusts every savings claim for accuracy, so the number you get is the number that actually matters.

Why a separate benchmark. Every tool in the ~45-tool agent-efficiency space reports savings on its own methodology against its own baseline — the numbers are literally incomparable. Copeca holds the agent and model fixed and varies one tool, answering "did my tool help, and what did it cost?" No existing benchmark occupies that lane.


Quick start

git clone https://github.com/jahala/copeca && cd copeca
pip install -e .
copeca init ./my-benchmark
copeca run --task scenarios/my-scenario.yaml --runner claude
copeca analyze results/bench.jsonl

A scenario file defines what to measure:

name: my-tool-vs-baseline
tasks:
  include: ["rg_*", "fastapi_*"]
modes: [baseline, my-tool]
models: [claude-sonnet-4-6]
model_runner_map:
  claude-sonnet-4-6: claude
repetitions: 5
budget_usd: 1.00

The report leads with the cost-per-correct delta between your tool and the baseline, with 95% bootstrapped confidence intervals, per-task and per-capability breakdowns (locate / trace / fix / debug — where the tool helps, not just an overall number), and adversarial flags that catch token snowballing and expensive failures.

Current corpus: 52 tasks across four real repos (ripgrep, gin, express, fastapi — Rust, Go, JavaScript, Python), each tagged by capability so the report shows where a tool helps. Broader coverage is on the roadmap; small N still means wide confidence intervals — see docs/known-limitations.md.


What copeca measures

Dimension How
Cost The vendor's billed cost when the runner reports it (the real bill — reflects cache TTL/tier/discounts; frozen into the artifact at run time). copeca also records a reproducible, provider-neutral cross-check: computed_cost_usd = Σ tokens × runner.pricing[model]. Token counts are read from the agent CLI and not re-tokenized — see known-limitations.
Correctness String matching (comprehension tasks) or test-command exit codes (edit tasks) (case-insensitive substring matching — gameable on single tasks; see known-limitations)
Completeness all_of field verifies the agent listed everything — not just something
Futility Adversarial flags: token snowball, talkative failure, tool storm, budget exhaustion, timeout
Integrity Each result is packaged with an integrity manifest — a SHA-256 hash of every file in the artifact. copeca verify ARTIFACT recomputes these to detect accidental corruption. The manifest alone is not tamper-proof: anyone who rewrites the zip can recompute it. For real tamper-evidence, sign artifacts with copeca run … --artifacts --sign-key <private.pem> — this writes a detached Ed25519 signature over the content hash, and copeca verify ARTIFACT --pubkey <public.pem> rejects any artifact a holder of the private key did not sign (so a tampered-and-recomputed artifact fails). Unsigned artifacts get corruption detection only and are reported as unsigned. External transparency-log anchoring is a further planned option.

Who copeca is for

Tool builders — MCP/server authors, context compressor developers, code-search tool maintainers. You ship a tool and need a number that isn't marketing. Copeca gives you cost-per-correct with a delta and CI, and a .copeca zip anyone can verify.

Platform builders — CLI agent authors (Codex, OpenCode, Gemini CLI style). You need to validate that your pricing model is accurate before customers depend on it. Copeca normalizes cost across providers and warns when pricing data is stale.

Skeptical evaluators — Researchers, reviewers, procurement leads. You've been burned by contaminated benchmarks and selectively reported results. Copeca's artifact model lets you verify any individual result; batch completeness verification (copeca verify --batch --scenario <path>) confirms all expected runs are present and names any specific missing runs.


How copeca works

Copeca launches a CLI coding agent as a subprocess against a real open-source repo pinned at a known commit. The agent answers a question or fixes a bug. Copeca parses the agent's output, checks correctness, computes cost from token counts, and writes a JSONL record. A scenario runs the matrix of tasks × modes × models × repetitions with parallel git-worktree-isolated workers.

Modes express the one variable that changes between baseline and experimental. They cover all five integration types real tools use:

Integration Mode field Example
MCP server mcp_config any MCP server
API proxy (env) env ANTHROPIC_BASE_URL proxy
Config-dir hook agent_config PreToolUse hook via settings overlay
Process wrapper wrapper ["your-wrapper-tool", "wrap"]
Pre-run index setup per-worktree indexing command

Copeca provisions each arm with its own config directory and an allow-listed environment. The baseline arm receives only a minimal set of host vars (infra, locale, and provider credentials); all ambient hooks, CLAUDE_* vars, and MCP_* vars are excluded. Experimental modes may declare additional vars via mode.env, which are merged on top.


Task corpus

Tasks are YAML data — no embedded code, no Docker per task. They target real open-source repos pinned at exact commits (per task, so one repo can serve several code states). The corpus is 52 tasks across ripgrep, gin, express, and fastapi — drawn from six public source families plus a set migrated from the tilth benchmark (MIT); each carries a source: field with provenance and a category (locate / trace / fix / debug). Tasks are tool-agnostic — they name the information required, never the method, so no tool is privileged; copeca validate lints for it. Every edit task is verified by copeca check-task: the test must pass on clean code and fail on mutated code, proving the mutation actually bites. See docs/task-taxonomy.md.

Contamination defense: copeca validate checks every task's source: field against a blocklist of known-contaminated source benchmarks (SWE-bench Verified, RepoBench, ClassEval, DevEval, CoderEval). A task from any of these sources is rejected before it can enter the corpus. This is a static provenance check — no model calls, no network. A planned authoring-time option (requires an API key) will also probe a live model with the task ID and exclude it if the model reproduces the gold solution from memory; that feature is not shipped yet.


Runners

The runner interface is config-driven: a runner is a YAML file in defaults/runners/ declaring the CLI binary, its argument mapping, its config-dir env var, and which output parser to use — plus a pricing table. Copeca builds the subprocess invocation from that YAML, so adding an agent CLI means writing a YAML, not editing copeca's code. See docs/runner-configuration.md.

To compute cost, copeca requires the minimum from the agent's output: token counts. From those it derives computed_cost_usd — a reproducible, provider-neutral cross-check; when the runner also reports its own billed cost, that vendor figure is the headline. Duration and completion are derived from the output too.

{"type": "turn", "input_tokens": 5000, "output_tokens": 200,
 "cache_creation_tokens": 3500, "cache_read_tokens": 3000}
{"type": "assistant_message", "text": "...", "turn": 2}
{"type": "result", "total_cost_usd": 0.0734, "duration_ms": 45230}

Two runners ship today: Claude Code (stream_json parser) and OpenAI Codex (codex_json parser) — each added as a YAML plus a parser, with no changes to copeca's core. A CLI with a different output format needs a matching parser, and a runner YAML naming an unbuilt parser fails loudly rather than silently miscounting.


Install

A built wheel bundles its runtime data (schemas/, tasks/, defaults/, and repos.yaml), so a pip install is fully functional — copeca init, validate, and run work off the packaged corpus. Copeca is not published on PyPI yet, so install from git or a source checkout:

pip install git+https://github.com/jahala/copeca

Or from a clone (use -e for development):

git clone https://github.com/jahala/copeca
cd copeca
pip install .

Requires Python ≥ 3.11. The Claude Code and Codex runners ship ready to use; the runner interface is config-driven, so other CLIs are added by writing a YAML (and, if their output format differs, a parser). See docs/runner-configuration.md.


Documentation


Support

"Buy Me A Coffee"

License

MIT — see LICENSE.

Copeca's bundled task corpus is derived from independent benchmark sources under permissive licenses (Apache-2.0, MIT, CC BY 4.0). Each task carries a source: field with provenance. Tasks from NonCommercial, ShareAlike, or no-license sources are explicitly excluded.


Copeca is part of the plotplot garden of small, sharp tools for building with AI. Siblings: tilth (AST-aware code intelligence), umbel (drive many agent CLIs from one session), pleach (conduct agent work in isolated worktrees), petals (brand intelligence), tend (feature mapping across sessions).

Metadata

Release files for copeca 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 copeca 0.1.0
File Size Uploaded
copeca-0.1.0.tar.gz 94.5 kB Details

Built distribution (wheel)

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

Total release size: 216.9 kB

Release files / copeca-0.1.0.tar.gz

Download URL copeca-0.1.0.tar.gz
Size 94.5 kB
Tags Source
SHA-256 checksum
How to use checksums
741349a625e6fb6a7b979dac9abd1dd072f1a18420215a563df4bafde1f65537
BLAKE2b-256 checksum
How to use checksums
b050b115a76cdb58067edb5f6283c38bf809bb15dcf0f8946b5a493986d500bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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 Jun 22, 2026.

Transparency log

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

Download URL copeca-0.1.0-py3-none-any.whl
Size 122.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4426cec3ca45f65c2a1cb4da0dd3c0bcbe6c220d4246a25f06e929b5357b66bc
BLAKE2b-256 checksum
How to use checksums
d2374efcd775b3ff218ba4105375b4fbf8ccd3063ab9efc68f4a4c945c37ce6d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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 Jun 22, 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