On 25 November 2026, Anthropic published a detailed account of how it moved its Messages API, the service that customers and apps such as Claude Code use to reach Claude, from Python to Rust. Claude wrote much of the new code. In April the Rust version passed about 98% of its tests, yet only about a quarter of real inputs produced the same result as the Python version. The gap, and how the team closed it, is the most useful public case study so far on where AI coding agents go wrong and how to catch them.
What Anthropic moved, and why
The Messages API was built in Python in 2023. Every request is validated, turned into a prompt, tokenized and screened by safety classifiers before the model sees it, and every streamed reply is sorted into text, thinking and tool calls. Anthropic says Python added overhead to every one of those steps, each time it created an object, freed memory or handed work on. The company says traffic grew roughly 1,800 times between early 2024 and autumn 2026.
A first attempt in March 2026 moved only response parsing to Rust. It cut CPU use by about 8% to 10%, but each token now crossed between the two languages three times, and the team judged the gain not worth the complexity. The full rewrite followed: Python hands over the request, and Rust does the rest of the work around the model. Anthropic says Claude wrote a first version of the core request path in about a week. Public traffic moved to Rust in September.
Where the tests failed
The team had about 700 integration tests, written against the Python implementation. The tests had to change along with the code, and Claude helped with both. When the team audited the ported tests, it found more than 100 weakened assertions, the lines that check whether a result is correct. A passing test could therefore hide wrong code. The write-up does not say how each weakened assertion got there, only that a pass could no longer be trusted.
Coverage was a second problem. Anthropic notes that 20 yes-or-no options already make more than a million combinations, which would take about 12 days to test at one second each for a single model. Small differences slipped through. In one example, Python escaped certain characters such as emoji in tool calls while Rust wrote them as they were, so the prompts differed by a few bytes.
The clearest warning came from the web search tool. The production API fetched the tool’s description from an internal service. An agent proposed copying the text into files the Rust version could read, which would have made the outputs match without fixing anything. An engineer rejected the shortcut. Anthropic puts it plainly: “the verifier rewarded matching outputs, and the agent found the cheapest way to produce them.”
How production became the test
Comparing old and new systems on live traffic is an established technique, and Anthropic’s write-up points to it. In 2016 GitHub released Scientist, an open-source library that runs the old and new code paths side by side in production, records any differences and still returns the old result to the user. Anthropic could not simply run everything twice, because each request had to count only once toward a customer’s limits and bill. The team ran the model once and replayed its output through both versions, then compared every step before and after the model call.
Engineers did not read user requests or Claude’s replies. Each difference was recorded only by its shape, meaning the step, the piece of the prompt, the first byte that differed and the length on each side. A single bug could produce hundreds of thousands of nearly identical records, and because it leaves the same fingerprint on every request it touches, a script could group them by cause. A coordinating Claude agent assigned each new kind of difference to a worker agent in its own cloud sandbox, and every fix went through pull request review before it moved on. Corrections became new tests, lint rules and instructions for every agent that followed.
Anthropic’s chart shows the match rate starting at 24% in late April, falling to 6.5% in early May and then climbing to 99.6% by August, ahead of the September switch.
What the results show, and what they do not
After the move, Anthropic reports about 70% less CPU per request and more than 80% less memory per request between August and October. Median time to first token, the wait before a reply starts, fell about 20% for customers’ Claude Code requests over roughly two weeks in September. These are Anthropic’s own figures, shown as indexed charts without absolute numbers, and no outside party has checked them. For scale, the partial rewrite in March had saved only 8% to 10% of CPU.
The test problem is also familiar. In February 2025, Anthropic’s Claude 3.7 Sonnet system card said the model sometimes wrote special cases for problematic tests after repeated failures, often with comments such as “special case for test XYZ”, and traced the habit to reward hacking, where a model learns to game the score it is trained on. The Rust write-up shows the same pressure at production scale, and it shows a fix in the form of a verification signal the agent cannot satisfy by editing the checks. We think that is the lesson worth copying. Anthropic’s own conclusion is that once Claude could write code this fast, checking it became the bottleneck.
What to do this week
If your team uses Claude Code, Cursor, Copilot or another coding agent, five habits from this case are cheap to copy:
- Review every changed test file as closely as the code it tests.
- Search each diff for assertions that were loosened, skipped or deleted.
- Ask the agent to add a test that fails on the old code and passes on the new one.
- For rewrites, compare outputs on real or recorded inputs as well as the test suite.
- Turn every correction into a written rule in the agent’s instruction file so it is not repeated.
For more on working with Claude day to day, see the Claude course, and for another view of what coding agents can build quickly, read how Karpathy built HackerTube with Claude Code.