On November 25, 2026, Anthropic published an account of how it moved the Messages API, the main gateway to Claude, from Python to Rust. Regular customer traffic was switched over in September. According to the company, CPU usage per request fell by about 70%, and the median time until the first token arrives dropped by about 20%. Claude wrote a first version of the core logic in about a week. But in April, even when about 98% of tests passed, only about a quarter of production inputs sent to the model matched between the Rust and Python versions. What carried the migration was a mechanism that used the still-running old version as the baseline, searched for differences without reading customers' conversations, and verified fixes.
The performance figures come with limits on what was observed. The CPU figures cover one region, while the latency figures cover customers' Claude Code requests, over a shorter observation period. The published charts show seven-day averages before and after the migration. The total cost and effort of the migration, and the cost of running the agents, have not been disclosed.
98% of tests passed, but only about a quarter of inputs to the model matched in production
The Messages API does far more than relay traffic to the model. It validates input, assembles prompts (the text passed to the model) from instructions and conversations, and splits them into the units the model handles. It also runs safety classification, and when a response comes back, it sorts the output into ordinary text, reasoning, and tool calls. According to Anthropic, API traffic on the platform, including its own use, grew about 1,800-fold between early 2024 and autumn 2026.
In Python, each of these stages carried overhead from creating objects, freeing memory, and handing work to the next task. Anthropic first rewrote only the part that parses model output in Rust and called it from Python. That cut CPU usage by about 8–10%, but the setup crossed the Python–Rust boundary three times for every token of a response. The partial speedup came with the complexity of linking two languages.
There were about 700 tests available for trying a full migration. However, they ran the Python API in the same process as the tests, and the services that manage billing and usage limits were stood in for by placeholder logic held in Python memory. Moving to Rust meant rebuilding the tests along with the main code.
Claude rewrote both. That made it hard to tell whether a passing test meant the main code was correct, or whether the tests had changed in a way that let errors slip through. A post-migration audit found that more than 100 verification conditions had become weaker than in the originals. Combinations of features also multiply. In an example Anthropic gave, 20 simple on/off settings produce more than a million combinations.
The April figures, "about 98%" and "about a quarter," describe different sides of this problem. The former is measured against test cases; the latter against production requests whose inputs to the model were compared between the old and new versions. Each test case counts once, but in production, if the same bug sits in a frequently used feature, the mismatch shows up on every request.
The differences looked small. When representing tool calls as JSON, Python converted some characters, such as emoji, into character-code notation, while Rust output them as the characters themselves. This created a difference of a few bytes in the text passed to the model. Because Claude accepts a wide range of text, such differences, and even missing parts of a prompt, do not necessarily cause errors, and the model still returns a response. Confirming that processing succeeded did not show whether the same input had been passed as before.
Running inference once and tracking differences without reading content
Anthropic processed the same production requests in both Python and Rust and compared the results stage by stage before and after the model call. But calling Claude twice can naturally produce different responses even from the same input. So the model was run only once, and its output was replayed on the Rust side. Usage-limit accounting and billing also had to happen only once per request.
Comparing old and new in production has precedent. In GitHub's explanation of Scientist, a comparison library it released in 2016, the existing and new code paths both ran, results and timing were compared, and the caller received the result of the existing path. GitHub said at the time that it excluded operations such as database writes, where running twice would affect production, and used the approach only for read operations.
| Comparison condition | GitHub's Scientist (2016 description) | Messages API migration (2026 report) |
|---|---|---|
| Old and new processing | Runs both and returns the existing path's result | Compares the production Python and Rust versions stage by stage |
| Handling of results-affecting steps | Records comparable results and timing | Runs inference once and replays the same model output to Rust |
| Impact on users | Excludes operations with side effects such as writes | Billing and usage-limit accounting happen once |
| Information used to examine differences | Result differences and exceptions | Records where differences arose and their length instead of customer content |
Note: Comparison conditions as described in GitHub's post ("Enter Scientist" and "Caveats") and Anthropic's report ("Detecting parity with production").
The 2016 Scientist also compared old and new in production. In the Messages API migration, though, inference was run only once and the same output replayed, and clues for fixes were built from the position and length of differences. To make production comparison work for an LLM API, the outputs being compared have to be aligned, and operations that affect users must not be duplicated. Both need to be designed together.
To get closer to causes without reading customers' requests or Claude's replies, the comparator followed the processing steps. It compared in order whether input was accepted, how settings were resolved, and how the prompt was assembled, then identified the first stage where a difference appeared and the part of the prompt involved. It added the position and length of the first divergence and recorded these as the "features of the difference."
This record serves as a clue for finding the code that needs fixing. Because one bug produces large numbers of similar differences, a script aggregated the records every 10 to 30 minutes and notified a coordinating Claude only of new types. The coordinator assigned an agent and created a shared Slack thread where human engineers could follow progress.
What the assigned agent sees is not customer content but the features of the difference. It reasons about the cause from the code, writes its own requests and model responses, and tries to reproduce the same difference. With self-made data, the two results can be compared in full.
To speed up trials, each agent's isolated environment held the old and new code and a local comparator. On the input side, prompts are assembled without calling a real model, so a comparison finishes in under a second. On the output side too, agents tested with a mock model that returns predetermined responses. Checks that used to require code review and deployment to a test environment for each hypothesis, taking hours to days, could now be repeated in the agent's own environment. Once a difference was reproduced and the Rust code fixed, a test was added that failed before the fix and passed after.
Whether to adopt a fix that matches
In mid-May, a problem was found in which the description text of the web search tool was missing from the prompt. Python fetched the description from an internal service, but Rust had no such call. The agent copied the missing text into a file and produced the same output as Python.
That satisfied the comparator. But an engineer rejected the approach. Before going to production, a process to call the internal service would have to be implemented anyway, and the substitute using copied text would be discarded. Being able to produce the same text is different from being able to keep up with the mechanism that supplies the description. If matching output is the only reward, an agent may choose the easiest way to create a match.
Human code review was placed between trials in the isolated environment and verification in production. Engineers judge whether a difference is a bug or an intended change, and whether a proposed fix can be maintained over time. Reviewed fixes were verified by running builds with and without the fix on production comparison traffic.
In doing so, the team recorded the models and API features used in place of content. For example, it compared requests with the same model and the same prompt caching and tool conditions to see how often the problematic difference appeared. If cases missed in self-made inputs or differences between local and production settings remained, the assigned agent returned to the isolated environment and rebuilt its hypothesis.
The reasons for rejected fixes were also kept for later work. For the web search problem, building the process to call the internal service took several weeks. In the meantime, if the missing description appeared at a different position in the prompt, or went missing in another tool using the same service, differences with different features appeared. Features and bugs do not map one to one. By reading the saved reasoning, other records could be linked to known problems, avoiding repeated proposals of the same substitute.
In June, agents extracted recurring problems and working rules from about 60 review comments, and engineers edited and approved them into CLAUDE.md, the instruction file for agents. Some of the lessons also became tests that catch divergence from Python and checks that detect frequently flagged coding patterns. In addition, a merge-time check was introduced requiring that any change on the Python side come with a corresponding Rust change or an exception request. This is the mechanism that lets the new version keep up with an old version that keeps changing during the migration.
Where to place the criterion for judgment
When moving Bun, a runtime that executes JavaScript and more, from Zig to Rust, tests written in TypeScript were used. In Bun, existing tests could be applied to both old and new, whereas for the Messages API the tests themselves had to be ported, and the production Python version, which kept being updated, became the comparison baseline.
In his July 8 account of the port, Bun developer Jarred Sumner explains that the automated tests on all six platforms passed and that he manually confirmed the tests were actually running and not being skipped. The difference between the two lies in how independent the judgment criterion could be kept from the code being ported.
| Subject | Baseline for comparing old and new | Additional checks on the baseline |
|---|---|---|
| Bun | Existing TypeScript tests shared by the Zig and Rust versions | Runs on 6 platforms and manual confirmation that tests were not skipped; merging to main and product release decided separately |
| Messages API | About 700 integration tests that depend on the main code, plus the live Python version | Replay of the same model output and stage-by-stage comparison; human review of proposed fixes and re-verification in production |
Note: Verification conditions as described in Bun's July account and Anthropic's November report.
Bun also saw 19 known regressions from the port, meaning functionality that previously worked broke, and fixed each one. Even with shared tests, passing them alone cannot guarantee all behavior. Sumner separated merging to main from versioned product releases, and continued security reviews and fuzzing, which hunts for bugs with varied inputs, after the merge. Bun is also part of Anthropic, and both are process records from the parties who did the porting.
Measuring against the old version tells you whether behavior users have relied on is preserved. Whether the old version's own design is sound remains a judgment for human review. When pursuing an AI-driven port of another system, the things to check first are whether there is a criterion independent of the rewrite, which operations would affect users if executed twice, and how far differences can be recorded without reading content. If those conditions are set and the differences found can be fed back into reproduction and fixes, the speed of writing code can be turned into the ability to move a live service.
