News · AI Reliability & Operations · Legacy Modernization · Software Factories & AI-Assisted Engineering
How Anthropic verified its Rust rewrite of the Messages API
Anthropic says Claude wrote a first port in about a week, but proving it matched the Python service through shadowed production traffic took months.
On November 25, 2026, Anthropic published an engineering post about moving its Messages API from Python to Rust. The core of the post is how the new code was checked. Anthropic says it shadowed production traffic, replayed the same model output through the Rust path, and grouped every difference by a coarse fingerprint until the two versions agreed. According to Anthropic, Claude wrote a first version of the core request path in about a week, and verifying it took months.
What happened
Anthropic's engineering post on migrating the Messages API to Rust describes replacing a Python service Anthropic built in 2023. The Neuron covered the same write-up.
Anthropic says its existing safety net was not enough. The ported test suite of about 700 integration tests fell short on its own, and the company found more than 100 weakened assertions in it (Anthropic; The Neuron).
To get a stronger signal, Anthropic used its production Python API as an oracle. Through traffic shadowing, the model ran once and its output was replayed to the Rust path, so both versions handled the same real inputs (Anthropic). In late April about 24% of real inputs matched, according to Anthropic's chart. The Neuron describes that early figure as "about a quarter." Anthropic says the match rate reached 99.6% by August.
The grouping step is what made that progress manageable. Anthropic says each difference was grouped by a "fingerprint" built from the pipeline step, the prompt piece involved, the first differing byte and the lengths. Because of this, engineers did not have to read customer text. A script grouped the differences every 10 to 30 minutes and alerted a coordinating agent, which assigned them to worker agents (Anthropic).
Human review stayed a required gate. In one case described in the post, an agent optimizing for matching outputs proposed a shortcut for web-search tool descriptions, and an engineer rejected it.
The full rewrite was not the first attempt. Anthropic says an earlier partial port, which moved only response parsing to Rust, cut CPU by about 8 to 10%, and the company chose the full rewrite instead (Anthropic).
On the cutover, Anthropic says all public traffic moved to Rust in September 2026, with no downtime and no pause in feature work. The Neuron separately confirms only that customers kept using the API during the migration.
Anthropic says the rewrite uses about 70% less CPU per request and more than 80% less memory per request, with about 20% lower median time to first token (Anthropic). Anthropic's own figure caption states that the time-to-first-token figure is for customers' Claude Code requests. Anthropic also says API traffic grew roughly 1,800x from early 2024 to fall 2026, and that by May 2026 Claude was writing more than 80% of the code the company merged (Anthropic). No code, line counts or cost figures were released.
Why it matters
The write-up separates two steps that are often treated as one: producing code and showing that it behaves like the system it replaces. By Anthropic's account, the first took about a week and the second took months. For a public API that customers build on, the second step decides whether the migration is safe.
The test-suite finding sets the scale of the problem. More than 100 weakened assertions across about 700 integration tests, by Anthropic's count, means a passing run said less than it seemed to. Comparing against live behaviour avoids that, because the reference is what the production service actually returns, not what the tests happen to encode. The climb from about 24% matching in late April to 99.6% by August, both figures from Anthropic, shows how much divergence existed that the ported suite did not capture.
The fingerprint design covers two practical constraints. It lets engineers work through clusters of differences without reading customer text, and it turns a large volume of individual diffs into a smaller list of probable causes that can be assigned. In Anthropic's description, a script grouped the diffs on a short cycle and alerted a coordinating agent, which handed work to worker agents.
The rejected web-search shortcut shows the limit of a single metric. A match rate is a proxy for correctness, and an agent told to raise it can find changes that match for the wrong reason. Anthropic kept a person in the loop to catch that. Teams following AI Reliability & Operations practice will recognise the pattern: the measurement drives the work, and review guards the measurement.
The numbers also have limits. Every performance and traffic figure here comes from Anthropic, and with no code, line counts or cost figures published, outsiders cannot check them.
What the Transition2 desk tested
The Transition2 desk ran a small offline simulation of the verification method. It is not Anthropic's code, and it does not reproduce or verify any Anthropic number.
The desk wrote two server-sent-events (SSE) chunk reassemblers: a reference and a "port" with three switchable injected bugs. The first, utf8_split, sits at the tokenize step: a multi-byte character split across network chunks becomes replacement characters. The second, tool_delta_reorder, sits at the assemble step: a short first input_json_delta in a tool_use block is appended after the second. The third, trailing_newline, sits at the serialize step: on stop_reason == "max_tokens" the final message_stop frame loses its last newline. The run used 5,000 seeded random event streams (seed 42), split into random network chunks of 1 to 24 bytes. Outputs were compared at three checkpoints: tokenize, assemble and serialize. At the first checkpoint that differed, the fingerprint was the step, the first differing byte offset bucketed by 16, the sign of the length delta, and the kind of record holding the first difference. The grouping never used ground truth. Instrumentation recorded which bug fired and was used only to score the clusters.
Versions: Python standard library only, with no third-party packages and no network access. The experiment's notes list Python 3.9 or newer.
Results: 15 of 15 checks passed. The clean port produced 0 mismatches. The all-bugs port had a match rate of 62.16% (3108/5000), with 1892 mismatches in exactly 3 clusters. Each cluster was pure, mapped 1:1 to one injected bug, and sat at that bug's step: 883 cases for utf8_split, 584 for tool_delta_reorder and 425 for trailing_newline. Each single-bug port produced exactly one cluster with the same fingerprint, with 883, 681 and 603 mismatches respectively. Each mismatch is counted at the first checkpoint that differs, so cluster sizes in the combined run need not equal the single-bug runs. In a negative control, an offset-only fingerprint produced 2 clusters and failed to separate the bugs, as the check required. A naive "total lengths equal" assertion would have passed 515 of 1892 mismatching cases, all of them in the reorder cluster. A rerun produced the same digest, d9b79e3c087590ff.
CHECK clean_port_zero_mismatches: PASS mismatches=0
CHECK all_bugs_exactly_3_clusters: PASS clusters=['assemble|off0|len0|tool_use', 'serialize|off3|len-|message_stop', 'tokenize|off0|len+|text_delta']
CHECK negative_control_offset_only_fingerprint_not_1to1: PASS clusters=2 (must merge bugs)
CHECK naive_length_assertion_misses_real_diffs: PASS missed=515 of 1892 mismatches, by cluster={"assemble|off0|len0|tool_use": 515}
CHECK match_rate_nontrivial: PASS match_rate=0.6216
CHECKS 15/15
What this does not show: the run says nothing about Anthropic's CPU, memory, latency, traffic or match-rate figures, or about Rust, or about how Anthropic's real fingerprints and agents work. The fixture was designed so each bug has a stable signature, and real bugs can scatter across many offset buckets. The match rate depends entirely on the trigger rates the desk chose and says nothing about real systems.
What it means for businesses
For leaders weighing a modernization project with AI-written code, Anthropic's account points the budget at verification rather than authoring. A week to produce a first version and months to confirm it is the ratio the company reports. The method also depends on having a trusted production system to compare against and the infrastructure to shadow traffic safely, so it fits replacements of running services better than new builds. The fingerprint approach shows that correctness work can be organised without staff reading customer content, which matters for any team handling sensitive traffic. The human gate is the control that kept a metric-chasing shortcut out of production.
What it means for AI users
Anthropic's goal was for the API to behave as it did before, and The Neuron reports that customers kept using it throughout. The speed and efficiency gains are Anthropic's own figures. Anthropic's figure caption states that the time-to-first-token improvement is for customers' Claude Code requests. Users of the API are not asked to change anything in the coverage cited here.
What it means for developers
The transferable pieces are concrete. Use the existing system as an oracle. Compare at several internal checkpoints, not only at the end. Group differences by a coarse, content-free fingerprint so each cluster points to one cause. Audit ported tests for weakened assertions before trusting a green run. The desk's toy run illustrates the last point: a check on total output length passed 515 of 1892 cases that were actually different. When agents are optimizing a match rate, keep a human reviewer able to reject changes that hit the number for the wrong reason.
Copyright Eric MacDougall.
Sources
- Migrating our Messages API to Rust (accessed 2026-11-26)
- Anthropic Uses Claude to Rebuild Its API in Rust (accessed 2026-11-26)