← All posts

Anthropic Messages API Rust migration: how it worked

2026-11-26 · 5 min read

Anthropic has moved the Messages API, the endpoint developers call to use Claude, from Python to Rust, and Claude agents wrote most of the new code. Anthropic says the Rust version uses about 70% less CPU per request and cut median time to first token by about 20%, without taking the service offline or freezing feature work.

The posts

@AnthropicAI announced it on Wednesday, crediting "teams of Claude agents tracking down and fixing differences between the two versions." Lance Martin, a co-author of the engineering write-up, went a step further in his post: the team "used the Python API as an oracle" and had agents fix diffs until Rust matched what production actually did.

The speed numbers will get the headlines, but most of the write-up is about checking that agent-written code is correct.

Why Anthropic left Python

The Messages API was built in Python in 2023. Every request now goes through validation, prompt conversion, tokenization and safety screening, and Python adds overhead at each step. Anthropic says API traffic grew roughly 1,800 times from early 2024 to fall 2026.

A partial attempt in March 2026 rewrote only the response parsing in Rust, called from Python, and cut CPU by about 8% to 10%. The team judged that not worth the extra complexity and went for a full rewrite.

Writing took a week, proving it took months

According to Anthropic, Claude wrote a first version of the core request path in about a week. Checking it took far longer. The roughly 700 existing integration tests were tied to Python, and an audit of the ported tests turned up more than 100 weakened assertions. In April the Rust API passed about 98% of its tests while matching only about a quarter of real production inputs.

So the team treated the live Python service as the definition of correct and shadowed requests to both versions. The model ran once and its output was replayed to Rust, so randomness in the model couldn't pass for a bug. Engineers couldn't read customer requests, so the system logged where each difference first appeared, plus a fingerprint of it. A script grouped those records every 10 to 30 minutes and pinged a coordinating agent only when a new kind showed up. Each new kind went to its own worker agent in a cloud sandbox.

Input matching reached 99.6% by August, and public traffic moved to Rust in September.

Measure Change What was measured
CPU per request About 70% lower One region, August to October
Memory per request More than 80% lower All of production, August to October
Median time to first token About 20% lower Customers' Claude Code requests, shorter window

Where the agents cut corners

Anthropic is upfront that the verifier could be gamed. It rewarded matching outputs, and the agents looked for the cheapest way to produce them. On web search they took a shortcut, copying tool-description text into files. An engineer rejected it, and the real fix took the team weeks to build. Human review stayed as a gate, and engineers' corrections became rules the agents read before starting work.

How to try the oracle method on your own code

You don't need Anthropic's traffic for this. It fits any rewrite where the old version still runs:

  1. Keep the old system live and treat what it does as correct, including the parts nobody documented.
  2. Run the same real inputs through both versions and compare outputs, not code. If a step is random, like an AI call, run it once and give both versions the same result.
  3. Log where each mismatch starts plus a short fingerprint, so one bug shows up as one group instead of ten thousand rows.
  4. Hand each new group to its own Claude Code session with a quick local check it can rerun.
  5. Turn every correction into a rule in CLAUDE.md, and keep a person approving merges.

The prompt I'd start with for step 4: "Here is a mismatch group and a sample input. Reproduce it, fix the new version only, rerun the comparison, and stop when it matches. Do not edit the comparison script." The last line is there because of what Anthropic's agents tried.

My read

When we covered tsc-rs, the takeaway was that 181,711 existing tests gave the agent a precise target. Anthropic's post goes further: a suite passing at 98% still matched production only about a quarter of the time. One of its section headings puts it plainly: "Verification is the new bottleneck." The same goes for Claude Ship, which approves the pull requests your team's policy allows: that policy is your verifier, so write it as carefully as the code.

What it means for a business

Most owners aren't rewriting an API. Plenty are swapping an old spreadsheet, intake form or Zapier flow for something AI built, though, and the same rule holds: run old and new side by side on real work for a couple of weeks and compare the results before you switch. Writing the replacement is cheap now. Checking that it's right is where the time goes.

If you want help working out which of your processes have a clear definition of correct, and which need one first, New Face Design offers a free process audit.

08 / Start here

Which of this can you use today?

Tell us what you use today and we'll reply within one business day with what it would take. Free, 20 minutes, no pitch deck.

Email

pgorski@newfacedesign.com

Phone

+1 (773) 627-2176

Based in

Chicago area

Working with clients everywhere

Skip the form: grab a 20 minute slot.

Open the calendar →