Insights · Legacy
Migrating a legacy system with coding agents: the hard part is proving the new one behaves the same
Published
Writing the new code is no longer the hardest part of a migration. The hard part now is proving that the new system does exactly what the old one did, including the cases nobody documented. On 25 November 2026, Anthropic published how it migrated the Messages API from Python to Rust. The API is the primary way customers, as well as the company's own apps, reach Claude. According to the company, Claude wrote a first version of the core request path in about a week. The real work was checking it.
The step-by-step process for a modernization (inventory, characterization tests, cutover criteria) is in the guide to modernizing a legacy system. This piece is about parity.
What Anthropic migrated, and why all at once
The Messages API was written in Python in 2023. According to Anthropic, traffic grew roughly 1,800 times from early 2024 to fall 2026, and Rust would make it possible to use far less CPU per request.
The first attempt followed the standard advice: rewrite only the slow part. Anthropic rewrote the code that parses the model's output in Rust and called it from Python. The API's CPU usage fell by about 8% to 10%, but, according to the company, the gains did not justify the added complexity: each token now crossed the boundary between Python and Rust three times.
What changed the math was the cost of writing code: by May 2026, according to the company, Claude was writing more than 80% of the code merged at Anthropic. In the post's own words: "Verification, not generation, had become the bottleneck."
Why proving parity is hard
Parity means the new system responds the same way as the old one to the same inputs. Among the obstacles, Anthropic names three:
- The target kept moving. The Python API kept changing during the migration, with new models and features.
- The model is nondeterministic. Claude can reply differently to the same request, so a difference between two outputs did not prove a bug.
- Nobody could read customer requests. For privacy, the team did not see the text of the requests, so it could not easily see where the two versions diverged.
The tests did not solve it. The roughly 700 integration tests were coupled to the Python implementation and had to change along with the code; when it audited the ported tests, Anthropic found more than 100 weakened assertions. They were also incomplete by nature: just 20 binary options make more than a million combinations, or 12 days of tests at one second each, for a single model.
The number that sums up the problem: in April, the Rust version passed about 98% of its tests, but only about a quarter of inputs matched on production traffic. Part of the gap came from cases the tests did not cover. One example from the post: in JSON tool calls, Python replaced certain characters, such as an emoji, with text codes, and Rust wrote them as they were; the prompts differed by a few bytes. On top of that, in production a common bug repeats in every request that triggers it.
For anyone running a legacy system, the lesson: green tests do not prove parity; the reference is behavior in production. That is what Ithaca calls correctness in the piece on AI refactoring without losing correctness.
Shadowing: run the new system alongside, on real traffic, and compare step by step
Running the same requests through the old code and the new code and comparing the results is called shadowing. Anthropic used the production system as the reference and adapted the technique in three ways:
- Billed once. Each request counted only once toward the customer's limits and bill.
- The model runs once. To take nondeterminism out of the comparison, the same model output was replayed to the Rust version.
- Step-by-step comparison. Both versions go through the same steps (accept or reject the request, resolve its settings, build the prompt), and the result of each step was compared (checkpointing). The first step that differed showed where to look.
Since nobody could read the text, each difference became a small record of its shape: the step, the piece of the prompt, the byte where it began and the length of each version. This is what Anthropic calls a fingerprint. The same bug tends to leave the same fingerprint on every request it affects, which makes it possible to group the differences.
A script ran every 10 to 30 minutes, grouped the records and alerted a coordinating agent only when a new kind appeared. The coordinator assigned each kind to a worker agent and opened a thread in Slack, where engineers followed along and could steer.
Loops with human review in the middle
Anthropic organized the fixing of differences into verification loops.
Inner loop. Each agent worked in a cloud sandbox, with both codebases and local checks. Starting from the fingerprint, it formed a hypothesis, wrote its own request to reproduce the difference and edited the Rust until the two versions matched. Then it added a test that failed before the fix and passed after it.
The seam between the loops. No fix left the sandbox without PR review. Engineers looked at fixes, not guesses, and answered the questions the verifier could not, such as whether a difference was a bug or a deliberate change.
Outer loop. Once approved, the fix went to a Rust build running on shadowed traffic, and the agents checked whether the fingerprint went away. If it did not, the task went back to the inner loop.
In mid-May, one of the largest remaining differences came from web search: the production API fetched the tool's description from an internal service that Rust did not call yet. An agent proposed copying the text into files Rust could read. The prompts then matched and the fix passed the local verifier, but an engineer turned it down: before launch, Rust would still have to call the service. Anthropic's conclusion: "A verifier can tell an agent whether the outputs matched, but not whether the fix is good enough to ship. That’s why human review was an important gate."
Each fix becomes a rule and a test
The third loop is the memory loop: Anthropic did not want an engineer to make the same correction twice. When the web search shortcut was turned down, the agent saved a note with the decision, the reason and the correct fix. Until Rust called the service, the bug kept producing records, some with new fingerprints, and the agents recognized it from the note instead of writing another workaround.
Other lessons became general rules. In June, an agent went through about 60 of the team's review comments, grouped the recurring problems and proposed rules, which an engineer edited and approved for the CLAUDE.md file. Some became permanent checks, such as tests that fail when Rust drifts from Python and a merge check that requires anyone changing the Python code to make the matching change in Rust or request an exemption.
The result, and what it does not say
According to Anthropic, the Rust Messages API uses about 70% less CPU per request and cuts median time to first token by about 20%, while the service stayed online and feature development kept going. Public traffic moved to Rust in September 2026.
Three caveats apply. It is the company's own account, about its own system, at its own scale. In the post's chart, CPU was measured in one region, and time to first token on customers' Claude Code requests. And the CPU gain comes from moving from Python to Rust, not from the agents; what verification brought, according to the post, was the confidence to switch.
According to the post, as the system matured, the engineers increasingly moved from the inner loop to the edge: writing the rules and checks that agents work within.
What this means for a legacy system migration
A legacy system rarely has the traffic, the tests or the team of the Messages API. But the core problem is the same, and the case raises four questions to answer before rewriting a system with AI:
- What counts as correct? In many production services, it depends as much on behavior as on the tests or the documentation. The signs are in what is a legacy system.
- Can you compare step by step? The final result shows that something differed, but not where.
- Where does human review sit? A verifier can accept a fix that only makes the outputs match.
- Is the correction recorded? At Anthropic, an engineer's correction became a rule, a search for the same mistake and a test. Without some kind of record, the same mistake comes back.
What follows is Ithaca's method, not Anthropic's. Legacy modernization while the system keeps running follows four steps: read, build beside it, check and switch, with the check made against the behavior of the old system, not against the documentation. How to compare and how to switch is worked out case by case, from the assessment. The agentic development platform logs every coding agent session, with the request, steps, model, cost, result and authorship, and before anything goes to production, people review all of it, from Ithaca's team or yours, depending on the project. It operates at level 4 of autonomy, with human supervision and traceability as the rule (what to record is in coding agent observability). An example of modernization with the platform is the Dr. Consulta case, in which Dr. Consulta's own team supervised the coding agents.
Want to migrate a legacy system with coding agents, human review before production and every session logged? Request a free assessment
Frequently asked questions
Can you rewrite a legacy system with AI?
Writing the new code got faster. In Anthropic's case, the first Rust version of the Messages API's core request path took about a week. The hard part is proving that the new system behaves the same as the old one, and that is where most of the work lies.
What is parity in a system migration?
It is the new system responding the same way as the old one to the same inputs, including the cases nobody documented. The reference is behavior in production, not the documentation or the test suite alone.
What is shadowing?
It is running the same real requests through the old system and the new one and comparing the results. Anthropic compared each processing step and grouped the differences by fingerprint, without reading the text of customer requests.
Are passing tests enough to switch systems?
Not necessarily. In April, Anthropic's Rust version passed about 98% of its tests, but only about a quarter of inputs matched on production traffic. Tests cover the cases someone thought of; production brings the others, and repeats a common bug in every request that triggers it.
Where does human review fit in a migration with coding agents?
At Anthropic, no fix left the sandbox without PR review, and an engineer turned down a shortcut that made the outputs match without solving the problem. At Ithaca, before anything goes to production, people review all of it, from Ithaca's team or yours, depending on the project, and every coding agent session is logged.
Sources
- Anthropic. "Migrating our Messages API to Rust". Anthropic Research, 25 Nov 2026. The company's own account. https://www.anthropic.com/research/migrating-api-to-rust

