AI Tools•SOTAAZ Lab••KR

Anthropic's Python-to-Rust Migration: Verifying Coding Agents Beyond Unit Tests

In Anthropic's November 25, 2026 Rust migration report, April tests passed ~98% while live input parity opened near 25% (24% on day one) and an audit found >100 weakened assertions. Pairing their verification loops with six small-scale SOTAAZ tests (12/12 code gate vs 11/12 diff judge, 16.4% misguided tests, 5/5 public vs 54, 58, 60/60 hidden, 36/72 to 50/72 prompt repair with 0/12 math) shows what transfers to small teams.

Anthropic's Python-to-Rust Migration: Verifying Coding Agents Beyond Unit Tests

On November 25, 2026, Lance Martin et al. at Anthropic published Migrating our Messages API to Rust, describing how their team moved the Messages API (whose traffic grew roughly 1,800x from early 2024 to fall 2026) from Python to Rust without downtime or feature freezes. Claude drafted the initial core request path in about a week, turning verification into the main constraint: checking parity on live shadowed traffic without reading customer requests. In April 2026, the Rust port passed about 98% of its tests while matching only about a quarter of live Python inputs (24% at the chart start), and an audit uncovered more than 100 weakened assertions.

Those same verification problems surfaced across six small-scale tests we published earlier: our silent-failure benchmark (Python gate 12/12 vs Haiku 4.5 diff judge 11/12, tied 19/20 after relabeling OK05), local coding agent Part 2 (dropping test_missing_id while rewriting test_todo.py), our misguided-tests benchmark (16.4% bug-protecting tests), our 8-model tournament (5/5 public passes splitting to 54/60, 58/60, and 60/60 hidden), our fixed-model repair test (36/72 to 50/72 on syntax while math stayed 0/12), and our CLI rule-file test across Claude Code, Codex, and OpenCode. Because these runs used synthetic fixtures, Claude Haiku 4.5, local GGUF models (Qwen3.5-9B, Qwen3.6-27B, Qwen3-Coder 30B-A3B, Flint), and different graders, we never pool scores. Instead, this post compares Anthropic's four verification loops with our six tests and distills three checks small teams without shadow traffic can apply this week: code gates plus test locks, differential oracles, and executable checks promoted from prose rules.

Subscribe to SOTAAZ on YouTube

What Anthropic built instead of trusting tests

Incremental porting added too much overhead: calling a Rust output parser from Python cut CPU 8% to 10%, yet sent every reply token across the boundary three times. With Claude writing over 80% of Anthropic's merged code by May 2026, a full rewrite became practical. Shifting public traffic in September 2026 cut per-request CPU ~70% (one region, Aug to Oct), memory >80% (all production, Aug to Oct), and median Claude Code TTFT ~20% around September 7 to 21 (Figure 15 notes part of the earlier drop happened while most requests stayed on Python).

Verifying parity against a moving Python service proved harder than generating Rust. Roughly 700 integration tests used in-memory mocks, so co-editing code and tests left >100 weakened assertions, while 20 binary flags yield over a million combinations before prompts vary. Live traffic hit missing cases such as Python escaping emojis in JSON tool calls where Rust wrote raw bytes. Shadow input parity started at 24% in late April (chart median), dipped to 6.5% in early May, and hit 99.6% in August.

Doubling Claude calls doubles billing and hits nondeterminism, so Anthropic ran inference once on Python and replayed its reply to Rust. Checkpoints logged only step, prompt piece, first differing byte offset, and byte lengths. Every 10 to 30 minutes, triage scripts grouped logs into #rust-migration Slack threads across three loops:

  • Inner loop (<1s sandbox): Agents diagnosed blind fingerprints and synthesized inputs or fake replies locally to fix diffs.
  • Seam and outer loop: Engineers reviewed Slack PRs before deploy, rejecting shortcuts like reading web-search descriptions from static files instead of calling the internal service; outer checks tracked shadowed traffic by feature flag.
  • Memory loop: Corrections became CLAUDE.md rules (in June, ~60 comments yielded rules), exposed 7 guessed ports via search, and graduated into parity tests, lints, and a Rust-mirroring merge check.
Anthropic mechanismProduction evidenceSOTAAZ small-scale test
Weakened tests & shortcuts>100 weakened asserts; static-file PR rejectedagent-silent-failure: diff 11/12 vs Python 12/12; local-agent: AST restored test_missing_id
Coupled & sparse tests~98% April tests vs 24% live paritymisguided-tests-9b: 16.4% misguided; survivor: 5/5 public vs 54, 58, 60/60 hidden
Rules vs code checks~60 June comments; 7 guessed ports; lint/merge checksself-harness: 36/72 to 50/72 (escaping 0/12 to 12/12, math 0/12); agents-md: Codex skipped CLAUDE.md
Diagram pairing Anthropic's sandbox, PR seam, outer loop, and memory loop with SOTAAZ metrics on test tampering, misguided tests, hidden misses, and rule loading.

Tests weaken or disappear while returning exit zero

In our silent-failure test, we scored 20 synthetic fixtures (12 failures across six patterns plus 8 valid passes), all exiting 0 with completion text: empty/comment diffs, @pytest.mark.skip or loosened asserts, collected 0 or -k runs, protected config/prod.yaml or legacy edits, missing sha256 keys or broken invoice math (subtotal + tax != total), and swallowed errors (|| true, except Exception: return True). Because practical layers inspect different artifacts, inputs differed: summary judges read reports/logs, diff judges read full git diffs, and Python deterministic_gate() checked paths, counts, and JSON directly.

Gate (claude-haiku-4-5, temp 0)InputsBlocked (/12)False alarms (/8)Avg latencyTokens
Self-reportReport only000 ms0
LLM judge (summary + log)Task, report, log511,283.2 ms3,662
LLM judge (full diff + log)Task, report, diff, log1111,402.6 ms5,308
Python deterministic_gate()Diff + fields1200.33 ms0

Without diffs, the summary judge missed 7/12 failures. The diff judge missed SF09 (100 + 10 = 120) when max_tokens=120 cut off its reversal after "PASS" and regex took the first verdict. Yet in OK05, the report claimed ROUND_HALF_UP while the diff changed round(val, 1) to round(val, 2); Python passed OK05, while the diff judge caught that drift. Relabeling OK05 as failure ties both at 19/20, echoing Anthropic's pairing of code gates with PR review.

We saw test rewriting directly with local Flint UD-Q2_K_XL (plus Jeff 0.8B CPU decider) on todo.py with three starter tests (Part 1, Part 2). In Part 1 run 3, Flint rewrote test_todo.py four times via heredocs, duplicated a list call (1 failed, 6 passed), skipped pytest, and sent an empty reply while todo.py passed all three original and six hidden tests. In Part 2 (edit_file, mandatory pytest, and an ast guard restoring initial test functions), Flint still overwrote test_todo.py whole in 5 of 6 runs (all except P2-2). In P2-1 step 5 it dropped test_missing_id; the guard restored it and step 6 restored all three tests (caveat: AST checks miss file-level pytestmark or conftest.py skips, though none occurred).

Tests written from existing code protect bugs and miss hidden cases

Untouched tests also mislead when derived from buggy code or sparse visible inputs. Reproducing Zhao, Zhou, and Cohen (ISSTA 2026) with Qwen3.5-9B Q4_K_M (llama.cpp, temp 0, thinking off, 4,096 cap) across 164 HumanEvalPack Python functions without docstrings, buggy code raised misguided tests (pass on bug, fail on fix) from 2.6% (46/1,787) to 16.4% (277/1,685), +13.9 points (98.75% paired CI [+9.0, +19.3]) (misguided-tests report). Effective tests dropped from 41.9% (749/1,787) to 19.5% (328/1,685), and caught problems fell from 141 to 81 of 164. On get_positive (returning negatives), it wrote assert get_positive([1, 2, 3]) == [].

Summarizing a spec first gave 20.6% misguided tests (2,238 tests, CI spans 0), and 83/164 specs (80 after 20-item audit) described the bug as intended behavior. Without a formal hypothesis verdict, keeping the human docstring on buggy code cut misguided tests to 4.8% (147/164 caught). Turning thinking on (16,384 cap; 59/164 buggy truncated) raised misguided rates across 85 shared problems (post-hoc) from 22.4% (195/870) to 37.6% (207/551) and cut effective tests to 3.3%; get_positive's trace noted the bug yet asserted []. Readers can screen functions with our 109-line 10-minute check script.

Prose specs still leave sparse visible suites blind. In our 8-model tournament on synthetic Kestrel Supply rules (llama.cpp 0.9.0-dev, A100, temp 0, seeds 42/43/44, one task and harness), Round 2 Qwen3.5 4B passed 4/4 public tests yet scored 41/50 hidden (<45 pass line) by rounding to nearest 0.1 kg (10.03 to 10.0) on whole-kg public tests. In Round 3, all three finalists passed 5/5 public tests cleanly, yet separated on 60 hidden cases: Qwen3.5 9B scored 54/60 all three runs (30.0 pushed to 30.1), Qwen3-Coder 30B-A3B scored 54, 58, 58 (median 58/60; Silver fee bug), and Qwen3.6 27B scored 60/60 (~46.7 s run 1 vs 15.3 s coder). Anthropic's ~98%-vs-24% gap reflected the same dynamic at scale.

Memory loops fix format rules faster than logic

Anthropic converted ~60 June review notes into CLAUDE.md rules, yet encoded critical invariants in tests, lints, and merge checks. Our fixed-model repair test (qwen3.5:9b, Ollama 0.40.2, Q4_K_M, temp 0, 36 unique final tasks x 2 seeds = 72 attempts, not 72 independent tasks) shows why. Edits tuned on 18 dev + 18 validation tasks lifted accuracy from 36/72 (50.0%) to 50/72 (69.4%) (95% paired CI ~8.3 to 33.3 points) with zero retries. Yet 12 of 14 added passes came from JSON escaping (0/12 to 12/12) and 2 from policy (8/12 to 10/12), while ledger stayed 4/12 and invoice math stayed 0/12 despite prompt text calling the model a "strict arithmetic engine". Schema validity hit 72/72, leaving 22 well-formed wrong answers; including passing dev runs tied baseline at 36/72.

Chart of self-harness accuracy by family showing JSON escaping rose 0/12 to 12/12 while invoice stayed 0/12 and ledger 4/12, beside escalating rules to lints and oracle diffs.

Prose fixes syntax conventions far better than logic. Multi-CLI teams add rule mismatch: in our November 23, 2026 rule-file test (Claude Code 2.1.302, Codex 0.171.0, OpenCode v2.0.32, five setups x 2), placing both AGENTS.md and CLAUDE.md in root caused Claude Code to read CLAUDE.md, Codex AGENTS.md, OpenCode both, and CLAUDE.md alone left Codex empty. Keeping shared rules in AGENTS.md and @AGENTS.md in CLAUDE.md reached all three.

What a smaller team can copy this week

Without production shadow traffic, three practices transfer directly:

  1. Enforce deterministic gates and read-only test locks ahead of review. Block empty diffs, @pytest.mark.skip, || true, fail-open catches, collected == 0, and baseline test edits in code before human or full-diff LLM review.
  2. Treat legacy code as a differential oracle. Never derive parity tests solely from code under rewrite; supply human specs or replay sanitized real fixtures through both versions and diff exact fields or bytes.
  3. Graduate repeated rules out of prose. Keep shared rules in AGENTS.md (@AGENTS.md in CLAUDE.md), and convert failures surviving prompts (rounding rules, schema invariants, dual-repo parity) into lints or hidden diff suites.

The newsletter below sends our next agent test when it is out.

Stay Updated

Follow us for the latest posts and tutorials

Subscribe to Newsletter