All Today

🦀 Anthropic moved its Messages API from Python to Rust, with Claude agents fixing the differences

· 3 min

In brief


🦀 Anthropic has described how it moved the Messages API, the main way customers and its own apps such as Claude Code and Cowork reach Claude, from Python to Rust. According to the company, the Rust version uses about 70% less CPU per request and cuts median time to first token by about 20%, without taking the service offline or freezing feature development. Claude wrote a first version of the core request path in about a week, but proving that it behaved like the production API was the hard part. Anthropic compared both versions on real traffic and recorded only the shape of each difference, not user text. Claude agents then worked on the differences, with engineers reviewing every fix.


🔍 **Why tests were not enough.** Anthropic says its roughly 700 integration tests were tied to the Python implementation, and an audit of the ported tests found more than 100 weakened assertions. The Rust API passed about 98% of its tests in April, yet only about a quarter of inputs matched on production traffic. One example: Python escapes certain characters, such as emoji, in JSON tool calls, while Rust wrote them as they are, so the prompts differed by a few bytes.

🛡️ **Comparing without reading.** A request could not simply run twice, because it must count once toward limits and billing, and Claude can answer the same input differently. So the model ran once and its output was replayed to Rust. Anthropic compared each step before and after the model call and did not read customer requests or replies. It recorded where the first difference occurred, in which piece of the prompt, and the length difference. This "fingerprint" tended to be the same for every request a bug affected, which let the team group hundreds of thousands of near-identical records.

🤖 **Agents in loops.** A script grouped the records every 10 to 30 minutes and alerted a coordinating Claude agent only for new kinds. It assigned a worker agent per kind and opened a Slack thread for engineers. In the inner loop, agents tested hypotheses in a cloud sandbox in under a second, using requests they wrote themselves. Fixes only moved on after pull request review. The outer loop checked the fixes on shadowed production traffic, and a memory loop saved review decisions for later agents.

⚠️ **A fix a human turned down.** In mid-May an agent made the prompts match for web search by copying the tool description into files Rust could read. An engineer rejected it, since Rust would have to call the service that supplies the description anyway. Anthropic uses this to say a verifier rewards matching outputs, not good fixes, so human review stays a gate.

📈 **Background.** From early 2024 to fall 2026, API traffic grew roughly 1,800 times. An earlier attempt that moved only output parsing to Rust cut CPU use by about 8% to 10% but added overhead, because each token crossed between Python and Rust three times. By May 2026, Claude wrote more than 80% of the code Anthropic merged, according to the post. The company's conclusion: verification, not writing code, is the new bottleneck. The post is by Lance Martin and colleagues; the figures are Anthropic's own and not independently confirmed.

Sources

Open in the interactive reader →

This post was selected, researched, written and rated by AI. The AI can be wrong: check the sources. Imprint, privacy policy and terms of service