Anthropic just published how it moved the API that every Claude request passes through from Python to Rust, with Claude agents writing and fixing much of the new code. The results: about 70% less CPU per request, more than 80% less memory, and no downtime (Anthropic).
The part worth your attention is shadow testing, the method they used to prove the new version behaved like the old one. Their tests said 98% passing. Real traffic said only about a quarter of requests matched. If an old system feels too risky to replace, study this pattern.
TL;DR#
- Anthropic migrated its Messages API from Python to Rust using Claude agents, cutting CPU per request by about 70% without downtime.
- Its rewrite passed about 98% of tests while only about a quarter of real inputs matched, so shadow testing on production traffic became the real check.
- With AI writing code cheaply, verification is now the bottleneck in any legacy system migration. Plan for it before you write a line.
What Anthropic actually did#
Built in 2023 as "basically a request forwarder," the Messages API saw traffic grow roughly 1,800 times by fall 2026, with Python adding overhead at every step.
The team first tried the textbook move: rewrite only the slow part. They moved output parsing to Rust and called it from Python. CPU dropped 8% to 10%, but each token now crossed between the two languages three times, and the gain didn't justify the extra complexity.
So they rewrote it fully. Claude produced a first version of the core request path in about a week. Proving it matched production was the hard part:
- The Python API kept shipping features during the migration, so "correct" was a moving target.
- Model replies are nondeterministic, so two different outputs didn't automatically mean a bug.
- Engineers couldn't read customer requests, so they couldn't simply eyeball where the versions diverged.
Public traffic moved to Rust in September 2026 (The Next Web).
Why tests weren't enough#
Anthropic had about 700 integration tests. Two problems made them unreliable as a migration check.
First, the tests were tied to the Python implementation, so they had to be ported too. When the team audited the ported tests, they found more than 100 weakened assertions. A pass could mean a loosened test, not correct code.
Second, tests only cover the cases someone thought of. Just 20 on/off options produce over a million combinations. One example: Python escaped characters like emoji when writing JSON tool calls, while Rust wrote them as is. The prompts differed by a few bytes, and no test caught it.
The result was a sharp gap. In April the Rust version passed about 98% of its tests, yet only about a quarter of production inputs matched. By August, the seven-day median match rate had reached 99.6%.
If your business runs on a system that's ten years old, assume its real behaviour lives in production, not in its tests or docs. That's true for legacy code migration and for any data migration from a legacy system.
How shadow testing works, and where it gets tricky#
Shadow testing (also called shadow traffic testing) sends a copy of real requests to the new system while users keep getting responses from the old one. You compare the two and chase every difference:
request -> [ Old system ] -> response to user
| |
| copy | checkpoints
v v
[ New system ] -> [ Compare ] -> diff records, grouped by fingerprint
(no side effects)
Side effects must happen once#
Many shadowing tools assume a request can safely run twice. That breaks the moment it charges a card or sends an email. Anthropic had to make sure each request counted only once toward a customer's limits and bill.
Nondeterminism needs a fixed input#
Because model replies vary, they ran the model once and replayed its output into the Rust version, then compared every step before and after the call. Do the same for anything random or time-based: record once, replay to both.
Compare shapes when you can't read the data#
For privacy, they logged where a difference happened, the first differing byte and both lengths, never the text. Each bug left a repeatable fingerprint, so hundreds of thousands of mismatches collapsed into a small number of bug groups.
The agent loop, and where humans stayed in charge#
A script ran every 10 to 30 minutes, grouped new diff records, and alerted a coordinating agent only when a new kind of difference appeared. It assigned a worker agent and opened a Slack thread for engineers.
Workers ran in a sandbox where a local check compared both versions in under a second. They guessed at a cause, reproduced it, edited the Rust until both sides matched, then added a test. Fixes reached production only after a human reviewed the pull request.
That review gate mattered. In one case an agent "fixed" a missing web search tool description by copying the text into local files. The outputs matched, but an engineer rejected it as throwaway code. A verifier can tell you outputs match. It can't tell you a fix is good enough to ship.
What this means for your business#
Most scaling businesses aren't migrating a model API. They're stuck on an old order system or a custom CRM from 2014 that does dozens of undocumented things, so replacing it feels too risky.
Anthropic's write-up changes that math. If AI can write a first version of a core service in about a week, most of the cost of a legacy system migration moves from writing code to proving the new system behaves the same. That cost is real, but it's predictable.
Two caveats. Anthropic's numbers are its own: CPU was measured in one region and no dollar figure was given (AI Digest). They also had a strong platform team, huge traffic to compare against, and roughly five months of shadow runs before cutover. A smaller business needs less scale, not less discipline.
How to run a shadow test on your own migration#
- List every output the old system produces: API responses, database writes, emails, invoices, files.
- Mark which ones are side effects. In shadow mode, the new system writes to a sandbox or a log, never to the real world.
- Record anything nondeterministic (timestamps, IDs, AI replies, third-party API responses) and replay the same values to both sides.
- Compare at checkpoints, not only the final output, so you know where a difference started.
- Group differences by fingerprint and fix the biggest group first. One common bug can hide others behind it.
- Keep a human review step between "the outputs match" and "this ships."
- Don't freeze the old system. Require any change to it to have a matching change in the new one until cutover.
- Cut over a slice of traffic at a time, and keep the old system ready to take traffic back.
How MagicMakers Lab approaches this#
Much of our custom software development work starts with a system a client has outgrown. When we consolidated three disconnected systems into one platform for Business Hub, the real risk sat in behaviour nobody had written down. So we plan verification first: what to compare, where the side effects are, and who signs off on cutover. The same thinking applies when we automate fulfilment flows like Framico's, where a duplicated order is worse than a slow one.
Key takeaways#
- AI has made writing a replacement system fast; proving it behaves the same is now the main cost.
- A high test pass rate can hide a low real-world match rate (about 98% versus about 25% for Anthropic in April).
- Shadow testing on real traffic catches the behaviour your tests and docs never captured.
- Keep humans at the gate between "outputs match" and "ship it."
FAQ#
What is shadow testing?#
Shadow testing means sending a copy of real production requests to a new version of a system while users still get responses from the old one. You compare the two outputs and investigate every difference. Because the new version never affects users, you test it against real behaviour, including edge cases your tests missed, before switching anyone over.
Is shadow testing safe for systems that send emails or take payments?#
Only if you design for it. The shadow copy must not repeat side effects like charging a card, sending an email or updating inventory. Route its writes to a sandbox or a log, or replay recorded responses from outside services. Anthropic made sure each request counted only once toward a customer's limits and bill during its migration.
How long does a legacy system migration take with AI?#
It depends on how much undocumented behaviour the system has. AI can now produce a first version quickly: Claude wrote the core request path of Anthropic's API in about a week. Verification took far longer, with comparison running from April to August before public traffic moved in September. Budget most of your time for proving parity.
Should I rewrite my legacy system or refactor it piece by piece?#
Partial rewrites can add complexity that outweighs the gain. Anthropic's first step, moving one component to Rust, cut CPU by only 8% to 10% because data crossed between languages three times. A full rewrite paid off once it could be checked against production. If you can't build a reliable way to compare old and new, refactoring in place is usually safer.
If there's a system you've been afraid to replace, start with one question: how will you know the new one is right? We're happy to map that out with you, including which outputs to compare and where the side effects hide. Book a free audit.