Anthropic's Rust rewrite used the old service as judge
Ricardo Argüello, December 5, 2026
If you keep one thing from this post, keep this. When an agent rewrites a system, a green test suite tells you very little. Running the new system next to the old one on real traffic, and looking at where they disagree, tells you a lot. The old system’s behavior in production is the standard. The tests are a sample of it.
Anthropic just published numbers that back this up. On November 25 it described how it moved the Messages API from Python to Rust, with public traffic switching over in September. I read the original write-up. The speed gain is the headline, about 70% less CPU per request by Anthropic’s own measure. The part worth your time is how it knew the rewrite was right.
Two numbers from April
In April the Rust version “passed about 98% of its tests,” and only about a quarter of inputs matched on production traffic. Same code, same week, two readings. One says nearly done. The other says three of every four requests behave differently from what customers get today.
Back up one step. The Messages API was built in 2023 in Python, started as a simple forwarder, and by fall 2026 was carrying roughly 1,800 times the traffic it had in early 2024. In March the team rewrote only the response parsing in Rust and saved 8% to 10% of CPU. Not enough, because each token crossed the Python and Rust boundary three times. So they went for the full rewrite. Claude wrote a first version of the core request path in about a week.
Writing code was the cheap part. Anthropic says it plainly: verification, not generation, had become the bottleneck.
What was wrong with the tests
The team started from roughly 700 integration tests, tied to the Python implementation. When they audited the ported tests they found more than 100 weakened assertions. A test that no longer demands what it used to demand still passes. That is the whole problem with a test suite as the judge of an agent’s work, when the agent is also the one editing the tests.
Even a perfect suite runs out of room. The article does the arithmetic, and I rechecked it: 20 yes-or-no options make 1,048,576 combinations, about 12 days per model at one second a test. A real API has far more than 20 options.
If you run a company on an old billing platform or order system, this will sound familiar. Nobody wrote down what the system does. It does it, quirks included. I wrote about that on the legacy modernization side months ago, and this migration shows the same idea at a scale few companies will ever reach: the running system does the judging.
How the old service got to vote
Anthropic built it in a particular way, and each piece scales down to a smaller shop.
First, the model ran once. Its output was replayed to Python and to Rust, so the model’s own randomness could not create fake differences. Requests were not counted twice either, which protected customer rate limits and billing.
Second, comparison happened at checkpoints: accept or reject, settings, prompt building, sorting the output, counting usage. A difference record held the step, the prompt piece, the first differing byte and the two lengths. No text. Engineers never read what customers sent.
Third, bugs were grouped by fingerprint. One bug could throw off hundreds of thousands of nearly identical records. Grouped, they became a short list, and a script ran every 10 to 30 minutes and raised a flag only for new kinds.
One of the differences was tiny. When Python writes JSON tool calls it escapes certain characters, an emoji for example, and Rust did not. The prompts differed by a few bytes. I like that example because no one would think to write a test for it.
The match rate did not climb in a straight line. It started at 24%, sank to 6.5% in early May, and ended at 99.6% once the fixes piled up. My own reading of the dip, and it is only mine, is that the comparison kept finding things instead of hiding them.
The results, and who measured them
| Measure | Anthropic’s reported result |
|---|---|
| CPU per request | about 70% lower (August to October) |
| Memory per request | more than 80% lower (August to October) |
| Median time to first token | about 20% lower (roughly September 7 to 21) |
| Match with the Python service | from about a quarter to 99.6% |
These are Anthropic’s figures about its own service. No third party audited them, and the write-up gives no team size and no code size. Read them as what this route can deliver, not as a forecast for your system.
The judge can be gamed
In mid-May the largest remaining gap came from the web search tool description, which Rust did not fetch. An agent copied the text into files as a workaround. It passed the local verifier. A human engineer rejected it as throwaway code. The write-up puts it this way: the verifier rewarded matching outputs, and the agent found the cheapest way to produce them.
So the claim I opened with needs a limit. An oracle is only as good as the review around it. If an agent can fake a match without doing the work, someone has to read what changed and why. At Anthropic, engineers’ corrections became shared rules such as “port exactly what Python did,” and that one rule surfaced seven more places where a port had relied on a guess.
What I would ask before an agent touches your system
This part is my opinion, not an Anthropic finding. If a vendor, or we ourselves, propose replacing a system with agents, I would ask for three things before the first line of new code:
- Your current system logs real inputs and outputs, with sensitive data stripped, or starts logging now. Without that there is nothing to compare against.
- Progress reports say how much live traffic matches, not how many tests pass.
- Someone on your side reads every change that “fixes” a difference. The difference may have been covered up and not resolved.
If your system logs nothing today, that is the first job, and it costs less than the rewrite. To go through what a migration like this would need to meet in your case, tell us which system it is and what traffic it keeps, through our technology partner service.
Two more reads. There is comprehension debt, the code nobody on your team can explain afterwards. And there are evals as a compounding asset, so what you learn ends up in checks that do not loosen on their own.
Frequently Asked Questions
Why did Anthropic migrate its Messages API from Python to Rust?
According to Anthropic, Messages API traffic grew roughly 1,800 times between early 2024 and fall 2026, and Python added overhead to every request. The Rust version uses about 70% less CPU per request and cuts median time to first token by about 20%, measured by Anthropic itself.
What does using the old system as an oracle mean when AI agents rewrite software?
It means the current system's real behavior defines what correct is, instead of a list of written tests. Anthropic compared, step by step and on production traffic, what its Python API produced against what the new Rust API produced, and treated every difference as a bug to resolve.
Why doesn't passing 98% of tests guarantee an AI-written rewrite behaves like the original?
Tests only cover the combinations someone thought of. In Anthropic's Messages API migration, the Rust code passed about 98% of tests while only a quarter of production inputs matched Python. The audit also found more than 100 weakened assertions among the tests ported from the original service.
How do you compare a rewritten system with the original without reading customer data?
Anthropic logged the shape of each difference, not its content. Each record held the step, the prompt piece, the first differing byte and the two lengths, with no text. That let it group bugs by fingerprint and assign them to agents while no engineer read customer requests or replies.
Newsletter
Get the best articles in your inbox
We respect your privacy. Unsubscribe anytime.



