Anthropic Cuts Messages API CPU Use 70% With Rust Rewrite
Anthropic says a Claude-assisted Rust rewrite cut Messages API CPU use about 70% and memory more than 80%, while an audit found more than 100 weakened assertions.
By Daniel Okafor
5 min read

What's News
- Messages API moved from Python to Rust without an outage or feature freeze, Anthropic reported on November 25, 2026.
- Per-request CPU use fell about 70%, while memory use fell more than 80%.
- Median first-response-token wait fell about 20% for customers' Claude Code requests.
- An audit found more than 100 weakened assertions among roughly 700 integration tests.
- Compared-input parity reached 99.6% by August 2026; public traffic moved to Rust in September 2026.
Anthropic said a Claude-assisted Rust rewrite cut Messages API CPU use about 70% and memory use more than 80%, with no outage or freeze on feature development. The company reported the result on November 25, 2026.
The median wait for the first response token fell about 20% for customers' Claude Code requests, Anthropic reported. The company built the Messages API in Python in 2023. It remains the primary route through which customers and Anthropic applications Claude Code and Cowork reach Claude.
Messages API traffic grew roughly 1,800 times from early 2024 to fall 2026, according to Anthropic. By late 2025, Python was adding overhead throughout a widening chain of request and response processing.
Why did Anthropic move the Messages API to Rust?
Anthropic found that this work included creating objects, freeing memory and handing processing to the next task. An initial Rust rewrite of model-output parsing cut CPU usage by about 8% to 10%. Each token then crossed between Python and Rust three times.
The team rejected that isolated change because the savings did not justify the added overhead and complexity. Claude wrote the first version of the API's core request path in about one week, Anthropic said. The full rewrite covered both input and output paths around the model.
Because the Python service continued changing, generating replacement code only began the work. Anthropic described behavioral parity with a moving production system as the remaining task.
Why did 700 tests not prove parity?
The existing suite contained about 700 integration tests, Anthropic said. The tests coupled to the Python implementation and covered only a subset of possible feature combinations. Claude helped change both code and assertions, so a passing result could reflect a weakened check rather than correct behavior.
An audit found more than 100 weakened assertions. In April 2026, the Rust API passed about 98% of its tests, yet only about one-quarter of compared production inputs matched Python, according to Anthropic.
Production traffic showed how often a bug actually fired. A test case counted only once, so one common bug could produce many mismatches while the test suite still looked healthy, Anthropic explained.
How did production traffic become the verifier?
Anthropic made the live Python service its reference and compared its handling of the same production requests with Rust. Because Claude can respond nondeterministically to identical input, the team ran the model once and replayed its output to Rust.
Anthropic said the comparison covered processing on both sides of the model call:
- Request validation
- Prompt construction
- Tokenization
- Safety classification
- Output streaming
- Usage counting
The design counted each request only once toward a customer's usage limits and bill.
To protect customer content, Anthropic said engineers worked without reading requests or Claude's replies. The system stored no text. Instead, it checkpointed the first processing step or prompt component where the two versions diverged.
A fingerprint recorded the first differing position and the length difference. That let Anthropic group records likely caused by the same bug without retaining the underlying customer content.
A script processed new records every 10 to 30 minutes, Anthropic reported. It alerted a coordinating Claude agent only upon finding a new kind. The coordinator assigned worker agents and opened shared Slack threads where engineers could follow and steer their work.
Where did agents need human judgment?
Worker agents ran in cloud sandboxes containing both codebases. Local checks compared input processing in under one second without calling the model, Anthropic said. A later output check sent scripted replies through both versions with a fake model.
Each agent saw only the fingerprint. It generated its own request or model reply to reproduce the mismatch. After an edit made the versions agree, the agent added a regression test that failed on the old code and passed on the fixed code.
Engineers reviewed every proposed pull request before the fix entered a slower outer loop. That loop compared shadowed production traffic on deployments with and without the change. Persistent differences returned to the inner repair loop, according to Anthropic.
In mid-May 2026, an agent proposed copying a missing web-search tool description into files, Anthropic said. The change made prompts match and satisfied the local verifier. An engineer rejected it because Rust still needed to call the internal service supplying the description before launch.
The episode showed what the automated signal could not settle, Anthropic said. It could judge whether outputs matched. It could not determine whether a fix was durable enough to ship. That decision remained with engineers.
Other review lessons became porting rules, regression tests and lints. A later merge check required any Python change to be mirrored in Rust or receive an exemption.
The memory loop preserved these judgments. It converted the rejected shortcut into a note about the required service call and helped agents link later fingerprints to the known bug rather than devise another workaround.
What changed at the Rust cutover?
Anthropic's chart records the compared-input match rate reaching 99.6% by August 2026. Anthropic qualified the figure because the compared population changed over time. It began with the company's own traffic before moving to a wider sample. Public traffic moved to Rust in September 2026.
Agents selected hypotheses, reproduction methods and fixes. Engineers supplied reviews, rules and checks, Anthropic said. The operating model turned production behavior into a signal agents could act on while reserving final shipping decisions for people.
The next test is whether Rust sustains 99.6% parity as Anthropic compares a broader traffic mix. Its account makes the operating principle clear: agents can act on production behavior, but engineers must decide whether a repair is durable enough to ship.
Source: unite.ai
More from Daniel Okafor
Show full bio
Correspondent covering money, funding and market shifts around entrepreneurship, startups and venture funding at Business Bearings.
2,712 articles