subagentic.ai RSS X YouTube GitHub
AI-generated illustration

News

Anthropic checked a Rust Messages API against live traffic with Claude agent teams

Anthropic used live traffic and Claude agent teams to prove a Rust Messages API matched Python, cutting CPU about 70% without taking the service offline.

anthropicclaudeagentsrust

The durable news in Anthropic’s account of moving the Messages API from Python to Rust—covered by InfoWorld on November 25, 2026—is not the language change. Claude wrote a first version of the core request path in about a week. Proving that path matched a Python service that kept shipping models and features took shadow traffic, difference fingerprints, and teams of Claude agents. Engineers still rejected a fix a local verifier was willing to pass.

The Messages API is the primary way customers, and Anthropic’s own apps including Claude Code and Cowork, reach Claude. Anthropic built it in 2023 in Python. One engineer at the time called it “basically a request forwarder.” From early 2024 to fall 2026, API traffic grew roughly 1,800 times. By late 2025 every request had to be validated, converted into a prompt, tokenized, and screened by safety classifiers, and reply tokens had to be sorted into text, thinking, and tool calls. Python added overhead each time it created an object, freed memory, or handed work onward.

A partial Rust rewrite of output parsing, labeled March 2026 in Anthropic’s diagrams, cut CPU use by about 8% to 10%. Each token then crossed between Python and Rust three times, and the gain did not justify the complexity. The full rewrite, labeled September 2026 in those diagrams, has Python hand over the request and Rust do every other step around the model. The Rust API that shipped uses about 70% less CPU per request and cuts median time to first token by about 20%, without taking the service offline or freezing feature development. Anthropic’s charts place that median drop between roughly September 7 and 21, as requests moved.

Tests passed. Production did not match.

About 700 integration tests were the easy place to start, and a weak oracle. They ran the Python API inside the test process and mocked services such as billing and rate limiting in Python memory, so they were coupled to the implementation they were meant to judge. Claude helped change both the code and the tests. An audit of the ported tests found more than 100 weakened assertions. A pass could mean the port was right, or that the test had been loosened until wrong code got through. Coverage was incomplete as well. Twenty binary options alone make more than a million combinations—about 12 days of tests at one second each, for one model, before the prompts inside them vary.

In April the Rust API passed about 98% of its tests, yet only about a quarter of inputs matched on production traffic. A chart of compared inputs starts at 24%, drops to 6.5% in early May, then rises as fixes roll out, with two falls from changes on the Rust side, and ends at 99.6%. That line is the share of inputs that matched on the requests Anthropic compared. Replies were compared separately. The comparison began on Anthropic’s own traffic and later moved to a wider sample, and six days the team called misleading are left off the line. What was compared also changed over time.

Live traffic weighted bugs differently than a suite, where each case counts once. A common bug shows up on every request that triggers it. Some mismatches were only a few bytes. When Python writes JSON tool calls, it escapes certain characters—an emoji, for example—as text codes. Rust wrote those characters as is. The request still succeeded and the model still answered. Because Claude accepts almost any prompt, a small deviation can change a reply without raising an error.

A fingerprint, not the request

Shadowing—running requests through old and new code and comparing results—could not assume a request was safe to run twice, or that the service was deterministic. A shadowed copy had to count only once toward a customer’s limits and bill. Claude can reply differently to the same input, so two outputs can differ without either being a bug. Anthropic ran the model once and replayed that output to Rust, then required an exact match at every stage before and after the model call.

Engineers also could not read customer requests or Claude’s replies. They recorded the shape of each difference: the step, the piece of the prompt, the first differing byte, and the length on each side. Checkpointing found the first step that diverged. Combined with position and length, that shape was a fingerprint. One bug tended to leave the same fingerprint on every request it affected, so errors could be grouped without reading text.

A single bug could produce hundreds of thousands of nearly identical records. A script every 10 to 30 minutes grouped them by which fields differed and alerted a coordinating Claude agent only when a new kind appeared. The coordinator assigned a worker agent and opened a thread in a shared Slack channel so engineers could follow and steer.

Three loops, and a shortcut a human threw out

The inner loop gave each agent a cloud sandbox with both codebases and fast local checks. The input check built the prompt each version would send and never called the model, so a comparison took under a second. A later output check ran both versions against a fake model and a scripted reply, such as a tool call. Agents saw the fingerprint, not the request behind it. They guessed a cause, wrote their own request or reply, edited Rust until the two versions matched the way the record described, and added a test that failed on the old code and passed on the new. A wrong guess cost seconds and did not reach users. A fix entered the outer loop only after pull-request review. Engineers used that seam to decide what the verifier could not: bug, or deliberate change?

In mid-May, one of the largest remaining gaps was web search. Production retrieved the tool’s description from an internal service. Rust did not call that service yet, so the description was missing from prompts. An agent proposed copying the text into files Rust could read. The prompts matched, and the local verifier passed. An engineer rejected the change as throwaway code. Rust would still need to call the service before launch, and the workaround would be discarded. The verifier could tell whether outputs matched. It could not tell whether the fix was good enough to ship.

That correction was saved. The agent wrote a memory note with the decision, the reason, and the correct fix: have Rust call the service that supplies tool descriptions. Building the call took weeks. The bug kept producing records, some with new fingerprints, because the missing text fell at other positions or belonged to another tool on the same service. Later agents checked the note, recognized the known bug, and linked those records instead of writing another workaround.

Other review notes became rules. After one agent guessed at Python’s behavior, an engineer required the port to do exactly what Python did. Another agent then found seven more places where the port had relied on a guess. In June an agent went through about 60 review comments, grouped recurring problems, and proposed rules an engineer edited and approved for CLAUDE.md. The memory loop also became permanent checks: tests that fail when Rust drifts from Python, lints against patterns reviewers kept flagging, and a merge check that requires a matching Rust change, or an exemption, when Python changes.

The outer loop compared deployments with and without each fix on shadowed live traffic. Agents used logged facts about compared requests—model, prompt caching, tools, extended thinking—not the request text, and watched how often the fingerprint appeared. If it remained, the task went back to the inner loop.

Verification is the bottleneck

By May 2026 Claude was writing more than 80% of the code Anthropic merged, which is why a full migration looked newly tractable. In 2024, after one engineer suggested Go or Rust, another had closed the question the other way: “We are not rewriting the API in go or rust!” Anthropic’s post now treats generation as the cheaper part. The constraint is how quickly a new system can be shown to behave like the old one. When a written rule or a test suite is not enough, the production service itself can be the oracle—if you build a signal agents can act on. Checkpoints located each difference in the code. Fingerprints told one bug from another. Nested loops let agents use that signal, with people still gating what counted as correct.

InfoWorld’s November 25, 2026 recap, by Taryn Plumb, follows that no-downtime account and the CPU and time-to-first-token figures stated in the post. Summarizing the engineers, it says they put human judgment “only into what counted as correct,” and that as the system matured people moved from chasing differences inside the inner loop to writing rules and checks at the edge.

Read Anthropic’s post for the checkpoint diagrams, the example fingerprint record, and the three-loop figure before you borrow the pattern. Carry the cuts the post states in prose—about 70% less CPU per request, and about 20% lower median time to first token—and the web-search lesson with them: a verifier can reward the cheapest match, and a human still has to decide whether that match is a fix.

Sources