01Watch & read
Claude Helped Rewrite Anthropic’s API in Rust — The 98% Test Trap
26 Nov 2026 · 11:58
Watch on YouTube ↗Anthropic says its Messages API rewrite to Rust cut CPU per request by about seventy percent, but passing nearly all tests still left most compared production inputs mismatched. The engineering account shows why comparing against the old service mattered more than generating code alone. Sources: https://www.anthropic.com/research/migrating-api-to-rust https://news.ycombinator.com/item?id=50646357 https://www.reddit.com/r/ClaudeCode/comments/1y5gsx1/anthropic_moved_its_messages_api_from_python_to/ https://www.reddit.com/r/Anthropic/comments/1y5gsx8/anthropic_moved_its_messages_api_from_python_to/
Chapters
Commands & links
Article
The Gap
Anthropic says its Rust rewrite cut CPU per request by about seventy percent. But at one point, passing ninety-eight percent of tests still matched only about a quarter of production inputs. That gap is the part builders should pay attention to. A test suite can be green while real users still get different behavior.
Anthropic published this engineering account on November twenty-fifth, twenty twenty-six. It describes moving the Messages API from Python to Rust, with Claude agents doing much of the implementation work. Anthropic says Claude was writing more than eighty percent of the code it merged by May twenty twenty-six. That figure tells us agents were deeply involved in implementation.
It doesn't tell us the rewrite was autonomous. For that, we need to look at how the team checked the new service. The Messages API is the service that handles messages sent to Claude. A rewrite like this must preserve the behavior callers already depend on.
That behavior includes ordinary requests, edge cases, and details callers may never have documented. The new service can compile and answer requests while still changing those details. So the core migration question isn't only whether Rust works. It's whether it behaves like the service it replaces.
The team chose Rust for a production service, then moved public traffic to it in September twenty twenty-six. That makes this a real service migration, not a toy rewrite or a benchmark exercise. The old Python implementation was still useful after the new one existed. It provided a reference for what the system actually did on incoming requests.
That reference becomes essential when written tests don't cover enough of the production surface.
The Results
Anthropic reports about seventy percent less CPU per request. That's the headline efficiency result, according to the company. The post says this CPU figure covers one region, so it isn't a universal number across every region. Still, it suggests the rewrite made each request less demanding on the measured service.
It also reports more than eighty percent less memory per request. That measurement covers production, according to the account. Lower memory use can matter in a busy service because it changes the resources each request consumes. But the post doesn't give us a single combined score for CPU, memory, and latency.
These are separate measurements with separate scopes. And median time to first token was about twenty percent lower. Anthropic says that figure covers Claude Code requests over a shorter period. Time to first token describes how quickly the first part of a response arrives.
A lower median can improve perceived responsiveness, though it doesn't describe every request or the full response time. Keep the population and time window attached to the claim. These numbers don't all describe the same slice of the system. CPU covers one region.
Memory covers production. Latency covers Claude Code requests over a shorter period. So it's fair to say Anthropic reports improvements across three measures. It's not fair to flatten them into one controlled, same-scope comparison.
The account also doesn't isolate how much came from Rust and how much from Claude's involvement. The numbers are Anthropic's measurements. The migration changed the implementation language, and Claude helped write the code. Because the post doesn't separate those contributions, this isn't evidence that Claude itself caused the performance gains.
It's evidence that the team used Claude during a migration that Anthropic says improved these service metrics.
The Test
Now for the surprising part: in April, the Rust version passed about ninety-eight percent of its tests. Yet only about a quarter of the compared production inputs matched Python. Those figures sound contradictory until we ask what each measurement represents. The tests covered cases the team had encoded.
Production comparison covered inputs the live service had actually received. A high score on one set didn't guarantee broad behavioral parity. Those figures measure different things. Tests check cases someone wrote down.
Production comparison checks what the existing service actually did. A test suite can be valuable and still have gaps. The mismatch rate exposed those gaps before the team treated the rewrite as equivalent. This is why a green checkmark needs a clear boundary: which behavior did it check?
That doesn't mean the tests were useless. It means they didn't cover enough of the behavior that production traffic exposed. And the production match figure changed as the team fixed issues. Anthropic also says the traffic sample and comparison method changed over time.
So treat the April numbers as a moment in the process, not a final score for the finished migration. Developers discussing the post on Reddit focused on this exact gap. They pointed to shadowing the old implementation as a useful migration pattern. That reaction makes sense: the old service can serve as a behavioral reference while the new one is still being checked.
But discussion comments are practitioner reaction, not a separate benchmark or proof that the pattern fits every system. The evidence for this case comes from Anthropic's engineering account. The practical move is to run the new version beside the old one. Then compare what each returns for the same inputs.
This is often called shadowing: real requests are observed by both implementations, while the established service remains the reference. You can detect differences without immediately putting every new response in front of users. The comparison creates a queue of concrete questions to investigate.
The Method
Anthropic says the Python service acted as an oracle for the rewrite. The team compared the two implementations, then had agents reproduce and fix mismatches before review. That changes the agent's task from guessing what a large system should do to explaining a specific difference. A useful report includes the input, both outputs, and enough context to reproduce the case.
Then an agent can propose a correction against evidence rather than broad instructions. This turns an agent task into a concrete loop. Instead of asking for a plausible rewrite, give the agent a specific difference to explain and repair. Anthropic says agents reproduced and fixed mismatches before the changes went through review.
That order matters: an agent can do the implementation work, while review checks whether the proposed fix makes sense. The human still has to judge behavior, not just inspect a diff for neat formatting. Anthropic describes three loops around agent work: inner, outer, and memory. Together they help the team iterate, check broader behavior, and carry corrections forward.
The inner loop is where a narrow change gets implemented and checked quickly. The outer loop broadens the comparison so local success doesn't hide a system-level mismatch. The memory loop keeps prior corrections available, so agents don't have to rediscover the same lesson each time. The key is making the feedback repeatable.
A mismatch you fix once should become a case the system can check again. If it stays only in a conversation, the same failure can return in a later change. Capture the input and the expected behavior as a regression check. That gives the agent and reviewer a concrete signal when they revisit the code.
Human Review
But matching outputs doesn't automatically tell you which output is correct. Developers in the Reddit discussion explicitly cautioned that parity alone isn't a good fix. The old system can contain quirks, bugs, or accidental behavior that users nevertheless depend on. A match may preserve those quirks; a mismatch may sometimes be an intentional improvement.
So the comparison finds questions. It doesn't answer every product or correctness question for you. Some differences are bugs. Others may be intentional behavior.
A person still has to decide which is which and whether a change is safe. That decision can require API knowledge, product context, and an understanding of downstream callers. A coding agent can summarize the difference and propose a fix, but the account describes review as part of the process. Parity is evidence for review, not a replacement for judgment.
That judgment is one reason readable code still matters. In the Hacker News discussion, developers debated oversight and whether agent-written code should remain understandable. If people need to review a behavior change, they need enough context to follow the implementation. The thread also included the argument that agents could make lower-level, faster languages more practical to use.
That possibility is interesting, but it doesn't remove the need to understand what ships. The same discussion included the view that agents could make lower-level, faster languages more practical. That's a useful possibility, but the thread was small when indexed: twenty-six points and nine comments. A small thread tells us what some practitioners were discussing, not what developers broadly believe.
The stronger takeaway comes from the migration workflow itself: automate repeated implementation work, then keep review and comparison close. Readable code helps make that review possible.
Builder Lessons
So what can a builder take from this? Start by measuring the behavior your users already rely on. Before changing a mature service, identify representative inputs and outputs from the current implementation. Keep enough context to compare old and new behavior safely.
Then use agents on the differences you can reproduce, instead of asking them to infer every hidden requirement. For a migration, keep the old implementation available as a reference. Feed both versions representative inputs, then investigate differences before switching traffic. The comparison can happen in a controlled environment or through shadowed requests, depending on the system.
What matters is that the input is comparable and the output difference is recorded. You want evidence that can be repeated, not a vague report that the rewrite feels off. Don't treat every mismatch as a defect until you know what the old service was meant to do. And don't treat a passing test suite as proof that production behavior is preserved.
Classify differences, check intended behavior, and turn confirmed fixes into regression cases. This gives future changes a way to detect the same problem before rollout. The loop is simple: compare, investigate, correct, and preserve the lesson. Developers in both Reddit discussions focused on production parity and what real traffic can reveal.
That doesn't prove this exact method fits every system, but it makes the old implementation a valuable source of evidence. The r/Anthropic thread also returned to the risk of tests missing behavior present in real traffic. These comments echo the engineering account's central problem, but they remain discussion rather than independent validation. Use them as a signal about practitioner concerns, not as another measurement of the gains.
Keep the performance claim in proportion too. Anthropic reports improvements after the Rust migration, but doesn't isolate the effect of agent involvement. The post doesn't quantify the total human effort, review time, or cost needed to achieve those results. It also doesn't show that the same workflow will produce similar gains in another codebase.
That's why this is a practical case study, not a forecast. The account leaves some useful questions open. How much engineering time did the migration take? What would the same work have cost without agents?
How much of the performance improvement came from language choice, implementation details, or other changes? And how much review effort is needed when agents implement more of the code? The post doesn't answer those questions, so don't infer the economics from the performance figures. There's also a difference between generating code and delivering a safe migration.
The code can be produced quickly, but confidence comes from comparing behavior and resolving the important mismatches. In this case, Anthropic's own account says the production comparison revealed a gap that test results had not made obvious. That makes verification the more transferable part of the story. The language and service details may not transfer; the habit of checking real behavior often can.
By the End
By the end, three points stand out. Rust brought reported efficiency gains, with different scopes for CPU, memory, and latency. Tests alone missed production behavior: ninety-eight percent passed while about a quarter of compared inputs matched. Comparing implementations made differences actionable, but people still had to decide which behavior was correct.
Subscribe for more no-hype AI breakdowns.