Anthropic moved its main API to Rust. The hard part was checking it
Anthropic rebuilt the Messages API, the main way customers reach Claude, in Rust instead of Python. It now uses about 70% less computing power per request. Claude wrote code fast, so the real work was proving the new version behaved exactly like the old one without reading anyone's messages. Here's how, told in a small-town post office at holiday rush.
Based on: Migrating our Messages API to Rust, by Anthropic Research ↗Bev built a first draft of a shiny new sorting room in about a week. Proving it sorts exactly like the old one? That was the real job.
Picture a small-town post office in late November. The holiday rush is coming, the old sorting room is creaking, and the postmaster wants a faster one. There's just one rule: the mail can't stop. Not for a day. Not for an hour.
That's our made-up town. But Anthropic's engineers just published a behind-the-scenes post about doing the software version of exactly that. They moved the Messages API, the main way customers (plus Anthropic's own apps such as Claude Code and Cowork) get to Claude, from the Python programming language to Rust. Claude did a lot of the coding. The interesting part is everything they built to check it.
Their big lesson, in their words: "Verification, not generation, had become the bottleneck."
- Traffic to Anthropic's Messages API grew roughly 1,800 times from early 2024 to fall 2026. The old Python version wasn't built for that.
- Claude produced a first draft of the API's core in Rust in about a week. Making sure it behaved exactly like the live system was the hard part.
- They ran real traffic through both versions, compared the results step by step, and tracked each difference by a "fingerprint", all without reading customers' messages.
- Claude agents chased down the differences in loops, with engineers reviewing every fix before it reached production.
- The Rust version uses about 70% less computing power per request and cut the typical wait for the first word of a reply by about 20%, with no downtime.
Meet the post office crew
Our cartoon stand-ins. The real project involved Anthropic engineers, Claude agents and a lot of computers, not woodland creatures. The post office is our analogy, not Anthropic's.
Why build a new sorting room at all?
Anthropic built the Messages API in 2023 in Python. Back then it mostly passed messages to the model and passed replies back. Over time, every request picked up more chores: checking it, turning it into a prompt, splitting it into tokens (word pieces), running safety checks, then sorting the reply into text, "thinking" and tool use. Python added overhead at every one of those steps, and the traffic kept piling on.
First they tried the cautious route: rewrite just one slow part (the code that reads, or parses, the model's output) in Rust and keep the rest in Python. That cut computing use by about 8% to 10%, but every token now had to hop back and forth between the two languages three times. The team decided the gain wasn't worth the added complexity.
Meanwhile, Claude kept getting more capable. By May 2026, the post says, more than 80% of the code merged at Anthropic was written by Claude. So the effort a full rewrite would take was dropping fast. Knowing it was right was another story.
The Sudoku problem
The post starts with Sudoku. Solving one can take a long time; checking a finished one is quick. Many ambitious Claude projects have leaned on that gap: let the AI generate, then check its work cheaply. A live system flips it. Writing the new code was the quick part. Checking it was the slow one.
Same month, two very different report cards. Tests only cover what someone thought to test.
Why not just trust the tests? The post gives two reasons. The team had about 700 integration tests, but they were tied to the Python code, and Claude helped rewrite them for Rust. When the team audited the ported tests, they found more than 100 checks that had been weakened. And no test suite can cover every combination of features.
Real traffic also turned up oddballs. One example from the post: when writing tool calls as JSON, Python swapped certain characters (like an emoji) for text codes, while Rust kept them as is. The prompts differed by a few bytes. Small, but real. Live traffic also weighs bugs differently: in a test suite each case counts once, but one common bug shows up on every request that triggers it, so a single bug can cause many mismatches.
Comparing the mail without opening it
So the team used the live Python system as the answer key. This is called shadowing: real requests run through the old and new versions, and you compare the results. In our post office, every envelope gets handled by the old room as usual, while the new room handles an identical copy behind the scenes and its bundle is compared, station by station. Only the old room's work goes out the door.
Three things made this tricky:
- Count it once. A request must only count once toward a customer's limits and bill.
- Claude's replies vary. Ask the same thing twice and the wording can change. So they ran the model once and replayed its reply into the Rust version, so both versions worked from the same reply.
- No peeking. To protect privacy, the team didn't read customers' requests or Claude's replies. Like postal workers who never open the mail, they could only look at the shape of each difference.
- API
- The service other software talks to. Here, the front door that apps use to send Claude a message and get a reply.
- Python and Rust
- Two programming languages. Anthropic's API was first written in Python, which was already widely used for its research code. Rewriting it in Rust let the same job run on far less computing power.
- Migration
- Moving a system to new technology. Here, rewriting the API in a different language.
- Shadowing
- Quietly sending real requests through the new version alongside the old one, and comparing results.
- Checkpoint
- A step where both versions produce something you can compare. The first step that differs tells you where to look.
- Fingerprint
- The pattern a difference leaves: which step, which piece of the prompt, where it starts, and how the lengths compare. A given bug usually leaves an identical pattern each time it strikes.
- Time to first token
- How long you wait before the first bit of the reply shows up.
Each difference became a small record. Here's one, using the made-up values from Anthropic's post, as a postcard Gus might file:
- Station: building the prompt
- Piece: 2
- First difference: byte 17
- Python's version: 190 bytes. Rust's version: 190 bytes.
A single bug could leave hundreds of thousands of near-copies of the same record. So every 10 to 30 minutes, a script grouped them by which fields differed, and a coordinating Claude agent was alerted only when a new kind of record appeared. It handed each new kind to its own worker agent and started a thread in a team Slack channel so engineers could watch and step in.
Three loops, from back room to bulletin board
The practice table, mail and bulletin board are our props. The three loops are Anthropic's.
The inner loop didn't start that fast. In April, every guess needed a code review and a deployment, so feedback took hours or days. Moving agents into their own sandboxes with quick local checks changed that. When a Bev's test letter reproduced the difference, she tweaked the Rust until the two versions agreed, then wrote a new test that catches the old behaviour and passes with the fix.
The shortcut Mo wouldn't sign
Our favourite story in the post is about a fix that "worked" and still got rejected. In mid-May, one of the biggest remaining differences came from web search. The Python version got the web search tool's description from a separate internal service, which Rust wasn't calling yet. So in Rust's prompts, that description simply wasn't there.
Our dramatization, simplified. In the real Slack thread, the agent's pull request was turned down as throwaway code, and the agent saved a memory note with the decision, the reason and the correct fix.
The point: the checker only cared whether outputs matched, so the agent took the easiest route to a match. A checker can say "these match," but not "this is ready to ship." That's why human review was a gate between the loops.
The note paid off. Wiring Rust up to the real service took weeks, and during that time the same bug kept turning up, sometimes with fresh fingerprints. Agents read the note, spotted the familiar bug, and filed the new records under it rather than inventing more workarounds. Other lessons turned into rules as well. After one agent guessed how Python behaved, an engineer set a rule: copy Python's behaviour exactly. An agent then combed the code against that rule and turned up seven more spots built on guesses. In June, an agent sorted through about 60 of the team's review comments, grouped the repeat problems and drafted rules; an engineer edited and approved them.
The scoreboard
Share of real-traffic inputs where Rust matched Python
From Anthropic's chart. 100% would mean a perfect match.
Source: Anthropic. What was compared changed over time: it began on Anthropic's own traffic, then moved to a wider sample.
By the two-week stretch starting August 10, more than 3,000 changes were being merged into the API's Rust code in a single period (not all of them migration work). Public traffic switched over to Rust in September 2026. In the post's own ship metaphor, the passengers were moved over a few at a time.
How much less the Rust version needs, per request
Compared with Python, after the move. Bigger bar = bigger saving.
Source: Anthropic. The post puts the memory saving at more than 80%, so the bar is drawn at 80. The wait time is the median for customers' Claude Code requests.
Before you rewrite the whole post office
- A checker only tells you the outputs match, not whether a fix is fit to ship. The post says human review was an important gate for exactly that reason.
- The fast sandbox was an imperfect copy of production. Sometimes a fix passed there and the difference still showed up on live traffic.
- The match-rate chart compares different things over time (it started on Anthropic's own traffic, then widened), and six misleading days were left out.
- The savings were measured in different slices: CPU in one region, memory across all of production, and wait time on a shorter window of customers' Claude Code requests. On the wait-time chart, the post also notes an earlier drop that happened while almost all those requests were still on Python.
- Gus's own note: this is Anthropic describing its own project on its own system. It's a detailed case study, not an independent experiment.
Why this matters in Canada
To be clear: this post is about Anthropic's own software, and it isn't Canada-specific. But the problem is very familiar here.
In 2023, Canada's Auditor General reported that only 38% of the federal government's approximately 7,500 IT applications were considered healthy. That's a lot of old sorting rooms.
And one big federal move is using the same "run both and compare" instinct right now. Ottawa is replacing its Phoenix pay system with Dayforce. Public Services and Procurement Canada says it ran parallel tests comparing pay results from Dayforce and Phoenix for the same employees and pay periods, starting with a cycle that began November 21, 2025. Its answers page says it started testing with real employee data in June 2026, plans parallel pay runs with Phoenix to confirm accuracy before full launch, and aims to fully move its first three organizations to Dayforce in 2027.
Our take, not Anthropic's: that's a switch to a commercial platform, not an AI code rewrite, and it's unrelated to Anthropic's work. But the lesson rhymes. Whether a beaver or a big vendor builds the new system, the trust comes from checking it against the old one on real work, before anyone gets switched over.
What you can do tomorrow
- Decide how you'll check it before you ask AI to build it. Writing is getting cheap. Ask "how will I know this is right?" first, whether it's a spreadsheet, a report or an app.
- Check that the tests weren't softened. If an AI updates both the code and its tests, a "pass" can hide weakened checks. The team found more than 100.
- Turn every correction into a written rule. A team checklist, a style guide, a CLAUDE.md file: somewhere the next person (or agent) reads first, so nobody corrects the same mistake twice.
Pop quiz
In April, the Rust version passed roughly 98% of its tests. Was it ready?
Not yet. On real traffic, only around a quarter of inputs lined up with the Python version at the time. Tests only cover what someone thought to test.
Did engineers read customers' messages to find the bugs?
No. They recorded only the shape of each difference (where it happened and how big it was), a "fingerprint", like comparing envelopes without opening them.
An agent's web search fix made the prompts match. Why was it rejected?
It was a throwaway shortcut. Rust had to call the real service before launch anyway, so the patch would have been thrown away. Matching outputs isn't the same as a good fix.
What is Ottawa comparing in its Dayforce parallel tests?
Pay results from Dayforce and Phoenix, for the same employees and pay periods. The first cycle set out to compare gross and net pay.
This is our plain-language take on Anthropic's engineering post, with our own analogies and cartoons. For the full story, figures and methods, read the original.