Anthropic Let Claude Agents Rewrite Its Messages API in Rust

Stackademic

Claude-driven migration cut CPU per request and tightened time-to-first-token latency while engineers reviewed agent-generated diffs against live traffic.

Why the Messages API had to move

On November 25, 2026, Anthropic published a detailed engineering account of how it moved the Messages API—the front door for Claude—from Python to Rust. The API is not a side channel. It is how enterprises, developers, and Anthropic’s own products, including Claude Code and Cowork, reach the models. Traffic on that path grew by roughly eighteen hundred times between early 2024 and autumn 2026, according to the company. A Python stack that made sense at a smaller scale became a tax on every request: more CPU, more memory, and longer waits before the first token streamed back.

Rust was the obvious direction for the next phase of that growth. Anthropic’s engineers expected lower per-request compute and tighter control over latency-sensitive paths. What was less obvious was how to port a live, continuously changing production service without freezing feature work or taking an outage. The team turned to Claude itself—not as a demo, but as labor on the migration. Agents drafted large portions of the Rust implementation and, later, chased parity bugs surfaced by production traffic. Human engineers remained in the loop, reviewing agent-produced diffs and deciding what shipped.

Agents wrote code; humans wrote the trust model

Anthropic reports that Claude produced a first cut of the API’s core request path in about a week. That speed did not translate into instant confidence. Passing unit tests was necessary but insufficient. In April, the Rust port cleared roughly ninety-eight percent of its automated tests, yet only about a quarter of shadowed production inputs matched the Python implementation byte-for-byte across every stage of handling.

The gap reflects how production differs from a test suite. Tests count each case once; live traffic repeats the same failure modes thousands of times. Production also surfaces corners that fixtures miss. One example Anthropic highlights is JSON encoding for tool calls: Python’s encoder escaped certain Unicode characters, such as emoji, into escape sequences, while early Rust code wrote the characters literally. A customer might never notice a few bytes in a tool schema, but the mismatch broke strict parity checks and could, in principle, change model behavior downstream.

Nondeterminism compounded the problem. Claude does not guarantee identical outputs for identical inputs, so you cannot shadow a live request through two stacks and compare final assistant text. Anthropic’s workaround was to run the model once, then replay the same model output through both the Python and Rust pipelines. With the stochastic step fixed, every pre-model and post-model stage had to match exactly.

Turning production into the verifier

The verification design had to respect privacy. Engineers could not simply read customer prompts and completions to diff them. Instead, Anthropic built checkpointing and fingerprinting: each request flows through the same ordered steps—validation, settings resolution, prompt assembly, and so on—and the system compares intermediate artifacts without exposing raw text at human-readable scale.

When Rust and Python diverged, logs recorded the shape of the difference: which stage failed, how large the delta was, and clustering metadata. A single bug could generate hundreds of thousands of nearly identical records. Rather than feed each line to an agent, a batching job every ten to thirty minutes grouped fingerprints and opened work items for worker agents.

Those agents operated in a loop that mirrors how modern software teams handle incident queues, except the triage and patch drafting were largely automated. Fast sandbox checks attempted to reproduce issues from minimal reproduction hints. Proposed fixes returned to the shadow path and had to survive replay against production traffic patterns. Engineers reviewed the resulting diffs before merge. Anthropic’s post is explicit that trust came from this layered verification, not from model confidence in its own Rust.

The approach also had to respect billing and rate limits. Shadowing cannot double-charge customers or double-count usage. The migration team treated “run twice safely” assumptions as false and engineered around them.

What shipped and what improved

Anthropic says the Rust Messages API is now in production without a customer-facing migration window or a feature freeze on the Python era’s pace of change. Measured on production workloads, the company reports about seventy percent lower CPU per request and a roughly twenty percent reduction in median time to first token. Internal users of Claude Code saw the latency improvement on the path they feel most acutely: the gap between sending a message and seeing the model begin to respond.

Memory use also fell sharply—Anthropic cites more than eighty percent in some summaries of the work—though the headline numbers emphasized CPU and first-token latency because those map directly to cost and perceived responsiveness at scale. When traffic multiplies by orders of magnitude, a double-digit percent cut in time-to-first-token across a huge request volume is the difference between building another datacenter footprint soon and buying headroom for the next product launch.

Industry coverage on November 25–26 framed the story as “Claude rewrote the API that serves Claude,” but the technical narrative is more interesting than that headline. The hard part was not syntax translation from Python to Rust. It was maintaining parity while Python continued to evolve, while privacy rules forbade naive debugging, and while the verifier had to reason about a nondeterministic model in the middle of the pipeline.

Implications for agent-assisted engineering

Anthropic’s write-up lands in the middle of a broader debate about autonomous coding agents in critical infrastructure. Skeptics point to the April mismatch—high test pass rate, low production match rate—as evidence that agents excel at plausible code and struggle at edge cases. Supporters counter that the same post shows agents scaling the fix cycle once humans built the right oracle.

The oracle here was production itself, instrumented heavily. That is expensive and company-specific. A smaller team cannot necessarily replay eighteen-hundred-fold traffic growth or afford the engineering months Anthropic implied across 2025 and 2026. Still, the pattern—agents generate, production or high-fidelity shadow verifies, humans approve—may become a template for other latency-sensitive control planes at model vendors and cloud providers.

For customers, the migration is mostly invisible if parity holds. SDKs and HTTP shapes stay the same; the change is under the hood. The visible effect is snappier streaming and, indirectly, capacity to add features without proportional cost growth. For competitors, the post reads as a capacity announcement dressed in research clothing: Anthropic is signaling it can keep investing in product velocity while rewriting foundations.

Open questions

Anthropic did not publish full agent autonomy metrics—what percentage of merged lines were agent-authored versus human-edited, or how many parity cycles ran before launch. External readers also cannot independently audit the shadow replay system. Trust rests on Anthropic’s description and on the lived experience of latency and availability after cutover.

Nor does the post claim Rust end states for every Claude-facing service. Messages is the primary customer API, not the entire surface area of inference, tooling, or internal batch jobs. Follow-on migrations, if any, would face their own parity stories.

What is clear as of November 26, 2026, is that one of the highest-traffic AI APIs in the market now runs on Rust, that Claude agents did substantial work under human review, and that the verification story—privacy-preserving, replay-based, clustered agent repair loops—is as important as the language choice. For teams building on Claude, the practical takeaway is modest but real: the path between their application and the model got faster and cheaper to operate. For teams building with agents on their own stacks, the takeaway is sharper: without a verifier as strong as production, agent-written rewrites remain risky no matter how quickly the first draft compiles.