Summary note: This post summarizes Anthropic’s official research article “Migrating our Messages API to Rust” (November 25, 2026), not a reprint. Original link: https://www.anthropic.com/research/migrating-api-to-rust
Note: At check time (around 09:00 on November 27), x.com returned HTTP 403 across the site, so related discussion posts could not be opened. Details, statuses, and figures here follow Anthropic’s official article, except the memory figure, which is noted separately.
Anthropic moved the Messages API behind Claude from Python to Rust. When it launched in 2023, the API was little more than a “request forwarder”; by the fall of 2026, API traffic had grown roughly 1,800 times since early 2024, and Python’s overhead could no longer carry it. The result: about 70% less CPU per request and about 20% lower median time to first token, with public traffic switched over in September 2026, the service never taken offline, and feature development never frozen.
Image source: Illustration from Anthropic’s official article
Why migrate? The incremental route was not enough
By late 2025, every Messages API request had to be validated, converted into a prompt, tokenized, and screened by safety classifiers, and the stream of reply tokens had to be sorted into text, thinking content, and tool calls. Python paid overhead at every step as it created objects, freed memory, and handed work to the next task.
The team tried the incremental route first: rewriting only the code that parses model output in Rust and calling it from Python. CPU fell just 8% to 10%, and the added complexity was not worth it — each token crossed between Python and Rust three times. The gains did not justify the cost.
What changed the calculation was Claude’s own capability. By May 2026, Claude was writing more than 80% of the code Anthropic merged. Writing new code was no longer the bottleneck. The bottleneck became proving that the new code behaved exactly like the old system.
Verification is the bottleneck: the test suite could not be trusted
The article starts from a “generator–verifier gap”: for many tasks, verifying a solution is far easier than finding one. Math proofs have proof assistants like Lean checking each step; in software engineering, the test suite is the verification tool. But in this migration, the test suite was not enough, for two reasons:
- The tests were coupled to the Python implementation. The existing set of about 700 integration tests ran the Python API inside the test’s process and mocked services like billing and rate limiting in Python’s memory. 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 changed in a way that let wrong code through. Auditing the ported tests turned up more than 100 weakened assertions.
- The tests were incomplete. The Messages API has dozens of features, and the combinations cannot be tested exhaustively. Just 20 binary options make over a million combinations — 12 days of tests at a second each, for one model, before varying the prompts inside them. Engineers could only test a subset approximating production, and gaps were inevitable.
So the team changed approach: use the running production system itself as an oracle, comparing old and new versions with shadow traffic.
Image source: Illustration from Anthropic’s official article (Figure 2 in the original)
Shadow traffic: 98% of tests passed, but only about 24% of production inputs matched
In April 2026, the Rust API passed about 98% of its tests, yet only about a quarter of production inputs matched the Python output. The gap came from production cases the tests did not cover. For example, when Python writes JSON tool calls, it escapes certain characters (such as an emoji) by replacing them with text codes; Rust wrote those characters as is, so the two prompts differed by a few bytes. A single request still succeeded and the model still answered — sometimes with minor differences.
Shadow comparison also had to solve two practical constraints:
- Each request could only count once. A user request could not be billed and counted against limits twice, once per version.
- Model output is nondeterministic. The same input can produce different replies from Claude, so a difference between two outputs did not necessarily mean a bug. The fix: run the model once and replay that same output through the Rust version, then compare every stage before and after the model call step by step.
Privacy imposed another limit: the team could not read user requests or Claude’s replies, so it could only record the shape of each difference — where it happened in the service and how big it was. Two techniques made that work:
- Checkpointing: Both versions handle a request in the same steps (accept or reject it, resolve its settings, build the prompt…). Comparing each step’s output, piece by piece within the prompt, roughly located where the migration code differed from production code.
- Fingerprinting: Recording where each difference began in the prompt plus the length difference between the two versions. One bug tends to leave the same fingerprint on every request it affects, so errors could be grouped by fingerprint and the fixes triaged by impact.
Three loops: inner, outer, and memory
Every 10 to 30 minutes, a script grouped diff 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 own each new kind and opened a thread in a shared Slack channel where human engineers could follow along and steer. Fixing bugs ran through three loops:
- Inner loop (fast): Each agent ran in a cloud sandbox holding both codebases, with fast local checks for what happens before and after the model call. The input check never called the model — it built the prompt each version would send and showed what differed, in under a second. The output check ran both versions against a scripted model reply, such as a tool call. The agent would hypothesize a cause, write its own request or model reply to reproduce the difference, and try again if the guess was wrong; if the results differed the same way the record described, it edited the Rust code until the two versions matched, then added a test that failed on the old code and passed on the new one. Inside the sandbox, a wrong guess cost only a few seconds and had no impact on users.
- Outer loop (slow): A fix could cross into the outer loop only after PR review. The outer loop compared Rust API deployments with and without each fix on shadowed production traffic. The inner loop simulated production quickly but imperfectly — it used requests the agent wrote itself and a local verifier that was not always configured exactly like production — so some problems only showed up here. When a fix passed in the sandbox but production still showed the difference, the assigned agent went back to the inner loop with the new evidence.
- Memory loop (outermost): Review outcomes and agents’ own work were recorded as rules every later agent could read. In mid-May, one of the largest remaining differences came from web search: the production API fetched the web search tool’s description from an internal service, and the Rust API did not call that service yet. An agent proposed a shortcut — copying the text into files Rust could read. The prompts matched and the local verifier passed, but an engineer turned it down: Rust would still need to call the service before launch, and the workaround would be thrown out. The agent saved a note to memory explaining the decision, the reason, and the correct fix, so later bugs with new fingerprints from the same missing text were linked to the known issue instead of getting another workaround. In June, an agent went through about 60 of the team’s review comments, grouped the recurring problems, and proposed rules that an engineer edited and approved for CLAUDE.md. On another occasion, an engineer made it a rule to port exactly what Python did, never guess; an agent comparing code against that rule found seven more places where the port had relied on a guess. The memory loop also encoded lessons in permanent checks: new tests that failed when Rust drifted from Python, lints banning patterns reviewers kept flagging, and a merge check requiring anyone changing Python code to make a matching change in Rust or request an exemption.
One lesson worth remembering: a verifier can tell an agent whether the outputs matched, but not whether the fix is good enough to ship. The verification signal rewards the cheapest way to make outputs match; human review was the gate that mattered.
Results and takeaways
Public traffic moved to the Rust service in September 2026. Per Anthropic’s production charts, CPU per request fell about 70% and median time to first token dropped about 20% (measured on Claude Code requests over a shorter window than the other metrics). InfoWorld separately reported memory use down about 80%.
The article closes with the Ship of Theseus: the usual migration is like rebuilding a ship 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 keeps sailing and having its planks replaced — with agents keeping the new ship in step as the old one changed, and checking that the two behaved the same. Once trusted, passengers were moved over a few at a time. The new ship sails faster and more efficiently than the old one.
The authors’ five lessons:
- Verification is the new bottleneck. When writing code is no longer the hard part, how quickly you can verify results sets how ambitious you can be.
- Verification is how you earn confidence. Math uses proof assistants, software uses tests or formal verification; when those checks are not enough, a production system itself can also be a verifier.
- Carefully design the verification signal. A proof assistant points to the failing step and a test names the failing case; a production system offers no such signal by default — much of this project’s effort went into building one, with checkpoints locating each difference in the code and fingerprints telling one bug from another.
- Build loops that let Claude autonomously act on the signal. A fast inner loop, a slower outer loop, and a memory loop that saves corrections as rules. Simple loops around strong verifiers scale with Claude’s capability.
- Move toward outer loops. At first engineers worked inside the inner loop, running Claude and chasing differences themselves; later they moved to the seam between loops, steering agents and reviewing fixes in Slack; as the system matured, they moved to the edge, writing the rules and checks agents worked within. Humans stayed mainly for the judgment calls about what counts as correct.
Written by

