Evaluating models

Can We Replace Claude Opus with Sonnet Without Losing Code Quality?

Claude Opus 5.5 costs $4 per million input tokens and $20 per million output tokens. Claude Sonnet 5.5 costs half that. If your coding agent runs all day, that difference is real money, so the question comes up quickly: can we switch to the cheaper model without the code getting worse?

This page builds a small, honest experiment that answers that question for your tasks instead of somebody else's leaderboard. The code lives in the model-switch-lab/ folder of the AI Spaceship repository.

Status: no results yet

The experiment is built and has been validated end to end at zero cost. The paid runs against real Opus and Sonnet have not been run yet, so this page reports no results. Every number below is a price from Anthropic's pricing page, not a measurement.

Why not just read a leaderboard?

Public benchmarks are useful, but they answer a different question. They measure a model on their tasks, with their agent, prompts and scoring. Your decision depends on:

  • Your tasks. A model that's slightly behind on average can be fine on your codebase, or much worse on the one thing you care about.
  • Your harness. The agent, its tools, the effort setting and the limits all change the outcome.
  • Your bar. "Passes 92% of tasks" doesn't tell you whether the 8% includes a security fix you can't afford to get wrong.

So we build a tiny benchmark that mirrors the decision we actually face.

The experiment in one picture

flowchart LR
    T[Task snapshot] --> A[Agent container<br/>workspace, no network]
    I[Inspect AI on host<br/>react agent] -->|tool calls via docker exec| A
    I <--> M[Opus, Sonnet or any model]
    A -->|source files, after the agent stops| G[Grader container]
    H[Hidden tests] --> G
    G --> L[Inspect log]
    L --> C[compare.py: gate + report]

That is Mermaid source; it renders as a diagram on GitHub. Each run gets two fresh containers with no network. The agent works in one. Our grader copies the agent's source files into the other, adds tests the agent never saw, and runs pytest. The API key never enters either container: the agent loop and every model call run on the host, and only the agent's tool commands run in the container, through docker exec.

See it working

How the lab's harness works steps through one run interactively, from the spend guard to the gate, and replays a recorded run.

Step 1: a small benchmark you can trust

We wrote three original tasks, small enough to read in a few minutes:

TaskWhat the agent must do
bug-fixFix wrong cart totals. The symptom is in cart.py, the causes are in money.py and discounts.py.
api-featureAdd filtering, pagination and a checkout endpoint to a FastAPI app, with exact status codes.
multi-file-featureAdd a text report across three modules, export it, and write at least three tests.

Each task has four parts:

  1. repo/: the starting code, with a few visible tests.
  2. prompt.md: the requirements, written like a ticket.
  3. hidden_tests/: 10 to 12 tests the agent never sees.
  4. solution/: a known-correct reference solution.

Before trusting a grader, test the grader. The validate task runs with no model at all:

uv run inspect eval eval.py@validate -T solution=false --model mockllm/model
uv run inspect eval eval.py@validate -T solution=true --epochs 5 --model mockllm/model

The starting code must fail the hidden tests, and the reference solution must pass all of them on five consecutive runs, each in fresh containers. Both checks pass today. One detail they caught: the unfinished multi-file-feature code doesn't even import, so pytest reports one error instead of ten failures. The grader therefore also checks that the expected number of tests ran.

Step 2: why hidden tests beat "which output looks better?"

You could show both models' code to a reviewer, or to another model, and ask which is better. That's slow, subjective, and easy to sway with confident prose. Hidden tests are:

  • Deterministic. The same code always gets the same verdict.
  • Specific. "limit=51 must return 422" is either true or not.
  • Out of reach. The agent can't read or edit them. Editing the visible tests is recorded in the log and doesn't change the score.

An LLM judge can still help later, for readability for example. It is never the primary measure of correctness here.

Step 3: hold everything constant except the model

Experiment A runs the same agent on the same snapshot with two models. We don't write our own agent loop: Inspect AI's built-in react() agent calls tools until the model submits an answer, and Inspect also handles orchestration, logs, limits and cost.

Why not a vendor's coding agent, such as Claude Code? Its prompts and tools are tuned for its own models, so any other model starts at a disadvantage. Inspect's agent is model-neutral, so the same commands work for DeepSeek, OpenAI or any other provider Inspect supports. We pin everything that could quietly differ:

Held constantHow
AgentInspect's react(), pinned with inspect-ai
ToolsExactly bash and text_editor; no web tools
Efforteffort=high for both. Their API defaults differ (Opus 5.5 medium, Sonnet 5.5 high), so leaving it unset would compare defaults, not models.
Starting stateThe workspace is checked against the snapshot's SHA-256 before every run
Model routingThe report checks that every call was served by the requested model, not a substitute.
uv run inspect eval eval.py@solve --model anthropic/claude-opus-5-5   $PAID --log-dir logs/a-opus
uv run inspect eval eval.py@solve --model anthropic/claude-sonnet-5-5 $PAID --log-dir logs/a-sonnet

Add --epochs 3 to repeat each task three times. Models are not deterministic and there is no seed, so repetition is the only way to see variability.

Step 4: the plan-artifact handoff

A common cost-saving pattern is to let the expensive model think and the cheaper model type. Experiment B tests exactly that, in a controlled way:

  1. Opus plans. It gets the requirements and a read-only tool set: one read_file tool, no shell and no editor. The grader confirms afterwards that the workspace is byte-for-byte unchanged.
  2. The plan is saved once. compare.py plans writes the plan text with its SHA-256 and the snapshot hash it was made for.
  3. Two branches fork from that one file. The control is Opus plan → Opus implementation; the candidate is the same Opus plan → Sonnet implementation. The plan is never regenerated per branch, because the planner's own randomness would then leak into the comparison.
uv run inspect eval eval.py@plan --model anthropic/claude-opus-5-5 $PAID --log-dir logs/b-plan
uv run python compare.py plans logs/b-plan/*.eval -o plans/plans.json
uv run inspect eval eval.py@solve -T plans=plans/plans.json --model anthropic/claude-opus-5-5   $PAID --log-dir logs/b-opus
uv run inspect eval eval.py@solve -T plans=plans/plans.json --model anthropic/claude-sonnet-5-5 $PAID --log-dir logs/b-sonnet

What this is not

This is a plan-artifact handoff: a written plan passed between two separate runs. It is not a mid-conversation model switch. The second model doesn't see the first model's conversation or reasoning. Inspect does have native checkpointing, but it doesn't document resuming a session with a different model, so true session switching is left for a future experiment.

Step 5: compare correctness, cost and latency

compare.py report reads Inspect's logs and produces a Markdown report:

  • Correctness: hidden tests passed, per task and per run.
  • Cost: Inspect multiplies each call's token usage, including cache reads and writes, by prices.yaml. The price file records its source and retrieval date. For the handoff, workflow cost = the shared plan cost + the implementation cost.
  • Latency: wall-clock time per run.
  • Failures, kept separate: refusals, truncated responses, limits hit and infrastructure errors are never counted as success, and never confused with "the model wrote wrong code".

Cost is reported as not measured whenever it can't be computed. It is never filled in with zero.

Step 6: a quality gate, decided before the results

The gate is a few lines of deterministic Python. It answers: does the Sonnet workflow meet our predeclared criteria relative to the Opus control?

VerdictMeaning
PASSSonnet's success rate is no worse than allowed on every task, with no extra critical failures
FAILIt falls below a threshold or has more critical failures
INCONCLUSIVEMissing runs, infrastructure errors, or a model-routing mismatch

The thresholds live in gate.json, committed before the paid runs, so nobody can tune them after seeing the answer. The defaults are strict: no drop in success rate and no extra critical failures. Cost is not an input. A cheaper model that fails tests doesn't pass, and a missing cost figure doesn't block a pass.

Step 7: spend control

Nothing paid runs by accident:

  • Real models are refused unless MODEL_SWITCH_LAB_ALLOW_PAID=1 is set.
  • Every paid run needs -T budget_usd=.... Inspect enforces it as a per-run cost limit and refuses to start without prices.yaml.
  • The worst-case total is budget_usd × runs. One repetition of both experiments is 15 runs, so $45 at budget_usd=3. That's a ceiling, not an estimate.
export MODEL_SWITCH_LAB_ALLOW_PAID=1
PAID="--model-cost-config prices.yaml -T budget_usd=3 -T effort=high"

Comparing other model families

Nothing in the agent is specific to Claude, so you can swap in another provider, for example --model deepseek/deepseek-v4-pro. Before a paid run:

  • Add the model's prices to prices.yaml from the provider's pricing page. Paid runs are refused without them.
  • Use a current model name. A retired name served by its replacement shows up in the served-model check and makes the result INCONCLUSIVE.
  • Remember that effort levels aren't calibrated across families: high on one provider isn't the same amount of thinking as high on another.

Results

Pending. The paid runs haven't been executed. When they are, this section will show the generated report. Until then, the only verified claims are about the harness itself: the graders work, the sandbox is isolated, and the handoff branches share one saved plan. All of that was checked with Inspect's mock model at zero cost.

Limitations

  • Tiny sample. Three tasks can reveal a regression. They can't prove that two models are equivalent.
  • Nondeterminism. Expect run-to-run variation. Read the variability section before drawing conclusions.
  • Framework effects. The results describe Inspect's react() agent at one version, with these tools, this effort level and these limits. A different harness can give a different answer.
  • Plan handoff ≠ session switching. See above.
  • The gate is illustrative. It is a teaching device, not a production deployment decision, and never a reason to switch on cost alone.

Reproduce it

# from a checkout of the AI Spaceship repository
cd model-switch-lab
uv sync
uv run pytest -q       # zero cost: offline tests + Docker tests with a mock model

Then follow the paid-run commands in the project's README.md, after you've decided on a budget.

Previous
Wrap-up