Anthropic just published one of the most honest engineering stories of the year: how it moved its Messages API — the route every Claude API call, Claude Code session, and Cowork task travels — from Python to Rust. The new version uses about 70% less CPU per request and cuts median time to first token by about 20%, with zero downtime and no freeze on feature development.

The surprising part isn't the rewrite. Claude wrote the first version of the API's core request path in about a week. The surprising part is what Anthropic says actually consumed the effort: proving the new code behaved exactly like the old one.

The generator–verifier gap comes to production

Anthropic frames the problem as a generator–verifier gap. It's often far easier to verify a solution than to produce one — checking a Sudoku solution is trivial, finding it is not. Many of Claude's most ambitious projects have relied on that gap: a proof assistant can check each step of a mathematical proof, and a test suite can judge a codebase migration.

But live systems break the pattern. Users rely on edge cases and quirks that fall outside the test suite, and "correct" is hard to define exhaustively. Generating the Rust code was the easy part. Verifying it was the project.

The numbers explain why a rewrite became unavoidable. The Messages API started in 2023 as what one engineer called "basically a request forwarder" — a thin Python service passing requests to the model. By late 2025, every request had to be validated, converted into a prompt, tokenized, and screened by safety classifiers, while replies had to be sorted into text, thinking, and tool calls. Python added overhead to every one of those steps. Meanwhile, traffic grew roughly 1,800 times from early 2024 to fall 2026.

The incremental fix that didn't pay

The team did what the standard advice says: rewrite only the slow parts. They rewrote the model-output parsing code in Rust and called it from Python. CPU usage fell about 8% to 10% — but each token now crossed between Python and Rust three times, adding complexity and new overhead. The gains didn't justify the cost.

What changed the calculus was Claude itself. By May 2026, Claude was writing more than 80% of the code Anthropic merged. The effort of a full rewrite was dropping fast. The question became: could Claude also help capture every behavior and fix in the production system — and how would anyone verify that?

Why 700 tests weren't enough

The team started with its existing suite of about 700 integration tests. Two problems limited how much they could trust it.

First, the tests were coupled to the Python implementation. They ran the Python API inside the test process and mocked services like billing and rate limiting in Python's memory. The tests had to change along with the code, and Claude helped with both — so a "pass" could mean the code was right, or that the test had been weakened to let wrong code through. An audit found more than 100 weakened assertions.

Second, the tests were incomplete. The API has dozens of features, and the combinations explode: just 20 binary options make over a million combinations — 12 days of tests at a second each, for one model, before varying the prompts. In practice, engineers test a subset that approximates production. It inevitably misses cases.

The gap showed up in the numbers. In April, the Rust API passed about 98% of its tests — yet only about a quarter of inputs matched on production traffic. One example: when Python writes JSON tool calls, it escapes certain characters (like an emoji) by replacing them with text codes. Rust wrote those characters as-is, so the two prompts differed by a few bytes. Production also weights bugs differently than a test suite: each case counts once in tests, but a single common bug in live traffic fires on every request it touches.

Turning production into the verifier

With tests insufficient, Anthropic used the existing system as an oracle — shadowing. Requests ran through both the old and new code, and the results were compared. Standard shadowing tools assume a request can safely run twice and that the service is deterministic. Neither held: a request had to count only once toward a customer's limits and bill, and Claude's replies are nondeterministic.

The fix: run the model once and replay its output to the Rust version. With both versions working from the same model output, every stage before and after the model call had to match exactly — because Claude accepts almost any prompt, even a small deviation can change its reply without triggering an error.

There was also a privacy constraint. The team worked without reading user requests or Claude's replies, so it couldn't just look at where the two versions diverged. Instead it recorded the shape of each difference:

  • Checkpointing. Both versions handle a request in the same steps — accept or reject it, resolve settings, build the prompt. Comparing step by step, and piece by piece within the prompt, located roughly where the migration code differed.
  • Fingerprinting. Once the rough location was known, the team recorded where each difference began in the prompt plus the length difference. One bug tends to leave the same fingerprint on every request it affects, so errors could be grouped and triaged by fingerprint.

Three loops, and a human at the seam

Each differing request left a record in the logs, and a single bug could produce hundreds of thousands of nearly identical records. A script ran every 10 to 30 minutes, grouped records by which fields differed, and alerted a coordinating Claude agent only when it saw a new kind of record. The coordinator assigned a worker agent to each new kind and opened a thread in a shared Slack channel where engineers could follow along.

From there, three loops did the work:

  • The inner loop ran in a cloud sandbox where agents could test hypotheses in seconds. The input check built the prompt each version would send — without calling the model, so a comparison took under a second. The output check ran both versions against a scripted reply. Agents had to reproduce each difference themselves, since they could only see the fingerprint, not the request behind it. A wrong guess cost seconds and harmed nobody.
  • The outer loop validated fixes against shadowed production traffic, comparing deployments with and without each fix. It caught what the sandbox missed, since the local verifier wasn't always configured exactly like production.
  • The memory loop recorded what came out of reviews and applied it to every agent that followed. When an engineer rejected a shortcut — an agent had proposed copying a web-search tool description into files instead of having Rust call the internal service — the decision, the reason, and the correct fix were saved as a note. Later agents recognized the same bug from new fingerprints and linked it to the note instead of writing another workaround. In June, an agent went through about 60 review comments, grouped the recurring problems, and proposed rules that an engineer edited and approved for the team's CLAUDE.md.

Human review sat at the seam between the inner and outer loops. A verifier can tell an agent whether outputs matched, Anthropic notes, but not whether a fix is good enough to ship. Engineers reviewed proposed fixes, decided whether a difference was a bug or a deliberate change, and increasingly moved to the edge — writing the rules and checks the agents worked within.

The lesson that generalizes

Anthropic closes with a metaphor: migration is usually like rebuilding the Ship of Theseus plank by plank while it sails, and changing too many planks at once means coming into dock. Claude made it possible to build an identically functioning ship alongside the first — even as the first kept sailing and having its planks replaced — and move the passengers over a few at a time.

The takeaway the team states plainly: verification is the new bottleneck. Writing code is no longer the constraint; how quickly you can verify results is. Ambition can increase as long as there's a way to verify correctness — and when tests and formal checks aren't enough, a production system itself can be the verifier. The work is in designing the verification signal: checkpoints that locate a difference in the code, fingerprints that tell one bug from another, and loops simple enough to scale as the model gets more capable.

For anyone planning their own rewrite, the message is uncomfortable but useful: if your migration plan is mostly about generating the new code, you've planned the easy half.

Source: Anthropic, "Migrating our Messages API to Rust" (November 25, 2026) — https://www.anthropic.com/research/migrating-api-to-rust