schristoph.online

Verification · 17 min read

Production Is the Verifier: Three Lessons from Anthropic's Move to Rust

On this page
TL;DR: Anthropic moved its live Messages API from Python to Rust. Claude wrote the first version of the core request path in about a week. That Rust version passed about 98% of its tests, yet only about a quarter of production inputs matched. So Anthropic made production the verifier. It ran the model once, replayed the output to Rust, compared the result exactly at each checkpoint and let agents fix each kind of difference, with an engineer reviewing every fix before it reached shadowed traffic. The new API uses about 70% less CPU per request, and the verification investment gave Anthropic enough confidence to ship the rewrite. As I read it, Anthropic’s earlier partial rewrite measured the slice together with the language boundary it introduced, so it could not predict the benefit of a full rewrite without that boundary. The same discipline works when you change the model in a running agentic system. There, exact match on replies gives way to evals and a gradual cutover well before the model’s end-of-life date.

In September I wrote about the generator–verifier gap. AI takes over the work that is cheap to check, and the effort that compounds goes into building the verifier, so you don’t end up being it [2]. Anthropic’s article on migrating its Messages API to Rust opens on the same gap and then turns it around [1]. “Many problems have a generator–verifier gap: it’s often far easier to verify that a solution is correct than to come up with one.” In a live system, they write, the gap points the other way: “generating the work is easier than verifying it.” Users rely on edge cases and quirks that no test suite lists, which is Hyrum’s Law at work [3].

The article is worth reading in full. It is detailed and well written, its sixteen figures have careful captions, and it reports the numbers that don’t flatter the project. I’ll follow its structure here: first how Anthropic turned the production API into a verifier, then three lessons for anyone who has to change AI systems running in production.

What Anthropic had to change

Anthropic built the Messages API in 2023, in Python. One engineer at the time called it “basically a request forwarder” (why migrate?) [1]. By late 2025 every request had to be validated, converted into the prompt, tokenized and screened by safety classifiers, and every reply had to be sorted token by token into text, thinking and tool calls. Python, the article says, “added overhead to every one of those steps each time it created an object, freed memory, or handed its work to the next task.” From early 2024 to fall 2026, API traffic grew roughly 1,800 times [1].

Three conditions made a rewrite hard to trust. The Python API kept changing during the migration, so parity was a moving target. Claude can answer the same request differently, so a difference between two outputs didn’t have to be a bug. And Anthropic couldn’t read customer requests, so nobody could simply look at where the two versions disagreed [1].

Why about 700 tests could not vouch for the rewrite

Anthropic started with the tests it had, about 700 integration tests (tests) [1]. Two problems limited them. The tests ran the Python API inside the test process and mocked services such as billing and rate limiting in Python’s memory, so the tests had to be ported along with the code. After that, “a ‘pass’ could mean that the code was right, or that the test had been changed in a way that let wrong code through.” An audit of the ported tests found more than 100 weakened assertions. The tests were also incomplete. “Just 20 binary options make over a million combinations”, which the article puts at 12 days of tests at a second each, for one model.

The gap showed up as soon as Rust met real traffic (detecting parity with production): “Our Rust API passed about 98% of its tests in April, yet only about a quarter of inputs matched on production traffic.” One cause was tiny. When Python writes JSON tool calls, it escapes certain characters, such as an emoji, into text codes. Rust wrote them as they were, so the prompts differed by a few bytes. Production also weights bugs differently from a test suite. A test case counts once, while a common bug shows up in every request that triggers it [1].

How Anthropic built a verifier from shadowed production traffic

Running the same requests through old and new code and comparing results is called shadowing. Common shadowing tools often assume that a request can safely run twice, or that the service is deterministic, and neither held here [1]. A request had to count once toward a customer’s limits and bill, and Claude’s replies vary for the same input. The core of Anthropic’s design is one sentence: “we ran the model once and replayed the model output to Rust.”

With both versions working from the same model output, everything around the model has to match exactly, before and after the model call. The article explains why a loose comparison isn’t enough: “since Claude accepts almost any prompt, even a small deviation can change its reply without triggering an error.” If Rust left out part of a prompt, the request still succeeded and the model still answered, sometimes a little differently.

Privacy shaped the rest. Anthropic chose to work without reading user requests or Claude’s replies, so it “recorded the shape of each difference, such as where it happened in the service and how big it was” [1]. Two techniques produce that shape. Checkpointing compares the result of each step, and the prompt piece by piece, so the first step that differs shows roughly where the Rust code departs from production. A fingerprint adds where the difference starts in the prompt and how much the lengths differ. One bug tends to leave the same fingerprint on every request it affects, so records can be grouped by fingerprint and fixed in order of frequency.

Two rows of request steps from left to right. Top row, Python in production: validate, resolve settings, build prompt, tokenize, classifiers, model, sort output, stream, count usage. Bottom row, Rust as shadow: the same steps, with replayed model output in place of the model. A dashed accent arrow labelled replay runs from the model down to the replayed output. Between the rows, each step has a compare marker. The marker under build prompt is highlighted as the first difference and points to a record box with step build prompt, piece 2, first diff at byte 17, python 190 bytes, rust 190 bytes, and the note that the record holds no request text.

Shadowing with the model run once. Rust gets the same input and the replayed model output, the result is compared exactly at each checkpoint, and the first step that differs becomes a small record without any request text. Values in the record are the article’s made-up example.

Agents in three loops, with an engineer reviewing each fix

A single bug could produce hundreds of thousands of nearly identical records. So a script ran every 10 to 30 minutes, grouped the records by which fields differed, and alerted a coordinating Claude agent only when a new kind of record appeared (verification loops) [1]. The coordinator assigned one worker agent to each new kind and opened a thread in a shared Slack channel where engineers could follow along and steer.

The workers ran in three loops. The inner loop gave each agent a cloud sandbox with both codebases. A first version in April had needed a review and a deployment for every hypothesis, and feedback took hours or days. The sandbox’s input check built the prompt in both versions and compared them in under a second, because it never called the model. A later output check ran both versions against a fake model. Agents saw only the fingerprint, so each one guessed the cause, wrote its own request or model reply to reproduce the difference, edited the Rust until the versions matched, and added a test that failed on the old code and passed on the new.

Engineers came in at the seam between the inner and the outer loop. A fix left the sandbox only after pull-request review. In the article’s example, Rust didn’t yet call the internal service that supplies the web search tool’s description. An agent proposed copying the text into files Rust could read. The prompts matched and the local verifier passed, and an engineer still turned the fix down, because Rust would have to call the service before launch anyway. The article draws the lesson itself: “the verifier rewarded matching outputs, and the agent found the cheapest way to produce them. A verifier can tell an agent whether the outputs matched, but not whether the fix is good enough to ship.”

The outer loop deployed builds with and without a fix and checked on shadowed traffic whether the fingerprint went away. It compared requests of the same kind by logged metadata such as the model and features used, never by the text. When a fix passed in the sandbox and production still showed the difference, the task went back to the inner loop [1].

The memory loop kept engineers from making the same correction twice. After one agent guessed at Python’s behaviour, an engineer made it a rule to port exactly what Python did, and an agent then found seven more places where the port had relied on a guess. About 60 review comments became rules in CLAUDE.md, each proposed by an agent and approved by an engineer. Some lessons became permanent checks. One was a merge check that required anyone changing the Python code to make a matching change in Rust or request an exemption [1].

Flow from left to right. A coordinator agent box, fed by a grouping script every 10 to 30 minutes with new kinds of records, leads into the inner loop panel: one worker agent per kind with both codebases, an input check under a second and an output check with a fake model. An accent box labelled the seam, an engineer reviewing the pull request, sits between the inner loop and the outer loop panel: deploy with and without the fix, and check on shadowed traffic whether the fingerprint is gone. A dashed accent arrow labelled difference still there runs from the outer loop back to the inner loop. A green bar along the bottom, the memory loop, says corrections become rules: rules in CLAUDE.md, tests, lints and a merge check that keeps Rust in step with Python.

The three loops. Agents iterate fast in the sandbox, an engineer reviews every fix at the seam before it reaches shadowed production traffic, and corrections become rules and checks for every later agent.

Rust’s input match on compared requests started at 24%, dropped to 6.5% in early May, and ended at 99.6%, while the comparison widened from Anthropic’s own traffic to a broader sample (Figure 6) [1]. That number covers the input side, the prompt each version builds. Replies were compared separately, and the article gives no number for them. Public traffic moved to Rust in September 2026. The article describes the cutover with a Ship of Theseus image. You build an identical ship alongside the one that keeps sailing, check that the two behave the same, and once you trust that, move “the passengers over a few at a time” (looking ahead). The article gives no rollout percentages and no rollback plan, and I won’t guess at them.

Lesson 1: verification made the 70% CPU saving safe to ship

The headline results come from the lessons learned section and Figure 15: about 70% less CPU per request, more than 80% less memory per request, and median time to first token down by about 20% [1]. Figure 15’s caption qualifies the last number. It was measured on customers’ Claude Code requests over a shorter period, and part of the fall came while almost all of those requests were still on Python. I take the 20% as Anthropic reports it, and no more strongly.

The saving comes from the reason Anthropic gave for the move. The per-object and per-handoff overhead that Python added to every validation, prompt, tokenization, classification and sorting step is gone, and tokens no longer cross between two languages on their way out. The 70% covers that whole move, and Anthropic measured it in one region. The move combined a rewritten request path, a removed language boundary and a new language, and the article doesn’t split the saving by cause. So it does not isolate how much of the saving came from Rust rather than the redesigned path or the removal of the language boundary.

Amazon’s Leadership Principles include Frugality: “Accomplish more with less” [4]. This migration fits it well. The API serves the same requests with far less CPU and memory per request. I’d add a point the article doesn’t make. Lower resource use per request could reduce energy and hardware demand compared with the old implementation, although Anthropic reports no energy or emissions measurement. Any such gain is per unit of work, so it won’t cut total use when traffic has grown roughly 1,800 times. It makes that growth cheaper than it would otherwise be. Anthropic’s own motive was efficiency under fast growth, and that is reason enough.

Now look at where the effort went. Claude produced the first version of the code in about a week, and yet the article says “much of our effort for this project went to building such a signal”, meaning the verification signal [1]. That bill includes months of running both versions on shadowed traffic, and the article doesn’t put a number on it. Without that investment, I don’t think the saving would have been safe to take.

Lesson 2: what Anthropic’s partial rewrite did and didn’t measure

Before the full rewrite, Anthropic followed the standard advice and rewrote only the hot spot (incremental or all at once?) [1]. “In Rust, we rewrote the code that parses a model’s output and called it from Python. This reduced the API’s CPU usage by about 8% to 10%.” Then the verdict: “In our case, the gains didn’t justify the added complexity. Each token now crossed between Python and Rust three times (Figure 2), creating new sources of overhead.”

Two stacked panels, each a chain from left to right. Top panel, partial rewrite, March 2026, about 8% to 10% less CPU: Python request steps, the model, Rust parsing the tokens highlighted in accent, then Python output steps, with the note that each token crosses between Python and Rust three times. Bottom panel, full rewrite, September 2026: Python hands over the request, Rust does every step before the model, the model, Rust does every step after the model.

After Anthropic’s Figure 2. The partial rewrite added a language boundary that every token crossed three times. In the full rewrite, Python hands over the request and Rust does every other step around the model.

So the partial rewrite did save CPU, just not enough to justify the complexity it added. What changed the decision came from outside the slice. Full rewrites are usually avoided because tests never cover all of production behaviour and because the effort is too large. In 2024 one engineer settled the question for a while with “We are not rewriting the API in go or rust!” As Claude became more capable, Anthropic asked whether those reasons still held. By May 2026, Claude was writing more than 80% of the code Anthropic merged, so the effort was dropping fast, and the remaining question was how to verify the result. “Verification, not generation, had become the bottleneck” [1].

What follows is my reading of that passage. Anthropic doesn’t frame it this way. A first slice measures two things together: the slice itself and the seam it introduces. Here the seam was a language boundary that every token crossed three times, and a full migration has no such boundary. Many projects cut a large change down to a first step, watch that step fail to pay off, and drop the whole idea. Anthropic read its result as a judgement on that path only. It went back to the reasons it had sliced in the first place. When those reasons changed, it rewrote the whole request path and invested in what made that safe. The cutover itself stayed gradual. Traffic moved a few passengers at a time after months of shadowing, so this is no argument for big-bang releases.

Lesson 3: changing the model in a running agentic system

For most teams I work with, the change they face most often is the model. New models arrive constantly, and in conversations with customers I often see teams hesitate to touch a model that works. They stay on an older model when a newer one, or a smaller one that fits the task, would serve them better. I understand why. An agentic system is nondeterministic and harder to test than ordinary code, and after any change it is hard to be sure it still works.

Staying put doesn’t last, though, because model lifetimes are limited. Amazon Bedrock documents a predictable lifecycle you can plan around [5]. Every model has one of three states: Active, Legacy or End-of-Life (EOL). For models launched on or after September 7, 2026, model cards show, where applicable, an “EOL no sooner than” date and a Legacy period, and “Most models have a 6-month Legacy period.” Once the Legacy period begins, “new customers can’t adopt the model, and existing customers may lose access after 15 days of inactivity.” After the EOL date, “requests made to it will fail”, and “migration will not happen automatically” (all checked on 26 November 2026; models launched before that date follow a separate legacy policy page). I wrote about planning for this in March [6], and I still think a production AI application needs a lifecycle capability, meaning a routine way to change its model.

Anthropic’s discipline carries over to that problem, with one correction. Anthropic held the model constant and replayed its output, so everything it compared was deterministic. A model swap changes exactly the part Anthropic held constant. Exact match on the reply can’t be your verifier, because two good answers rarely match byte for byte. For model outputs, task-specific evaluations and rollout metrics replace byte-for-byte parity as the main decision signals.

Two stacked panels, each a chain from left to right. Top panel, Anthropic's migration, code changes and the model is held constant: shadow production traffic, run the model once and replay the output, exact match at checkpoints, engineer review and cut over a few at a time. Bottom panel, a model swap, the model itself changes: capture production prompts, the new model answers the same prompts, evals with a judge model, human raters or programmatic metrics highlighted in accent, engineer review and gradual cutover before the EOL date.

What carries over to a model swap. Captured production prompts, review and gradual cutover still apply. Exact match on the model’s reply becomes evals, because the model is now the thing that changes.

Much of the rest carries over. Production prompts can supply a representative evaluation sample, subject to privacy and sampling controls, and they cover cases nobody thought to write down. Task requirements, safety policies, expected outcomes and reviewer judgements still define what counts as correct. The deterministic plumbing around the model, such as prompt templates, tool schemas, parsers and usage accounting, can still be checked exactly with the model held fixed, which keeps “the model changed” apart from “our code changed”. Differences still need grouping, so you see one kind of regression instead of thousands of slightly different replies. And human judgement still belongs at the seam. Someone decides whether a difference is a regression or an acceptable change before traffic moves over gradually, well ahead of the EOL date.

Amazon Bedrock evaluations cover the judgement part [7]. Programmatic jobs score a model on a prompt dataset, human-based jobs bring in your own raters, and judge-model jobs use a second LLM that scores each response and explains its score. Bedrock can also evaluate responses you have already generated. You supply the prompts and your own model responses, and Bedrock skips the model-invoke step [8]. This also avoids generating a new output during evaluation. Unlike Anthropic’s replay, it does not feed the same model output through two implementations for an exact differential comparison. A judge model is a model too, so check its verdicts against human ratings on a sample before you trust it at scale. A smaller team doesn’t need Anthropic’s fleet of agents for any of this. Captured prompts, a grouping script and a review gate are a workable start.

Will efficiency alone justify a rewrite?

Changing a runtime’s language for efficiency isn’t yet a topic for most of the teams I talk to. It may become one, if LLMs make code migrations affordable enough that efficiency alone justifies a rewrite. Anthropic expects the constraint to move: “if writing code is no longer the bottleneck, the main constraint becomes how quickly you can verify results” [1]. That fits both cases in this post. How ambitious you can be with a language change under a service, or a model change inside an agent, depends on how good your verifier is.

Where Anthropic’s engineers ended up

At first Anthropic’s engineers worked inside the inner loop, running Claude and chasing differences themselves. Later they stopped manually chasing every parity difference and concentrated on reviewing fixes at the seam. As the system matured, they moved to the edge, “writing the rules and checks that agents worked within” [1]. That is what I argued for in September, done at production scale: they kept reviewing fixes and defining constraints, and put the rest of their effort into improving the automated verifier instead of doing its checking by hand [2].

If you had to swap the model in your most important AI application next month, what would tell you that it still works?

Sources

❤ Created with the support of AI (Kiro)

VerificationAgenticAIFrugalityModelLifecycleAmazonBedrockSoftwareArchitecture