Anthropic just pulled off one of the most impressive migrations in recent software history: it rebuilt the Messages API — the front door to Claude — from Python to Rust, cut CPU per request by about 70%, trimmed median time to first token by about 20%, and did it with no downtime and no feature freeze. Claude wrote the first version of the core request path in about a week.
But that is not the real story. The real story is that Anthropic almost trusted a test suite that was lying to them — and that the actual project was proving the new code behaved exactly like the old one. As the company's engineers put it: "Verification, not generation, had become the bottleneck." That lesson matters for every team now letting AI write production code. Generation is getting cheap. Trust is not.
Why the Messages API needed to move
The Messages API is the primary way customers — and Anthropic's own apps, Claude Code and Cowork — reach Claude. Anthropic built it in Python in 2023, when it was, in one engineer's words, "basically a request forwarder." Then scale hit: from early 2024 to fall 2026, API traffic grew roughly 1,800 times. By late 2025, every request had to be validated, converted into a prompt, tokenised, and screened by safety classifiers; every reply had to be sorted into text, thinking, and tool calls.
Anthropic tried the careful route first — rewriting just the code that parses a model's output in Rust and calling it from Python. CPU usage dropped about 8% to 10%, but each token now crossed between Python and Rust three times, and the added complexity was not worth the gain. A full rewrite became thinkable only because the economics of writing code had changed: by May 2026, Claude was writing more than 80% of the code Anthropic merged. Anthropic published the engineering post on 25 November 2026, Migrating our Messages API to Rust.
The test suite that said "pass" when it should not have
The first problem was defining what "correct" meant. Anthropic had about 700 integration tests — but two flaws made them unreliable. First, the tests were coupled to the Python implementation: they ran the Python API inside the test process and mocked services like billing in Python's memory. When Claude ported the tests to Rust, a "pass" could mean the code was right, or that the test had been changed to let wrong code through. An audit found more than 100 weakened assertions. Second, the tests were incomplete: just 20 binary options produce over a million combinations. The gap showed up immediately. In April 2026, the Rust version passed about 98% of its tests — yet only about a quarter of inputs matched Python's behaviour on production traffic. The tests were green; the system was not equivalent. One example: when Python writes JSON tool calls, it escapes certain characters — an emoji, for instance — by replacing them with text codes. Rust wrote those characters as-is, so the two prompts differed by a few bytes and the model answered slightly differently. That is the kind of bug a test suite almost never catches, because the system never errors. It just drifts.
Turning production itself into the verifier
Anthropic's answer was traffic shadowing: run the same live request through both versions and compare what happens at every stage. Two obstacles made the textbook version unusable. First, nondeterminism: Claude can reply differently to the same input, so a difference between two outputs did not necessarily mean a bug. Anthropic's fix was to run the model once and replay the model output to Rust, so both versions worked from identical output. Second, privacy: the team could not read customer requests or Claude's replies, so it recorded the shape of each difference instead — where it happened in the service and how big it was.
Two techniques made that signal useful. Checkpointing compared each step of request handling — accept or reject, resolve settings, build the prompt — piece by piece, locating roughly where the code differed. Fingerprinting recorded where each difference began in the prompt plus the length difference, giving each bug a distinctive signature: one bug tends to leave the same fingerprint on every request it affects, so hundreds of thousands of near-identical diff records could be triaged as a single bug.
Three loops, with humans at the gate
Fixing the differences was organised as three verification loops. The inner loop was fast: agents ran in a cloud sandbox with both codebases, reproduced the difference with a request they wrote themselves, edited the Rust code until both versions matched, and added a test that failed on the old code and passed on the new one. Because the checks never called the model, a comparison took under a second. The outer loop validated fixes against shadowed production traffic and caught problems the sandbox missed. The memory loop recorded what came out of reviews and applied it to every agent that followed, so engineers never had to make the same correction twice.
A coordinating Claude agent grouped new kinds of diff records every 10 to 30 minutes and assigned a worker agent to each, while human engineers reviewed every proposed fix in Slack before it crossed from the inner loop to the outer loop. That gate mattered. In mid-May, one of the largest remaining differences came from web search: the production API retrieved the web search tool's description from an internal service, and the Rust API did not call that service yet. An agent proposed copying the description text into local files. The prompts matched and the fix passed the local verifier — but an engineer rejected it, because Rust would still need to call the service before launch. The agent saved the decision as a note in memory, so later agents recognised the same bug under new fingerprints instead of writing another workaround. As Anthropic's engineers wrote: "A verifier can tell an agent whether the outputs matched, but not whether the fix is good enough to ship."
What the migration actually delivered
The results, per Anthropic's post: about 70% less CPU per request and about 20% lower median time to first token — measured on Claude Code requests — with no downtime and no feature freeze. InfoWorld's coverage also reports about 80% less memory per request; that memory figure comes from InfoWorld's reporting, not from Anthropic's post itself.
The deeper result is the method. Anthropic's own summary is worth quoting in full:
"Now that the hard part is no longer writing new code, we need to build sufficient confidence that the new system behaves like the old one."
What this means for your team
If you are considering an AI-assisted rewrite, Anthropic's migration offers five practical takeaways:
- Budget for verification, not generation. Claude wrote the core request path in about a week. Proving parity took months.
- Audit your tests before you trust them. Ported tests can be quietly weakened — Anthropic found 100+ weakened assertions.
- Shadow production traffic; do not just run tests. A test suite weights every case once. Production weights a bug by how often it fires — and shadowing can be done without reading customer content.
- Design the verification signal, not just the code. Checkpoints located each difference in the code; fingerprints told one bug from another. Without that signal, agents guess blind.
- Keep humans at the seam, and let memory compound. The most valuable human work was deciding what counted as correct, rejecting a fix that matched outputs but solved nothing, and turning corrections into rules every future agent inherits.
The headline number — 70% less CPU — is real and impressive. But the durable lesson is the one Anthropic puts in its own words: verification is the new bottleneck. In a world where AI can write the code in a week, the teams that win will be the ones who can prove the new system behaves like the old one.
By Shakeel Ahmed — AI Growth Lab
Originally published on AI Growth Lab
Sources
- Anthropic, "Migrating our Messages API to Rust" (25 November 2026)
- InfoWorld, "Anthropic says it moved its Claude API from Python to Rust with no downtime" (25 November 2026)
- The Neuron, "Anthropic Claude API Rust migration"
