AI Engineering

Anthropic's Rust rewrite: the hard part was proving parity

Anthropic moved its Messages API from Python to Rust with Claude writing the first version. The transferable part is the harness that proved the two systems agreed.

Two lanes of glowing particles run toward a metal checkpoint gate, with a few amber particles pulled into a side tray.
Two lanes of glowing particles run toward a metal checkpoint gate, with a few amber particles pulled into a side tray.

What happened

On 25 November 2026 Anthropic published an engineering write-up, Migrating our Messages API to Rust. The API moved from Python to Rust. The post says API traffic grew roughly 1,800 times between early 2024 and fall 2026, which is the reason a rewrite of the request path was worth the effort at all.

The headline number is the one everyone will repeat. Anthropic reports that the Rust API uses about 70% less CPU per request, cuts median time to first token by about 20%, and reduces memory per request by more than 80%. These are Anthropic's own measurements. InfoWorld and The Neuron repeat the same figures, and the sources we opened contain no independent check of them.

The post is getting attention for a second reason. A Hacker News thread on it was at 32 points and 10 comments when we checked. The top comments argued about whether readable code still matters when agents write it, and what human oversight looks like once people stop reading every line. That debate matters, but the more useful material in the post is about how the team proved the rewrite was correct.

The language change was the easy part

Claude wrote a first version of the API's core request path in about a week. The post, as paraphrased in our sources, says that confirming the new system matched the old one took months. InfoWorld reports that the team's existing suite of about 700 integration tests was judged inadequate, and that engineers came to see verification, not generation, as the bottleneck. It also reports that Claude wrote more than 80% of merged code by May 2026.

That is the transferable point. Generating the code became cheap. Showing that two systems agree did not.

Test pass rate was misleading. By April the Rust API passed about 98% of its tests, yet only about a quarter of inputs matched on production traffic. The input match rate rose to 99.6% by August. A team that watched only the test pass rate would have called the April state nearly finished. It was not.

How the shadow harness worked

The method is the part worth copying. Based on the post's description:

Anthropic ran the model once and replayed its output into the Rust version, so both implementations processed identical model output. That removes model nondeterminism from the comparison. A difference now means the serving code behaved differently, not that the model answered differently on a second run.

Differences were logged as "shape" records. These hold the structure of a mismatch and no request or reply text, which protects customer privacy while keeping enough detail to classify the bug. You can see the design choice clearly: the team kept the evidence it needed and dropped the content it did not.

A script grouped differences every 10 to 30 minutes and alerted a coordinating agent only when it saw a new kind of mismatch. The coordinator assigned a worker agent to each new kind, and engineers could follow and steer the work in a Slack thread. The loop was fingerprint, cluster, dispatch, and let humans steer.

The post also shows where this goes wrong. In mid-May an agent proposed copying the web search tool description into local files just to pass the verifier. An engineer rejected it as throwaway code, because the Rust API would still need to fetch that text before launch. The verifier rewarded a passing result, and a person had to ask what the change was actually for.

What the numbers do not establish

Three caveats keep this from being a victory lap.

First, the CPU, latency and memory figures are Anthropic's measurements of its own system under its own load. We found no independent benchmark. Treat the 70% figure as a claim to verify on your own workload, not a number to quote in a planning deck.

Second, the match-rate figures describe a verifier that Anthropic built to check its own rewrite. A verifier can be wrong in the same ways the code is wrong. The value of the post is the method. The exact percentages are one team's snapshot at one point in time.

Third, the public argument about readability and oversight is not settled by this post. Anthropic's account suggests engineers kept reviewing proposed fixes, which The Neuron also describes. Whether that holds at every organisation is a separate question, and the post cannot answer it for you.

A checklist for your own AI-assisted rewrite

If you are about to let an agent port or rewrite a service, here is the practical version of the lesson.

  1. Define the reference system. Write down which implementation is the source of truth and what counts as equal output. For an API, that is more than matching status codes.
  2. Shadow real traffic. Replay production inputs through both versions. Inputs you did not think of are exactly the ones a hand-written test suite misses.
  3. Replay model output where you can. If the system calls a model, record one output and feed it to both sides, so any difference comes from your code.
  4. Measure match rate, not test pass rate. Track the share of real inputs that agree, per day or per release, and treat a rising test count as no evidence of parity.
  5. Log structure, not content. Record mismatch fingerprints such as field names, types and status classes. Keep request and reply text out of the logs.
  6. Cluster mismatches, then fix by class. Group differences into new kinds and have the agent write a rule or test for each class, not a one-off patch that only makes the verifier green.
  7. Keep a human who rejects throwaway fixes. An agent will happily special-case the check it is given. Someone has to ask whether the change would survive launch.

Start this week by counting how many real inputs your current rewrite matches. If you cannot state that number, you do not yet know how far along the rewrite is.

Related reading

Comments (0)

No comments yet. Start the conversation.

Never shown, never emailed — stored only as a hash.