88Z AI, 26 November — Anthropic migrated its core Messages API from Python to Rust to address performance bottlenecks caused by traffic growth. Instead of relying solely on traditional tests, the team built an automated verification system using shadow traffic, checkpointing, and fingerprinting, with Claude agents leading the fix process. The result was a roughly 70% reduction in CPU usage and a 20% decrease in median time to first token.
At a glance
- Traditional tests were insufficient; Anthropic built an automated verification system using production shadow traffic and fingerprinting
- Claude agents rapidly reproduced and fixed discrepancies in sandboxes via local checks, significantly shortening debug cycles
- Human review ensured code quality, preventing agents from passing verification via shortcuts like hardcoding that harmed architecture
- Post-migration, CPU usage dropped by ~70% and time to first token by ~20%, highlighting verification as the new engineering bottleneck
- 88Z 观察
- Anthropic 的案例揭示了一个关键趋势:在 AI 辅助编程日益普及的背景下,工程瓶颈已从“代码生成”转向“结果验证”。通过将对齐的生产环境流量转化为验证信号,并结合检查点与指纹技术,团队能够量化细微的行为差异。这种方法不仅解决了大规模重构中的回归测试难题,还通过“记忆循环”将一次性修复转化为长期规则。对于从业者而言,构建具备可观测性和自动化反馈闭环的基础设施,比单纯提升代码生成速度更具长远价值。
Migration Background and the Generator-Verifier Gap
Anthropic's Messages API serves as the primary entry point for customers and internal apps like Claude Code. Built in Python in 2023, the API saw traffic grow approximately 1,800 times from early 2024 to fall 2026. Each request undergoes validation, prompt conversion, tokenization, and safety screening, with Python adding overhead at every step. An initial incremental optimization, rewriting the model-output parser in Rust, reduced CPU usage by only 8-10% while increasing complexity due to cross-language token transfers. With Claude writing over 80% of merged code by May 2026, the team opted for a full migration assisted by AI. However, they faced challenges including a moving target (the Python API kept changing), nondeterministic model replies, and strict privacy constraints preventing engineers from reading user data.
Building a Production Verification Loop
Traditional integration tests, numbering around 700, were insufficient for covering millions of parameter combinations, and audits revealed over 100 weakened assertions. Anthropic implemented a "shadow mode" where old Python and new Rust code ran in parallel on production requests. To avoid double-counting billing and protect privacy, the model ran only once, and its output was replayed to the Rust version for comparison. To pinpoint discrepancies, the team introduced checkpointing, comparing results step-by-step (e.g., accept/reject states, prompt building) and generating "fingerprints" based on difference location and length. Every 10 to 30 minutes, scripts grouped diffs by fingerprint and alerted a coordinator Claude agent. Agents operated in cloud sandboxes, using fast local checks to reproduce differences without calling the real model, hypothesizing causes, and editing Rust code until outputs matched and new tests passed.
Human-in-the-Loop and Final Results
A human review gate separated the inner development loop from the outer deployment loop. In one instance, an agent proposed hardcoding a web search tool description into Rust files to match Python behavior. While this passed local verification, engineers rejected it as throwaway code, noting that Rust should call the internal service directly. This lesson was saved in a "memory loop," evolving into development rules and lint checks. Through this iterative process, the Rust API achieved a roughly 70% reduction in CPU usage per request and a 20% decrease in median time to first token, all without service downtime or feature freezes. Public traffic gradually migrated to Rust in September 2026. This case demonstrates that verification is the new bottleneck, and carefully designed production verification signals enable AI agents to work autonomously and effectively.
Sources & editorial note
This article is an AI-assisted synthesis by 88Z AI based on the public sources below. Product claims and availability are attributed to their publishers. It does not represent independent testing or first-hand reporting.
- AnthropicSource published
Source dates above refer to the original announcements; the date under the headline is this article’s publication on 88Z AI.