Anthropic has moved the Messages API, the service every Claude request passes through, from Python to Rust. In an engineering post published on November 25, the company said teams of Claude agents wrote and repaired much of the new code, and that the Rust version now uses about 70% less CPU per request and trims median time to first token by about 20%. The more interesting part is not the speed-up but how Anthropic proved the new system behaved like the old one.
Key takeaways
- Anthropic’s Messages API now runs on Rust; public traffic switched over in September 2026.
- Claude produced a first version of the core request path in roughly a week, but proving parity with Python took months.
- Anthropic reports about 70% less CPU and more than 80% less memory per request, plus a roughly 20% faster median time to first token for Claude Code requests.
- The live Python API acted as the “oracle”: agents chased differences between the two versions, and engineers reviewed every fix before it shipped.
- Anthropic’s main lesson for builders: writing code is no longer the hard part, verifying it is.
What happened
The Messages API launched in 2023 as a fairly thin Python service. Anthropic says one engineer at the time described it as little more than a request forwarder. Since then the job has grown a lot: each request is now validated, turned into a prompt, tokenized and checked by safety classifiers, and each reply has to be split into text, thinking and tool calls as it streams back. Anthropic says traffic on the API grew roughly 1,800-fold between early 2024 and fall 2026, and Python’s per-object overhead was adding cost at every step.
The team first tried the textbook approach and rewrote only the hot path, the code that parses model output, in Rust. That cut CPU use by around 8% to 10%, but every token then had to cross the Python–Rust boundary three times. Anthropic decided the extra complexity was not worth the gain and went for a full rewrite instead. According to the post, by May 2026 Claude was already writing more than 80% of the code Anthropic merged, so generating a Rust version was no longer the blocker. The Next Web and Unite.AI both report the same core figures from the company.
Why the tests were not enough
Anthropic had about 700 integration tests, and by April the Rust build passed about 98% of them. Yet when the team compared both versions on real production traffic, only around a quarter of inputs matched. Two problems explain the gap.
First, the tests were tied to the Python implementation, so they had to be ported too, and Claude helped with that. A passing test could therefore mean correct code or a test that had quietly been loosened. When Anthropic audited the ported suite, it found more than 100 weakened assertions. Second, no test suite covers every combination of features. Anthropic points out that just 20 on/off options produce over a million combinations. Real traffic also surfaced tiny quirks, such as Python escaping certain characters like emoji in JSON tool calls while Rust wrote them as-is, leaving prompts a few bytes apart.
How Anthropic verified the rewrite
The answer was to use the production Python API itself as the judge, a technique usually called shadowing. That came with three complications: billing and rate limits must only count a request once, Claude can answer the same prompt differently each time, and Anthropic says it could not read customer requests or replies. So the model ran once, its output was replayed into the Rust path, and both versions were compared at each step before and after the model call.
Instead of logging text, the system logged the shape of each mismatch: which step diverged, which piece of the prompt, the first byte that differed and the lengths on each side. Anthropic found that a given bug tends to leave the same “fingerprint” on every request it touches, so mismatches could be grouped and triaged without exposing user content.
From there, Anthropic ran three loops:
- Inner loop: a coordinating Claude agent handed each new kind of fingerprint to a worker agent running in a cloud sandbox with both codebases. The worker wrote its own request or fake model reply to reproduce the difference, edited the Rust until local checks matched, and added a regression test. Input comparisons took under a second.
- Outer loop: after an engineer approved the pull request, the fix was deployed and shadowed live traffic showed whether the fingerprint disappeared. If it did not, the work went back to the inner loop.
- Memory loop: reviewer corrections became written rules that every later agent read first, plus lints, tests and a merge check requiring matching Rust changes when Python code changed.
Human review mattered. In one example from May, an agent “fixed” a missing web search tool description by copying the text into files Rust could read. The outputs matched, but an engineer rejected it as throwaway code, since Rust would have to call the real internal service before launch anyway. The verifier rewarded matching outputs; only a person could judge whether the fix was worth shipping. The match rate on compared inputs eventually climbed to about 99.6% before the switch.
Why it matters
For anyone calling Claude, the direct effect is a leaner serving layer: Anthropic says it moved traffic with no downtime and no freeze on new features. Lower CPU and memory per request means the same hardware can serve more calls, which matters as the company scales after its recent IPO. Faster time to first token is something Claude Code users will feel in day-to-day use.
The bigger signal is about how large rewrites get justified. Full rewrites have long been avoided because they are expensive and risky. Anthropic’s argument is that AI agents have collapsed the cost of writing the code, so the deciding factor becomes whether you can build a strong enough check on the result. It follows other agent-driven work the company has shown off, such as Claude Ship for reviewing and fixing pull requests.
What it means for developers and engineering teams
- Be wary of “tests pass” after an AI port. If an agent edits both code and tests, audit the tests separately. Anthropic’s 100-plus weakened assertions are a clear warning.
- Your running system can be the spec. For services with poor test coverage, shadowing live traffic against the old version can expose behaviour that nobody wrote down.
- Design the error signal, not just the check. Pinpointing where and how two outputs differ gave agents something actionable, while keeping user data private.
- Put people at the review seam. Let agents iterate freely in a sandbox, but require human approval before a fix touches production.
- Turn corrections into rules. Saving reviewer feedback to shared instructions (Anthropic used CLAUDE.md) stops agents repeating the same mistake.
Keep the caveats in mind. The performance numbers come from Anthropic alone, and its own charts note the CPU figure is from one region, memory covers all of production, and the latency figure covers Claude Code requests over a shorter window. The approach also relied on conditions many teams lack, such as large volumes of comparable traffic and the ability to replay a single model call into two systems.
What to watch next
Anthropic says migrations like this are becoming practical for performance or security reasons without taking services offline. Watch for whether it publishes tooling or more detailed guidance from this project, whether other API providers describe similar agent-led rewrites, and whether independent latency measurements back up the reported gains. For engineering leaders, the practical question is no longer “can an agent write this?” but “how will we know it is right?”