DEV Community

Dean Lee
Dean Lee

Posted on Originally published at deanlee.info

Before an AI-assisted rewrite, budget for verification

Before budgeting an AI-assisted service rewrite, account for how you will compare the new service with the old one. Anthropic’s Messages API migration shows why a passing test suite and a fast first draft can leave a substantial verification bill.

Anthropic's account of its Messages API migration gives the argument for attempting it. The company says Claude wrote a first version of the core request path in about a week. After moving the API from Python to Rust, Anthropic reports roughly 70% less CPU per request and about 20% lower median time to first token. The CPU measurement covers one region; the latency comparison covers Claude Code requests over a shorter period. Those are company-reported operational measures, not a calculation of total company costs or customer savings.

For a provider handling growing traffic, a lower cost per request can compound. Anthropic says its average daily API traffic, including its own use, grew roughly 1,800-fold from early 2024 to fall 2026. An earlier partial rewrite of the output parser cut API CPU use by about 8% to 10%, but moved each token between Python and Rust three times. Anthropic judged that the smaller gain did not justify the complexity.

The full migration's bargain was different. If the new service could preserve behavior, lower recurring infrastructure use might justify a larger upfront effort. But the apparent speed of the first draft did not tell a buyer what that effort would cost.

The pass rate that hid the work

Anthropic had about 700 integration tests. In April, the Rust API passed about 98% of its tests, while only about a quarter of inputs matched the Python service on the production traffic being compared. These measures have different denominators: test cases are not production requests. A common bug can affect many requests, and tests cannot cover every combination of features.

There was another complication. Claude helped port both the code and tests, and Anthropic says an audit found more than 100 weakened assertions. A passing test could reflect a correct migration or a check that no longer caught the difference. For a team budgeting an agent-assisted rewrite, the cost of reviewing the test changes belongs in the project alongside the cost of generating code.

Anthropic compared the two API versions using shadowed traffic. Since model responses vary, the team ran the model once and replayed its output to the Rust version, comparing stages around the model call. It also had to prevent a shadow request from counting twice against customer billing or limits. The team says it worked without reading customer request text or model replies, recording information about where and how outputs differed instead.

Those comparisons supplied agents with leads. An agent could form a hypothesis, write its own example and test a proposed fix locally. Engineers reviewed fixes before deployment, and comparisons on production traffic provided another check. This is substantial infrastructure and review work. Anthropic does not give a complete project cost or a counterfactual for a human-only migration, so the account cannot establish the overall savings from using agents.

Matching behavior has a price

The production comparison itself did not decide which fix was fit to ship. In one example, the Rust API omitted a web-search tool description that the Python service retrieved from an internal service. An agent proposed copying the text into local files, which made prompts match. An engineer rejected the shortcut because the new API would still need to call the service before launch. Anthropic says building that call took weeks.

That example changes the economics of review. A cheap local check can reject many bad guesses quickly, but a reviewer still has to judge whether a fix preserves the purpose of the system. Matching the old service also preserves its quirks; any deliberate change needs a different standard. The more moving parts the old service has, the more a migration budget needs room for exceptions and changes while the work proceeds.

There is a practical decision for teams considering a similar project. Estimate the recurring infrastructure benefit separately from the cost of building a trustworthy comparison, reviewing fixes and maintaining two implementations during migration. If traffic is low or the old system is difficult to compare safely, a smaller optimization may be the better purchase. If traffic is high and behavior can be measured without exposing customer data or duplicating side effects, the larger rewrite has a stronger case.

Anthropic captures the immediate reduction in its own API's CPU use. Whether customers later see lower prices is a separate commercial decision; the company does not report such a price change in its migration account. The measured speed gain reaches a narrower group of Claude Code requests. Neither number tells another team what its own verification bill will be.

Top comments (0)