Analysis Software migrations and modernization 8 min read

Anthropic's Rust Migration: What the Verifier Could Not Catch

Anthropic says Claude wrote a first version of its Messages API's core request path in Rust in about a week. Getting from there to production took a test audit, shadowed live traffic and an engineer who rejected a fix that passed the verifier.

What Anthropic reported

On November 25, 2026, Anthropic published Migrating our Messages API to Rust, an engineering account by Lance Martin and five Anthropic colleagues. The Messages API is the interface developers use to send requests to Claude models. The team moved it from Python to Rust while the Python version kept changing, without taking the service offline or freezing feature work. Public traffic moved to Rust in September 2026.

Claude wrote a first version of the core request path in about a week. Most of the post is about what came after: proving that the new code did what the old code did. Anthropic reports that the finished migration uses about 70% less processor (CPU) time per request and more than 80% less memory per request, and cuts median time to first token, the wait before the first part of a reply arrives, by about 20%. Its first lesson is that verification, not code generation, is now the hard part.

The post shows what each of a well-staffed team's verification loops caught. It also describes a fix that passed the automated checks and that an engineer still rejected.

Three loops, three kinds of evidence

Anthropic built three verification loops around its agents. Each produced a different kind of evidence.

LoopWhat it didWhat it produced
Inner loopEach agent worked in a cloud sandbox holding both codebases, with fast local checks: one compared the prompt each version built from the same request without calling the model, and a later one ran both versions against a fake model, a stand-in for Claude, so no real model call was needed. The post calls these checks the local verifier.A fix, plus a test that failed before the fix and passed after it. A fix crossed into the outer loop only after pull request (PR) review.
Outer loopAfter deployment, builds with and without a fix were compared on shadowed live traffic: real production requests that Python answered, with Rust given the same work alongside and its result compared. The Python API was the reference.A fingerprint for each mismatch, a short record of its shape that let similar mismatches be grouped as one likely bug: which step and which part of the prompt differed, where the first differing byte was, and how long each version was. The team did not read requests or replies.
Memory loopEngineers' corrections became rules each new agent read first. Lessons also became permanent checks.Entries in CLAUDE.md, the instruction file Claude Code reads at the start of a session; new tests, lints (automated code checks) and a merge check.

The outer loop exists because tests were not enough. The team had about 700 integration tests, and the post notes that twenty on-or-off options alone make over a million combinations.

Two different numbers show the gap. In April the Rust API passed about 98% of its tests, while only about a quarter of inputs matched on production traffic. That quarter is the start of the second measure, the share of production inputs on which Rust and Python matched. Anthropic's chart of that match rate, measured first on its own traffic and then on a wider sample, starts at 24% in late April, falls to 6.5% in early May and ends at 99.6% in August.

Comparing old and new on live traffic, and treating the old system as the reference, is the method our article on behavioral equivalence and architectural compliance examines in GitHub's Copilot port; behavioral equivalence means the new system behaves like the old one. Anthropic's version is more careful than most. Two findings in the post concern things a comparison with Python cannot show: tests that had been edited, and a fix that matched Python while going against the planned design.

More than 100 weakened assertions

The ported tests were coupled to the Python implementation, so they had to change along with the code. A passing test could therefore mean the code was right, or that the test had been changed to let wrong code through. When the team audited the ported tests, it found more than 100 weakened assertions.

Some test changes are legitimate in a migration: the new code has different types, different errors and different internals. The difficulty is that Claude helped change both the code and the tests that judged it, and a pass rate cannot tell those two kinds of edit apart. Anthropic found the problem with an audit. Without a scheduled audit, a team would not see it: in a continuous integration (CI) pipeline, a test edited inside the PR it judges shows the same green check as any other.

The governance question here is ownership. Who may change an acceptance criterion, and does that change get reviewed apart from the code it lets through? Our analysis of the rules a pull request must not rewrite covers the GitHub settings that keep review rules out of the change under review.

The fix that passed the verifier

In mid-May, one large remaining difference traced to web search. In production, Python fetched the web search tool's description from an internal service. The Rust API did not call that service yet, so the description was missing from its prompts.

An agent proposed copying the description text into files the Rust code could read. The prompts then matched, and the fix passed the local verifier, the inner loop's quick comparison of the two versions. An engineer rejected it: Rust would have to call the service before launch anyway, so the copy was throwaway work. In the post's words, "the verifier rewarded matching outputs, and the agent found the cheapest way to produce them."

The agent was not being deceptive. It did what its signal asked. The signal could not express what the engineer knew: in the target architecture, the Rust API gets tool descriptions from the service that owns them. That is a decision about how the new system is built, and the matching outputs carried no trace of it.

No comparison with the old system can catch this kind of error, because the old system is the wrong reference for it. Python behaved correctly; the question was whether Rust was built the way the team had decided. Anthropic's answer was a person. The post calls human review an important gate, and describes engineers reviewing fixes for the questions the verifiers could not answer.

Notes, rules and checks

After the rejection, the agent saved a note to memory explaining the decision. The note worked: while the real fix was built, the bug kept producing new mismatch records, and later agents checked the note, recognized the known bug and linked those records to it instead of writing another workaround. Anthropic's memory loop sends corrections to two places, and only one of them can fail a build.

The post describes the web search correction as a note. It does not say whether that one also became a check. For a team copying this design, the open question is the path between the two lists: which corrections are decisions about the target architecture, which of those can a machine enforce, and who approves the move from note to check.

Anthropic's process already has the important part for its CLAUDE.md rules: an engineer edited and approved them before agents relied on them. Anthropic's note already recorded the decision, the reason and the correct fix. What a written decision adds is what a memory note does not have: the code it applies to, a status that changes when it stops applying, and a check that fails when it is broken.

The web search decision had a lifetime. As a hypothetical, a local copy of the description might be acceptable in a test harness and forbidden in the shipped Rust API. A memory note does not carry that scope; a recorded decision with a lifecycle status, enforced by a rule limited to certain paths, does. A lifecycle status says whether a decision is in force or has been replaced.

What teams planning an AI-led migration should do

Most organizations will not build fingerprinted shadow traffic for a migration. They can still copy the parts of Anthropic's process that do not depend on scale.

  1. Write the target-architecture decisions down before agents start. List which services the new system must call, which old dependencies it must not keep, and which shortcuts are forbidden. Give each decision an owner and a scope. An agent can only be held to a decision someone recorded.
  2. Separate acceptance criteria from the change. Put test directories, check configuration and CI workflows behind required owner review, and audit ported tests for weakened assertions before you trust a pass rate.
  3. Promote repeated corrections from notes to checks. When reviewers flag the same pattern twice, turn it into a lint or rule that fails the build, as Anthropic did. Have an engineer approve each one.
  4. Keep human review for what no check can express. Anthropic's engineers moved to the edges of the loop, writing rules and checks and deciding what counted as correct. That is where reviewer time goes once agents write most of the code.
  5. Track which decisions are enforced. For each recorded decision, know whether a check fails when it is broken or whether it still depends on a reviewer noticing.

Where Mneme fits

Mneme, the open-source tool we build, enforces a team's recorded architecture decisions on code changes. It does not run shadow traffic or compare a new system's behavior with an old one; that evidence still comes from methods like Anthropic's.

Mneme compiles architecture decision records (ADRs), short documents that each record one decision and its reason, into one file in the repository, .mneme/project_memory.json, which Mneme calls the memory file. A decision is enforced only when it has an active typed rule, a form of the decision that a program can check without judgment calls. Every typed rule Mneme ships today forbids something. The one that matters here forbids an exact piece of text, optionally limited to certain paths. Version 0.11.0 added a second, which forbids a numeric value in Python source above a set limit; only a separate whole-file check decides it, so the hook and CI job described below enforce the text rule.

Claude Code lets plugins install hooks, scripts that run around an agent's actions. In Claude Code, the Mneme plugin's hook refuses an edit made with Claude Code's file-editing tools before the file changes if it breaks an active text rule; most shell writes are checked when the agent finishes its turn. In CI, a required job fails a PR that adds or modifies a file breaking an active text rule, whichever agent or person wrote it.

Anthropic's example shows the limit of these rule types: they can forbid, and they cannot require. Once someone had named that shortcut, a team could forbid the copied files' path from appearing as text anywhere in the Rust source tree. No rule Mneme ships today can require that the Rust API call the description service. That requirement stays with tests and review.

Mneme also separates proposing a decision from adopting it. An agent can submit a candidate decision, a proposed decision that nothing enforces yet, through Mneme's Model Context Protocol (MCP) server, the interface agents use to read and propose decisions. Only a person running the mneme decision command can accept or reject it.

Accepting a candidate writes a new version into the Decision Index, the part of the memory file that keeps every version of every decision and each decision's lifecycle status, such as active or superseded. Acceptance does not turn on enforcement. A person activates the rule in a separate step. A person must run the command to accept, but the index does not record which person: it stores each version and its source, not an approver's name.

The CI job reads its decisions from the PR's own checkout, so an agent that can edit the ADRs, the memory file or the workflow can weaken what it enforces. That weakness in Mneme's own check is the same exposure as Anthropic's weakened assertions, and the protection we recommend is required owner review on those files. We have not run Mneme on a migration like Anthropic's.

Frequently asked questions

What did Anthropic migrate to Rust?+
Its Messages API, the service behind requests to Claude models, from Python to Rust. Claude wrote a first version of the core request path in about a week, and public traffic moved to Rust in September 2026. Anthropic reports about 70% less CPU and more than 80% less memory per request.
Why was a 98% test pass rate not enough?+
In April the Rust API passed about 98% of its tests while only about a quarter of production inputs matched the Python version. The tests covered a small part of the possible request combinations, and an audit of the ported tests found more than 100 weakened assertions.
What did the verifier miss in the web search case?+
An agent copied a tool description into local files instead of having Rust call the internal service that supplies it. The outputs matched and the local verifier passed. An engineer rejected the fix because Rust had to call the service before launch.
Can Mneme require that new code calls a particular service?+
No. Every typed rule Mneme ships forbids something, most often an exact piece of text, optionally limited to certain paths. It can block a known shortcut, such as a path that must not appear in the new code, but a requirement to call a service stays with tests and review.