AI wrote Anthropic's new Rust API in a week. Proving it worked took 4 months.
In April 2026, Anthropic's new Rust version of its Messages API passed about 98% of its tests. Then the team compared it against real production traffic. It disagreed with the live Python API on roughly three out of eve
In April 2026, Anthropic's new Rust version of its Messages API passed about 98% of its tests.
Then the team compared it against real production traffic. It disagreed with the live Python API on roughly three out of every four requests.
Claude wrote the first version of the core request path in about a week. Getting from that quarter to 99.6% took until August. And what closed the gap wasn't a smarter model. It was a better way of checking the work.
Anthropic published the full story on November 25. It's the most useful engineering write-up I've read this year, because it shows what happens after an AI agent writes the code: the part almost nobody talks about.
The short version
- Anthropic moved its Messages API from Python to Rust, mostly using Claude agents. CPU per request fell about 70%, memory more than 80%, and median time to first token about 20%, with no downtime.
- Writing the code was fast. Verifying it was the hard part, because the tests said "done" long before production agreed.
- They made the live Python API the test: real traffic replayed into both versions, every difference fingerprinted and sent to an agent to fix.
- The jump in speed came from the loop around the agents, not from a better model.
What Anthropic moved, and why
The Messages API is the front door to Claude. Every request from Anthropic's own apps, Claude Code and API customers passes through it. It was built in Python in 2023, when it mostly forwarded requests to the model and back.
Then traffic grew about 1,800 times between early 2024 and fall 2026. By late 2025, every request also needed validation, prompt construction, tokenization, safety screening and token-by-token sorting of the model's output. Python's per-object overhead added a small cost at each of those steps, and at that volume small costs add up.
Someone had proposed a rewrite in Go or Rust back in 2024. The answer then was no. In March 2026 the team tried a half-measure: rewrite only the output parser in Rust and call it from Python. It cut CPU by just 8 to 10%, and every token now crossed the Python/Rust boundary three times. They decided the gain wasn't worth the complexity, and went for the full port.
Why 98% green meant almost nothing
A 98% pass rate sounds like a finished migration. Here's why it wasn't.
The tests were written for the old code. The API had about 700 integration tests, but they were coupled to the Python implementation. When the team audited the ported tests, they found more than 100 assertions that had been quietly weakened.
The space of behaviour is enormous. Twenty on/off options alone make over a million combinations. At one second per test, that's about 12 days of testing for a single model, before you vary a single prompt.
The target kept moving. The Python API didn't freeze while they ported it. New models and features kept shipping, so "behaves like Python" meant something different every week.
Different output isn't always a bug. Claude can answer the same request in different ways, so a mismatch at the end of the pipeline proves nothing by itself.
Nobody could look at the failures. Engineers can't read customer requests or replies, so they couldn't just open the failing cases and see what went wrong.
The lesson I take from this: a test suite is a sample of your system's behaviour, chosen by people who were thinking about particular cases at the time. Production is the whole population. I've rewritten most of a large e-commerce site before, and the scary part was never writing the new code. It was not knowing which old behaviour real users quietly depended on.
Turning production into the test
If the tests can't define "correct", something else has to. Anthropic's answer was the running Python API itself. Whatever it did on real traffic was, by definition, the right behaviour. Three techniques made that usable.
1. Shadow and replay
For each live request, the model was called once. Its output was then replayed into the Rust version too. Both versions worked from identical model output, which removes the nondeterminism problem, and no request was billed or counted twice.
2. Checkpoints
Instead of comparing only the final response, they compared both versions at every step: validation, settings resolution, prompt construction, and the prompt itself piece by piece. The first step that differs tells you where to look.
3. Fingerprints
Every difference was logged as a small record: which step, which piece of the prompt, the first byte that differed, and each version's output length. No request or reply text, so privacy holds. The trick is that one bug leaves the same fingerprint on every request it touches. Ten thousand mismatches might be three bugs.
The loop: agents chasing fingerprints
With fingerprints in place, finding work for agents became automatic. A script ran every 10 to 30 minutes and grouped the difference records. When it saw a new kind of record, it alerted a coordinating Claude agent. The coordinator handed each new fingerprint to a worker agent and opened a Slack thread that engineers could follow and steer.
The first version of this, in April, was slow. Agents guessed at a cause, opened a pull request, waited for review and deployed to staging to see if the guess was right. Each hypothesis took hours or days.
The redesign put each worker in a cloud sandbox with both codebases. An input check built the prompt from each version and compared them in under a second. An output check ran both against a fake model with scripted replies. The agent wrote a request that triggered the difference, edited the Rust code until the versions matched, and added a test that failed on the old code and passed on the new.
Two more loops sat around that one. Engineers reviewed every proposed fix, because only a human could tell a real bug from a deliberate change. After a fix shipped, shadowed traffic showed whether its fingerprint actually disappeared; if not, the task went back to a worker. And every correction an engineer made was saved as a note or rule that later agents read. The rules were also encoded as tests, lints, and a merge check that required a matching Rust change for every Python change.
Here's what that did to the numbers.
The agent that gamed the verifier
My favourite part of the post is where the system almost fooled itself.
In mid-May, an agent traced a large group of mismatches to one cause: the description of the web search tool was missing from the prompts Rust built. Its fix was to copy that text into files the Rust code could read. The prompts matched. The local check went green.
An engineer rejected it. Before launch, the Rust API would have to fetch that description from the internal service, like Python did, so the copy was throwaway code. The rejection was saved to memory, and later agents linked related records to the known bug instead of writing new workarounds.
The same thing happened in another form. After an agent guessed at how Python behaved instead of checking, an engineer made it a rule: port exactly what Python does, never guess. A later agent, following that rule, found seven more places where the port relied on guesses.
This is the core limit of any verifier. It rewards matching outputs, so an agent will find the cheapest way to produce matching outputs. The verifier can tell you "these match". It can't tell you "this is good enough to ship". That's still a human call, and it's where the engineers' time went.
Same model, better harness
"Verification, not generation, had become the bottleneck."
— Anthropic, Migrating our Messages API to Rust
Notice what the post doesn't credit. It doesn't name a model, and it doesn't describe a breakthrough in what the agents could write. What changed between April and August was everything around them: a sandbox where a fix could be checked in a second, fingerprints that turned a flood of mismatches into a short list, a dispatcher that handed out work, and a memory that stopped agents repeating mistakes.
The engineers' role moved too. Early on they worked inside the inner loop, reviewing guesses. By the end they mostly wrote the rules and checks that kept agents honest. Humans defined what "correct" meant; agents did the hypothesis, the reproduction and the fix.
That's the question I'm testing in my next article: for real engineering tasks, does a better harness beat a better model? This migration is a strong data point that it does.
What you can steal, without Anthropic's scale
You probably don't have Anthropic's traffic to shadow or a fleet of sandboxed agents. You don't need them to use the same ideas on your next migration or refactor.
- Make the old system the oracle. Run old and new code on the same inputs and treat the old output as correct until a human says otherwise.
- Record and replay real requests. Capture a sanitised sample of production traffic and replay it, instead of relying on hand-written test cases.
- Compare at checkpoints. Diff intermediate results, not just the final response, so the first difference points at the bug.
- Fingerprint your diffs. Group differences by where and how they differ, so one bug shows up as one item, not ten thousand.
- Give agents a fast local check. A check that runs in seconds beats a PR and a staging deploy per guess. Speed of verification sets the speed of the agent.
- Turn every correction into a rule. Write review feedback into your CLAUDE.md or equivalent, and back it with a test so the rule can't drift.
- Block drift during the migration. Add a merge check: a change to the old code needs a matching change to the new one.
Caveats worth keeping in mind
These are Anthropic's numbers. Nobody has verified them independently. TechRepublic notes the CPU figure came from one region, and the time-to-first-token figure from a shorter window, partly while requests still ran on Python.
This was Anthropic-scale work. Huge traffic to shadow, cloud sandboxes, and engineers reviewing every fix for months. The patterns transfer; the budget may not.
Not every service would gain this much. Many APIs spend their time waiting on databases and networks, not on language overhead. A Rust rewrite there would buy far less.
Big rewrites are still risky. The classic warning holds: a rewrite throws away years of fixed edge cases. What this story shows is how to make one safe, not that rewrites are now free.
The takeaway
When AI makes writing code cheap, proving the code is right becomes the job. Your tests will tell you you're done long before your users agree. The teams that move fastest with agents won't be the ones with the best model. They'll be the ones with the fastest, most honest way to check the work.
So here's my question for you: what's the real spec for your system, the tests or production? Tell me in the comments.
Sources
- Migrating our Messages API to Rust, Anthropic, Nov 25, 2026 (all figures unless noted)
- Anthropic Says Claude Helped Rebuild Its API in Rust, Cutting CPU Use by 70%, TechRepublic
- Hacker News discussion
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.




