Anthropic moved its Messages API to Rust and compared it with the old version in production
Claude agents tracked down differences in a shadow run that processed the same requests with both versions. The Rust version uses about 70 per cent less CPU time per request than the Python one, the company said.
Traffic on the Messages API grew roughly 1,800-fold between early 2024 and autumn 2026, Anthropic said in a technical blog post published on 25 November. Customers and the company’s own applications, such as Claude Code, use Claude through the API. Python added overhead at every stage of handling a request.
Claude wrote a first version of the core request path in about a week. However, Anthropic did not move public traffic to the Rust version until September, and before that it compared the two versions from April onwards.
Tests alone were not enough. In April the Rust version passed about 98 per cent of its tests, yet on real traffic the input it assembled for the model matched the Python version’s in only about a quarter of requests. The tests missed cases such as this one: in tool call JSON, Python converted characters such as emoji into text codes, while Rust wrote them as they were. The tests ported to Rust also contained more than 100 weakened assertions.
When tests are not enough, the production system itself can verify new code, the blog post said. A shadow run sends the same real requests through both the old and the new code and compares the results. Because Claude can answer the same request in different ways, the model was run once and its response was also fed to the Rust version. Customer requests were not read, so instead of the text, the system recorded the shape of each difference, such as the processing stage, where the difference began and the lengths of the outputs. The same bug usually left the same fingerprint on every request it affected.
A coordinating Claude agent assigned each new kind of difference to an agent of its own. That agent reproduced the difference in a sandbox with a request it had written itself and fixed the Rust code until the versions matched. A fix reached production only after an engineer had reviewed its pull request. The shadow run then showed whether the fingerprint had disappeared.
The comparison could not show whether a fix was good. The Rust version’s prompts lacked the description of the web search tool, because the version did not yet call the internal service that provides it. An agent copied the text into files, which made the prompts match. An engineer rejected the workaround, however, because it did not solve the problem. Engineers’ corrections were recorded as rules that later agents read.
According to Anthropic’s own measurements, the Rust version uses about 70 per cent less CPU time per request, and median time to first token fell by about 20 per cent. The CPU figure was measured in one region, and the latency over a shorter period from customers’ Claude Code requests. A post on X by the Latent Space podcast said memory use per request fell by more than 80 per cent and that 99.6 per cent of inputs matched in August. The blog post’s text does not mention these figures.
Read more: How an agent works · Agent map