Claude Agents Rewrite Anthropic's API in Rust, Cutting CPU Use 70%
Live traffic was the exam: the share of real requests the new code answered exactly like the old one climbed from 6.5% to 99.6% before the switch.

Claude wrote a first version of the core of Anthropic's new API in about a week. Proving that it behaved exactly like the old one took from April to September, and that proof is the real story. On November 25, Anthropic's engineers published how teams of Claude agents moved the Messages API, the door every customer and every Claude Code session walks through, from Python to Rust while it kept serving traffic. The new version uses about 70% less CPU per request and cuts the median wait for the first token of a reply by about 20%.
1,800 Times the Traffic, One Week of Code
Anthropic built the Messages API in 2023, in Python. From early 2024 to fall 2026 its traffic grew roughly 1,800 times. Every request passes through validation, prompt building, tokenization and safety classifiers, and Python adds a little overhead at each step. Multiply a little by 1,800 and it becomes a fleet of servers.
The team tried the cautious route first. In March 2026 it rewrote only the response-parsing code in Rust and saved 8 to 10% of CPU. The catch was structural: each token of a reply now crossed between Python and Rust three times, and the gain did not justify the extra complexity.
Then the math of effort changed. By May 2026 Claude was writing more than 80% of the code Anthropic merged, and it produced a first version of the API's core request path in about a week. Writing the new system had stopped being the hard part.
“Verification, not generation, had become the bottleneck.”— Anthropic engineering team
Which raised the real question: how do you prove a rewrite is correct when no document anywhere spells out what correct means?
The Old API Became the Answer Key
The obvious answer was tests, and Anthropic had about 700 integration tests. They turned out to be shaky ground. They were written around the Python code, and an audit of the ported versions found more than 100 weakened assertions, tests quietly bent so that wrong code could pass. They were also incomplete: 20 on-off options alone make more than a million combinations.
So the engineers made the old Python API the judge. Real production requests ran through both versions. The model ran once and its output was replayed through Rust, so randomness in the model never looked like a bug and nobody was billed twice. The system never read user text. It logged only the shape of each difference: which step, which piece of the prompt, the first byte that differed and the lengths.
The first readings were humbling. In late April about 98% of tests passed, yet only 24% of real inputs matched. As the comparison widened, the rate fell to 6.5% in early May. Then the fixes started landing.
A single bug could leave hundreds of thousands of near-identical records in the logs. Someone had to chase every one of them.
Agents in Slack, Humans at the Gate
That someone was mostly Claude. Every 10 to 30 minutes a script grouped the difference records by kind and alerted a coordinating Claude agent whenever a new kind appeared. The coordinator handed each new kind to a worker agent with its own Slack thread, where engineers could follow along and steer.
Each worker had a sandbox with both codebases and checks that ran in under a second. It guessed a cause, wrote a request that reproduced the mismatch, edited the Rust until both versions agreed and added a test that failed before the fix and passed after. Engineers reviewed every change, and fixes then went back to shadowed live traffic. Corrections became rules in a shared memory file, in tests and in lints; in June an agent grouped about 60 review comments into proposed rules. By August the team was merging more than 3,000 changes every two weeks, up from fewer than 100 when the work began.
The humans earned their place. In mid-May an agent traced one of the largest remaining mismatches to the web search tool and proposed a shortcut that would have been thrown away before launch. An engineer said no. "A verifier can tell an agent whether the outputs matched, but not whether the fix is good enough to ship," the team wrote.
Public traffic moved to Rust in September without the service ever going offline or freezing new features. Every developer calling Claude now waits less for the first token, and Anthropic serves more requests from the same machines. The lesson travels to any company sitting on an old codebase it is afraid to touch: the code took a week, the proof took five months, and agents can now help write the proof too.
Five Months From 6.5% to 99.6%
The Brief
Stay curious
AI and technology: what changes and why it matters.
Your daily selection, in English or Spanish.
Free forever. Unsubscribe anytime.
More stories

The Specialty News





Conversation
Start the conversation