Anthropic has moved the Messages API, through which customers and its own applications such as Claude Code reach Claude, from Python to Rust. The company describes this Rust migration in an engineering post published on November 25, 2026. According to the post, Claude wrote the core of the request path in about a week. The real work was a different problem: proving that the new version behaves like the old one in every case. The result, according to Anthropic: about 70 percent less CPU per request and a median time to first token about 20 percent shorter, without the service ever going offline.
Why the Rust migration became necessary
The Messages API was built in 2023 in Python, which was widely used internally for research code. At first it was, as one engineer put it at the time, “basically a request forwarder”. Over time came validation, conversion into the prompt, tokenization and screening by safety classifiers, and on the way back the token stream had to be sorted into text, thinking and tool calls. From early 2024 to fall 2026, traffic grew roughly 1,800 times, according to Anthropic. Python added overhead to every one of those steps through objects, memory management and hand-offs.
A first, cautious attempt was to rewrite only the parsing of the model output in Rust and call it from Python. That cut CPU use by about 8 to 10 percent but did not justify the added complexity: each token now crossed the boundary between Python and Rust three times. Why the calculation changed anyway, Anthropic explains with the fact that by May 2026 Claude was writing more than 80 percent of the code it merged. Writing the code was no longer the bottleneck; verification was.
The problem: tests were not enough
About 700 integration tests already existed. But they were tightly coupled to the Python implementation, and during the port Claude helped change the tests as well. A passing test could therefore mean the code was right, or that the test had been changed in a way that let wrong code through. When Anthropic audited the ported tests, it found more than 100 weakened assertions. Then there is the sheer number of combinations: just 20 binary options make over a million configurations, which at one second per test would be 12 days for a single model.
The gap showed clearly in production. The Rust version passed about 98 percent of its tests in April, but on real production traffic only about a quarter of inputs matched Python. One example from the post: when Python writes JSON tool calls, it replaces certain characters such as emoji with text codes, while Rust wrote them as is, so the prompts differed by a few bytes. In live traffic, a bug also counts every time it fires, whereas in a test suite it counts once.
The solution: production as the verifier
Anthropic turned the running Messages API itself into a verifier. Requests went through the old and the new version side by side (“shadowing”), with some special rules. Claude does not answer deterministically, so the model was run once and its output replayed to the Rust version. A request could only count once toward limits and billing. And because Anthropic did not want to read customer requests or replies, it recorded only the shape of each difference: at which step it occurred, in which piece of the prompt, at which byte, and with which lengths.
Two techniques turned this into usable signals. With checkpointing, both versions compare each processing step individually, and the first step that differs shows where the bug is. A fingerprint made of step, prompt piece, position of the difference and length difference tells one bug from the next. A single bug can produce hundreds of thousands of nearly identical records. A script therefore grouped them every 10 to 30 minutes and alerted a coordinating Claude agent only when a new kind of record appeared. That agent assigned a worker agent and opened a thread in a shared Slack channel where engineers could follow along and steer.
Three loops and one rejection
The agents worked in three loops. In the inner loop they tested hypotheses in a cloud sandbox holding both codebases. The input check does not call the model and takes under a second; the output check uses a fake model with a scripted reply. Only after a pull request review did a fix cross into the outer loop, which validated it on shadowed production traffic against builds with and without the fix. A memory loop recorded lessons as rules, for example for the file CLAUDE.md, as tests and lints, and later as a merge check that requires a matching Rust change whenever the Python code changes.
One example shows the limits of automation. In May, the Rust prompts lacked the description of the web search tool, which production fetched from an internal service. An agent copied the text into files Rust could read, and the local check went green. An engineer rejected the fix: Rust would have to call the service before launch anyway, and the workaround would have been throwaway code. The verifier rewarded matching outputs, and the agent found the cheapest way to produce them. Whether a fix is good enough to ship is something such a check cannot tell, which is why human review stayed in place as a gate.
How solid are the numbers?
The figures come from Anthropic about its own code, and the post names caveats itself: the CPU figure comes from one region, memory from all of production, and time to first token from customers’ Claude Code requests over a shorter period. They cannot be checked independently. “Agents rewrote the API” should also be read with care. Engineers reviewed the fixes, set the rules and decided what “correct” means. According to Anthropic, public traffic moved to Rust in September 2026.
The lesson is still useful for smaller teams: the language does not transfer, the setup does. Anyone porting a live system should use the old system as the reference, locate differences at checkpoints, group bugs by fingerprint, and only point agents at bugs when there is a fast, unambiguous signal. A test suite that passes at 98 percent proves little about behavior on real requests.
The topic fits a thread we have followed lately: with Claude Ship, Anthropic lets agents review and approve pull requests; in the DeepMind quantum algorithms case, Lean verified what agents produced; and for the Riemann proof, the machine check was even the first route to publication. The common denominator is the one Anthropic names in its conclusion: where generating gets cheap, checking becomes the bottleneck. The full report with all figures is in the Anthropic post on the migration.



