Anthropic has replaced the Python code at the heart of its Messages API, the service that answers every request sent to Claude by outside developers and by its own Claude Code and Cowork apps, with a new version written in Rust. In a post published on 25 November, the company said teams of Claude agents did most of the work, and that the new service uses about 70% less CPU for each request.

The post is unusual because it describes a live, high-traffic system being rewritten mostly by AI, and it spends far more time on how the result was checked than on how the code was produced. Anthropic says traffic to the API grew roughly 1,800-fold between early 2024 and autumn 2026.

The finding

The original API was written in Python in 2023. Each request has to be checked, turned into a prompt, split into tokens and screened by safety classifiers, and every token the model streams back has to be labelled as text, thinking or a tool call. Anthropic says the cost of running each of those steps in Python was a main reason for the change.

Writing the new code turned out to be the quick part. According to the post, Claude produced a first draft of the core request path in about a week. Proving that the Rust version behaved exactly like the Python one took months.

"Verification, not generation, had become the bottleneck."Anthropic engineering team, Messages API migration post

How it was done

Anthropic first tried a smaller step in March 2026, calling a Rust parser from Python. That cut CPU use by about 8% to 10%, but each token had to pass between the two languages three times, so the team chose a full rewrite instead.

Tests alone were not enough. The API has about 700 integration tests, and Claude helped port them, but an audit later found more than 100 checks that had been weakened along the way. The company also notes that 20 simple on-off settings already produce over a million combinations.

"Our Rust API passed about 98% of its tests in April, yet only about a quarter of inputs matched on production traffic."Anthropic engineering team, Messages API migration post

From April, real requests were also sent through the Rust version in "shadow" mode. The model ran once and its output was replayed into Rust, so both versions handled identical data. Anthropic says the team did not read customer requests or replies; it stored only a short fingerprint describing where the two versions differed.

  • A coordinating Claude agent was alerted whenever a new kind of difference appeared and handed it to a worker agent.
  • Workers ran in cloud sandboxes with both codebases, reproduced the difference, changed the Rust code until the outputs matched and added a test. Every change went through pull request review.
  • Engineers followed each kind of difference in its own Slack thread, and their corrections were saved as rules for later agents.
  • A merge check now requires a matching Rust change whenever someone changes the Python code, unless an exemption is given.

Results

MeasureChange after the move
Inputs matching between the two versionsFrom 24% (low of 6.5% in early May) to 99.6%
CPU per requestAbout 70% lower (one region)
Memory per requestMore than 80% lower (all of production)
Median time to first tokenAbout 20% shorter (customers' Claude Code requests)

Public traffic moved to Rust in September 2026. Anthropic says the service never went offline and new features kept shipping during the move.

Limits stated by the authors

The company is candid that matching outputs is not the same as good code. In mid-May an agent suggested a shortcut for web search that passed the automated comparison, and an engineer turned it down because it would have had to be rebuilt later. Human review, the post says, remained an important gate. The figures are percentages only: Anthropic gives no cost saving, no absolute speeds and no total size for the new codebase, and the 99.6% match rate covers inputs, with replies compared separately.

Earlier this week Anthropic also launched Claude Ship, its tools for reviewing and fixing pull requests.

Announced by Anthropic on its engineering research blog: read the announcement

TopicsAI CodingAI AgentsAnthropic