OrchestriAI
Back to the field guide
AI systemsGuide8 min read

How Anthropic verified a rewrite that AI wrote

Anthropic rebuilt its busiest API in Rust with Claude writing the code. One input in four matched at first. How it reached 99.6% and what to copy.

Letting an agent change a system you depend on?

Free. Three short fields, and we reply by email within one business day.

By Shariq Riaz

In this guide

Anthropic rebuilt its busiest API in Rust with Claude writing the code. One input in four matched at first. How it reached 99.6% and what to copy.

7 sections1 cited source8 min read
On this page7 sections
  1. What happened
  2. Why green tests were not enough
  3. How Anthropic verified the rewrite
  4. The review gate that mattered
  5. What a business should copy
  6. When this applies and when it does not
  7. How we use it

Anthropic moved its busiest API from Python to Rust this year, and Claude wrote most of the code. The useful part of the story is not the code. It is how Anthropic proved the new version behaved like the old one before trusting it.

If your business is thinking about letting an agent change a system you depend on, a billing integration, a data pipeline, an internal tool, the verification pattern here is the part worth copying.

This post covers what Anthropic did, why its test suite was not enough, and what the same pattern looks like at small-business scale.

What happened

Anthropic published the engineering write-up on November 25, 2026. We read the migration post on November 28, 2026. Everything in this section comes from it.

The Messages API is the main path customers, Claude Code and Cowork use to reach Claude. Anthropic says traffic grew roughly 1,800 times from early 2024 to fall 2026. The service was written in Python in 2023, and a partial Rust rewrite in March 2026 cut CPU use by about 8 to 10 percent, at the cost of each token crossing between Python and Rust three times.

Claude wrote a first version of the API's core request path in about a week. By May 2026, Claude was writing more than 80 percent of the code Anthropic merged, by Anthropic's own count. Public traffic moved to the Rust API in September 2026 without downtime and without freezing feature work. Anthropic reports the Rust version uses about 70 percent less CPU per request and over 80 percent less memory, and cuts median time to first token by about 20 percent on Claude Code requests.

Why green tests were not enough

Anthropic had about 700 integration tests, and two problems made them weak proof for a migration this size.

First, the tests were coupled to the Python code. They ran the Python API inside the test process and mocked its services, so porting them meant changing them. Claude helped with the porting, and a later audit of the ported tests found more than 100 weakened assertions. A pass could mean the code was right, or that the test had been loosened enough to let wrong code through.

Second, the tests were incomplete. The API has dozens of features, and Anthropic notes that just 20 binary options make over a million combinations. The Rust build passed about 98 percent of its tests in April, yet only about a quarter of inputs matched the Python API on production traffic. Live traffic also weights bugs differently: a test counts each case once, while one common bug shows up in every request it touches.

We'll set up the side-by-side check that compares old and new on real inputs, and keep your sign-off on every change that ships.

How Anthropic verified the rewrite

Instead of trusting the test suite, the team used the production API itself as the oracle and shadowed real traffic through both versions.

Two details made that work. The model ran once and its output was replayed to the Rust side, so Claude's nondeterministic replies did not count as bugs. And each shadowed request had to count only once toward a customer's limits and bill, which ruled out the usual tools that assume a request can safely run twice.

The team also could not read customer requests or the replies, so it recorded the shape of each difference instead of the text: the step in the request path, the piece of the prompt, the first differing byte, and the two lengths. One bug leaves the same fingerprint on every request it touches, so records could be grouped by fingerprint. A script grouped new differences every 10 to 30 minutes, and a coordinating agent handed each new kind to its own worker agent while engineers followed along in Slack threads.

Input matching climbed from about 24 percent to 99.6 percent by August, with a dip to 6.5 percent in early May as the comparison widened.

The review gate that mattered

Agents worked in a sandbox with fast local checks and proposed fixes as pull requests. A fix crossed into production validation only after a human reviewed it.

That gate caught real problems. Anthropic describes an agent that proposed copying the web search tool's description into files Rust could read. The prompts matched and the fix passed the local verifier, but an engineer rejected it because Rust still had to call the real service before launch. The verifier rewards matching output, not a fix worth shipping.

Corrections then became rules. About 60 review comments were grouped and edited into CLAUDE.md rules for the agents that followed. One rule, applied as a code search, found seven more places where the port had guessed at Python's behavior. A later merge check required anyone changing the Python code to make the matching Rust change or request an exemption.

What a business should copy

You do not need Anthropic's traffic to use the pattern. When an agent changes a system your business already runs:

1. Keep the current system as the oracle. Run the old and new versions on the same real inputs and compare. A test suite covers what someone thought to test. Production traffic covers what actually happens.

2. Compare behavior, not green lights. Anthropic's build passed 98 percent of tests at roughly one in four parity. Passing tests and matching behavior are different claims.

3. Audit the tests when the same agent edits code and tests. More than 100 weakened assertions slipped into a careful team's suite. If your agent writes both, someone has to check the checks.

4. Keep a person as the merge gate. A verifier can confirm the outputs match. It cannot confirm the fix is one you want to live with.

5. Turn review comments into standing rules. The corrections are cheap to keep and they stop the same class of mistake from coming back.

When this applies and when it does not

This pattern fits agent-written changes to a system the business already runs: an integration, a sync, a billing path, a rewrite or migration where "the same as before" has a meaning you can measure.

It does not fit a brand new workflow with no existing system to compare against. That needs pre-launch testing instead; see testing AI agents before production. And a low-stakes internal script does not justify shadowing at all.

How we use it

When we build or rebuild automations for a client, the running workflow stays the reference. Where the systems allow it, we compare old and new on the same real inputs, and the client's sign-off gates what goes live. The details change with the systems involved, but the rule does not: the agent proposes, something outside the agent verifies, and a person approves the change that ships.

If you are weighing an agent-built change to a system your business depends on, the verification design is the part to get right first. Book a free automation audit and we will map where this pattern fits, or see how we run custom development and AI agent work.

Related reading: when human review becomes a rubber stamp, Claude Code Review for agent-written pull requests, and custom internal tools versus SaaS.

Free. Three fields. We reply within one business day.

Letting an agent change a system you depend on?

We'll set up the side-by-side check that compares old and new on real inputs, and keep your sign-off on every change that ships.

You'll talk to Shariq. Replies come from shariq@orchestriai.com. Leave out passwords and patient records.

What happens next

  1. 1.You send one line about the task.
  2. 2.Shariq reads every message and replies by email within one business day.
  3. 3.If it fits, you get a written plan or a short call. Your choice.
  4. 4.If it does not fit, we tell you and point you to a better option.
“Shariq built our Open Dental to GoHighLevel sync and our AI routing system for new patient inquiries. Both projects were delivered fast, worked right away, and he was responsive whenever we needed adjustments. He understands dental practice workflows and doesn't overcomplicate things.”
Michael Ling, Owner, Smile Again Dental

References used in this article

1 links
Shariq Riaz, founder of OrchestriAI

Written by

Shariq Riaz

Founder, OrchestriAI · CPHIMS · PMP · CBAP

11 years in enterprise IT at Fortune 500 companies. He founded OrchestriAI, an AI automation agency that builds and runs automations and AI agents for healthcare, real estate, financial services, and freight forwarding teams.

Free automation checklist

Free automation checklist for your industry

A one-page checklist of the manual work clinics, real estate teams, financial firms and freight forwarders most often automate. Pick your industry and tick what is still done by hand.

Or read it now, no email needed: Healthcare & dental automation checklist.

Your email comes only to us. No spam, and we never sell it. See the Privacy Policy.

Want this built for you? Custom Development: From $3,000/project

We build web portals, admin dashboards, and client-facing apps to your exact spec when another subscription will not solve the problem.

Not sure it fits yet? Send us one manual task and we'll email back one specific way to automate it, free.

Keep reading