Firstpass v0.9.2
How it worksProofDocsBenchmarksGitHub

Open source · Apache-2.0 · v0.9.2

Cheap until proven otherwise.

Firstpass sends every LLM request to the cheapest model first, runs your check on the real output, and escalates one rung only when that check fails. Every decision leaves a receipt anyone can re-verify.

A drop-in proxy for Anthropic- and OpenAI-compatible APIs. Leaving is one unset.

one requestenforce mode
One request through Firstpass The request opens on the cheapest model. Your gate checks the real output and it fails, so Firstpass escalates one rung to a bigger model. That output passes the gate and is served. The larger model above it is never called, and the decision is sealed into a hash-chained receipt. RUNG 0 · CHEAPEST haiku GATE FAILED test failed escalate one rung RUNG 1 sonnet GATE PASSED served rung 2 · opus — not called ◆ RECEIPT · SEALED rung 0 fail → rung 1 pass → served chain ok
Illustrative: what one gated decision looks like.

The problem

Model choice is a guess made before the answer exists.

Frontier prices for everyday work

Send everything to the biggest model and you pay top rate for requests a cheap model would have answered correctly.

Routers guess from the prompt

A classifier or price list picks a model before any output exists. When it guesses wrong, you find out in production.

No record of why

Either way, nothing explains why a request went where it did, or proves the answer was checked before it shipped.

How it works

Decide after the output exists, by checking it.

The question “is this good enough to serve?” can only be answered once there is an answer. So Firstpass gets one cheaply, then checks it.

  1. Cheapest model first

    Every request opens on the least expensive rung of the model ladder you configure. No classifier picks the model.

  2. Your gate checks the real output

    A gate is your definition of “good”: your test suite, a JSON schema, an LLM judge, or self-consistency across samples. A gate that errors abstains. It never passes by default.

    • tests / command
    • JSON schema
    • LLM judge
    • self-consistency
    • json-valid
    • non-empty
  3. Escalate only on failure

    Pass, and the answer is served. Fail, and Firstpass climbs exactly one rung and gates again. The expensive model is spent only when the cheap one is shown not to be enough.

receipt · example
{
  "prev_hash": "9f2c…a1b7",  // links to the decision before
  "attempts": [
    { "rung": 0, "model": "claude-haiku-4-5",
      "gates": [{ "gate_id": "tests", "verdict": "fail" }] },
    { "rung": 1, "model": "claude-sonnet-5",
      "gates": [{ "gate_id": "tests", "verdict": "pass" }] }
  ],
  "final": { "served_rung": 1 },
  "hash": "5c02…a91f"
}

Every decision is hash-chained. firstpass export writes the log; firstpass verify re-derives the chain on your own machine, with no proxy or database. Alter or reorder one record and it fails at that record. Receipts & audit →

Proof

Measured on real tasks, caveats attached.

Every number below links to the committed artifact that produced it, and comes with the conditions it was measured under.

Quality · MBPP, 974 real tasks

+15.2points

over always serving the cheap model, and 0 of 974 tasks made worse.

Gated escalation on a haiku → opus ladder, paired against always-cheap. 95% CI [+12.9, +17.5].

On this workload the gate runs asserts that are also shown in the prompt, so it is partly self-grading.

mbpp-policy-974-opus.txt →

Cost · MBPP, 974 real tasks

12–57%lower

cost per successful task than always using the top model.

12% with sonnet as the top rung, 57% with opus as the top rung.

Always-top still wins on raw success: by 1.5 points on the sonnet ladder and 2.3 points on the opus ladder.

sonnet ladder → · opus ladder →

Served failures · one live run

7.7%served wrong

against a ≤10% target at 95% confidence, earned on this run.

82%served from the cheap tier14.7%gate false-accept rate

One run on one dataset (MBPP). The bound is earned per run, not a universal promise. The gate’s false-accept rate is stated, not hidden.

mbpp-live-base.txt →

Agents · 500 SWE-bench Verified runs

71%lower cost

by choosing one model per workload on evidence: 374/500 resolved vs 384/500 for always-opus.

The difference in resolved tasks is not statistically significant. Per-request cascades did not beat always-top on agent runs, and we say so.

Public leaderboard trajectories, one recorded run per model, one scaffold.

agentic-real-runs.md →

More results, including what didn’t work: Benchmarks · all artifacts on GitHub.

It says no, too

Offered a cheaper model, it said no.

Add a challenger model to a route and Firstpass tests it on real traffic, graded by your own gates. A statistical test that stays valid however often you look ends in certified or halted. A halted challenger is stopped automatically. Adopting a certified one is a config change you make. It never switches models on its own.

We ran it live on real Anthropic calls, with haiku-4-5 challenging sonnet-5.

Halted

Stopped at pair 137.

MBPP · 974 pairs

Haiku costs 0.30× as much per request. Firstpass still proved it worse and stopped it, long before the run ended. It halts in 100 of 100 random orderings of the same pairs.

Undecided

Too close to call. So it didn’t.

APPS · 290 contest problems

Haiku is 0.09× the cost here, which is tempting. But 65.2% vs 60.7% is too near the margin to decide, and it stayed undecided in 194 of 200 random orderings. “Not yet” is the right answer.

Fixed

It caught three bugs in Firstpass.

found by the live run, fixed with tests

  • #244 The challenger was graded on “served”, not “passed”, which had falsely certified haiku.
  • #245 A halted challenger kept spending.
  • #246 A 120 s timeout dropped the 33 longest problems and manufactured a halt.
Real Anthropic calls, about $29.70 in total. In a replay of recorded paid calls, paired mode decided in about 3× fewer requests than live mode. The live run → Choose a model by proof →

Coding agents

Works with the agents you already run.

Claude Code, Codex and aider talk to Firstpass over the wire formats they already speak. Observe mode forwards byte-identical and writes receipts. Enforce mode gates tool calls, groups turns into sessions with no header, and keeps a session on one model.

Setup

One base URL.

Claude Code · Codex · aider

Claude Code: ANTHROPIC_BASE_URL or firstpass launch claude. Codex: firstpass launch codex, which sets OPENAI_BASE_URL. aider: --openai-api-base.

In observe mode the upstream’s retry-after, request-id and rate-limit headers are relayed so agents back off correctly, and count_tokens is passed through.

Enforce

Tool turns are gated, not misread.

built-in gate: tool-args-valid

A reply that only calls a tool is not “empty”. The tool-args-valid gate checks every call’s arguments against the request’s own schema and fails on a tool that was never declared.

Turns are grouped into sessions with no header (explicit header, agent session header, prompt_cache_key, then a salted prefix hash), so session promotion applies to these agents without config.

Measured

Don’t switch models mid-session.

500 real SWE-bench agent runs · $0 replay

Escalate-and-pin cost +$0.309 to +$0.316 per instance more than always-top at the same 384/500 resolved (haiku to opus). Per-session routing resolved 378/500. Choosing the model per workload was far cheaper (374/500 at $0.219 vs 384/500 at $0.754), but non-inferiority at 1 point was not shown.

Compatibility as measured, in observe mode against a fake upstream: Claude Code and aider completed a turn, Codex was covered by a fixture request only, and Gemini CLI is not supported. Coding agents guide → The granularity eval → The compatibility matrix →

Where it fits

Strongest where “correct” is checkable.

Verification needs something to verify against. We’d rather tell you now than after you deploy.

Great fit

Output you can check

Code with tests, structured output against a schema, extraction. The gate is crisp, so every escalation is earned.

Weaker fit

Open-ended prose

The available gates are an LLM judge or self-consistency. They work, but they are weaker checks than a test suite.

Wrong tool

Nothing to check

If your output has no check at all, Firstpass has nothing to decide on. Use something else.

Why now

Cheap models got good. Agents made the bill add up.

  • Many capable models, very different prices

    For a growing share of requests, a cheaper model gives an answer that passes. The hard part is knowing which requests.

  • Agents make thousands of calls

    An agent session is a long chain of requests. Small per-call choices compound into real spend and real failure rates.

  • Spend and correctness need a paper trail

    When a model decision affects cost or quality, someone will ask why. A re-derivable receipt is an answer you can hand over.

Get started

Running in a minute. Gone with one command.

It starts in observe mode: it watches your traffic and writes receipts, and changes nothing until you turn on enforcement.

1 · Install

Homebrew
brew install dshakes/tap/firstpass-proxy
PyPI
pip install firstpass
npm · not firstpass, an unrelated package
npm i -g firstpass-proxy
prebuilt binary · macOS, Linux
curl --proto '=https' --tlsv1.2 -LsSf \
  https://github.com/dshakes/firstpass/releases/latest/download/firstpass-proxy-installer.sh | sh
Docker
docker run -p 8080:8080 -e FIRSTPASS_BIND=0.0.0.0:8080 \
  ghcr.io/dshakes/firstpass:latest
crates.io · needs Rust
cargo install firstpass-proxy

Windows and other binaries: GitHub Releases.

2 · Route your agent through it

bash
# terminal 1: observe mode changes nothing
firstpass-proxy
# terminal 2: your agent now goes through it
export ANTHROPIC_BASE_URL=http://127.0.0.1:8080
# use your agent; read receipts at http://127.0.0.1:8080/panel

No lock-in. Offboarding is unset ANTHROPIC_BASE_URL. Your keys pass straight through to your provider.

Next: Quickstart · Write a gate · Configure a ladder

Stop guessing which model. Check.

Open source, Apache-2.0, written in Rust.