Tag Archives: verification

Claude Rebuilt the API That Serves Claude — in Rust, With No Downtime

First of all… Happy Thanksgiving, everybody. Whether you celebrate Thanksgiving or just spend time with family and friends this weekend, my wish for you is peace, happiness, and connection. Now – to today’s post:

Anthropic published an engineering post this week that reads like a dispatch from the near future of software development: it moved its Messages API — the service every Claude request travels through, including traffic from Claude Code and Cowork — from Python to Rust, and Claude did most of the rewriting. The headline numbers are striking: the new Rust API uses about 70% less CPU per request and cuts median time to first token by about 20%, all without ever taking the service offline or freezing feature development. But the interesting part isn’t the rewrite. It’s the verification.

Read Anthropic’s full post: Migrating our Messages API to Rust

Why rewrite at all?

Anthropic built the Messages API in 2023, when it was, in one engineer’s words, “basically a request forwarder” written in Python. Then traffic happened: from early 2024 to fall 2026, API traffic grew roughly 1,800 times, and every request now has to be validated, converted into a prompt, tokenized, screened by safety classifiers, and then streamed back token by token, sorted into text, thinking, and tool calls. Python adds overhead to every one of those steps.

The team tried the cautious route first. They rewrote just the code that parses a model’s output in Rust and called it from Python — and got only about 8% to 10% less CPU, because every token now crossed the Python–Rust boundary three times. A full rewrite was the obvious answer and the scary one. In 2024, when an engineer suggested migrating to Go or Rust, another replied: “We are not rewriting the API in go or rust!”

What changed the calculus was Claude itself. By May 2026, Claude was writing more than 80% of the code Anthropic merged. Generating a first version of the API’s core request path in Rust took Claude about a week. The bottleneck had moved: writing code was no longer the hard part. Proving the new code behaved exactly like the old code was.

The tests weren’t enough

Anthropic had about 700 integration tests, but they turned out to be a weak verifier for a migration this high-stakes. The tests were coupled to the Python implementation — they ran the Python API in-process and mocked services like billing in Python’s memory — so when Claude ported them, a “pass” could mean the code was right or that the test had been weakened. An audit found more than 100 weakened assertions. And the tests were incomplete: just 20 binary options make over a million combinations, or about 12 days of testing at a second each, for one model.

So the team turned the production API itself into the verifier, using a technique called shadowing: run each request through both the Python and Rust versions and compare the results. That sounds simple until you remember three things. The Python API kept changing throughout the migration, so parity was a moving target. Claude’s replies are nondeterministic, so a difference between two outputs doesn’t necessarily mean a bug. And the team couldn’t read customer requests, for privacy reasons, so it couldn’t easily see where the two versions diverged.

Their answers were elegant. They ran the model once and replayed its output to Rust, so both versions worked from identical model output. They compared every step before and after the model call, so a deviation could be pinned to the exact stage that produced it. And instead of reading request text, they recorded the shape of each difference — where it happened and how big it was — using checkpointing and a “fingerprint” (where the difference began in the prompt, plus the length difference). One bug tends to leave the same fingerprint on every request it affects, so diffs could be grouped and triaged without ever exposing customer content.

The gap this closed was real: in April, the Rust API passed about 98% of its tests, yet only about a quarter of inputs matched on production traffic. One early bug was almost poetic — when Python writes JSON tool calls, it escapes certain characters (like an emoji) as text codes; Rust wrote them as-is, so the two prompts differed by a few bytes and the model could answer slightly differently.

Three loops, and humans at the seam

Fixing the differences was itself automated, in three loops. Every 10 to 30 minutes, a script grouped new diff records by fingerprint and alerted a coordinating Claude agent only when it saw a new kind of record; the coordinator assigned a worker agent to each and opened a Slack thread where human engineers could follow along. A fast inner loop let agents test hypotheses in a cloud sandbox in seconds, writing their own requests to reproduce each fingerprint. A slower outer loop validated fixes against shadowed production traffic. And a memory loop recorded lessons as rules — in June, an agent went through about 60 review comments, grouped the recurring problems, and proposed rules an engineer edited and approved for the team’s CLAUDE.md.

Human review sat at the seam between the inner and outer loops, and it mattered. In mid-May, an agent proposed a shortcut for a missing web-search tool description: just copy the text into files Rust could read. The prompts matched and the local verifier passed — but an engineer rejected it, because Rust would still need to call the real service before launch, and the workaround would be thrown out. A verifier can tell an agent whether outputs match; it can’t tell whether a fix is good enough to ship. The memory loop saved that decision as a note, so later agents hitting the same bug recognized it instead of reinventing the workaround.

The result, once the team trusted the two versions behaved the same, was a gradual cutover — passengers moved over a few at a time, in Anthropic’s own Ship of Theseus metaphor — to an API that is now live on Rust.

What this means for the rest of us

Anthropic’s own lessons are worth quoting back. Verification is the new bottleneck. If writing code is no longer the constraint, ambition can grow as far as your ability to check results. Design the verification signal — much of the project’s effort went into building checkpoints and fingerprints that could show Claude where things went wrong, the way a test names a failing case. And keep the loops simple, so they scale: human judgment decided what counted as correct, and Claude chose how to get there.

There’s a coda worth noting for anyone managing engineers. In an interview, platform engineering head Katelyn Lesse said the team had no Rust experts when the project started — engineers learned the language with Claude’s help along the way — and the team has since phased out the traditional coding interview, because strong candidates kept failing an interview for a skill they no longer practice by hand. The job is moving from writing code to directing agents, reviewing their fixes, and writing the rules they work within. Anthropic’s engineers started inside the loop chasing diffs themselves and ended at the edge, writing the checks the agents worked inside.

That’s the shape of this story: not “AI wrote a bunch of code,” but “AI rebuilt the road it drives on, while traffic kept flowing, and proved — request by request, fingerprint by fingerprint — that the new road goes to the same place.”

My take

This is the most convincing account yet of what agent-assisted engineering looks like at production scale, and the honest part is the part Anthropic leads with: the code was the easy bit. If you’re running a Python service in a hot path and eyeing Rust, the takeaway isn’t “Claude can rewrite it in a week” — it’s that you should budget most of the project for the verifier. Build the shadow comparison first, make the diffs fingerprintable, and keep a human at the seam where a fix crosses from sandbox to production. The ship sails faster now. The reason it could be rebuilt mid-voyage is that somebody built a way to check every plank.