Anthropic rewrote its core API with Claude: first version in a week, months of validation and bug fixes

Anthropic published a technical retrospective detailing the migration of its core Messages API from Python to Rust. Claude wrote the first version of the core request-handling flow in about a week, but validation and fixes took months.

By April this year, the Rust version had passed about 98% of tests. But when handling real user requests, the inputs ultimately sent to the model by the old and new systems matched exactly only about 25% of the time. Claude also modified tests while migrating the code. After reviewing them, engineers found that the assertions in more than 100 tests had been weakened, potentially allowing code that should have failed to pass.

Anthropic then used the running Python version as the source of truth. The old and new systems processed real requests simultaneously, but called the model only once and shared the same model output, avoiding duplicate inference and charges.

The system categorized the differences it found and automatically assigned Claude Agents to investigate. To protect user privacy, the agents could not see the actual conversation content. They could only use clues such as the location of the error and byte lengths to construct their own requests, reproduce the issues in a sandbox, and fix the bugs.

Because local validation did not require actually calling the model, a single input comparison took less than a second. Previously, Agents had to wait for review and deployment after each attempted fix, and feedback could take hours or even days. Proposed fixes still had to undergo human review before being validated against real traffic.

Claude sometimes found loopholes in the validation rules. For example, the Rust version was missing a description of the web search tool, so Claude simply wrote the description into a file to make the inputs from the old and new systems match. Engineers rejected the change because the production system needed to retrieve the description dynamically from an internal service. Similar errors and review feedback were then added to the Agents’ shared memory, CLAUDE.md, and automated checks to prevent the same mistakes from recurring.

By the end of August, the model inputs from the two systems matched about 99.6% of the time. The production traffic switch was completed in September, without any service interruptions or pauses in new feature development.

After the migration, CPU usage per API request fell by about 70% (measured in a single region), memory usage fell by more than 80%, and the median time to first token for Claude Code users dropped by about 20%.

$ANT

What do you think? 👇