Anthropic 如何将 Messages API 从 Python 迁移到 Rust
- 核心提炼:Anthropic 将 Messages API 从 Python 迁移到 Rust,每请求 CPU 用量降低约 70%,首 token 中位延迟缩短约 20%,全程未停服也未冻结功能开发。
- 编辑部看点:原文给出把生产系统本身当作验证器、用检查点和指纹定位差异并让智能体自动修复的迁移方法,可复用于其他大型系统重写。
- 频道与评分:tip · 质量评分 69 分 · 来源 Anthropic:Research
情报档案
本帖由 AOB 情报系统同步至 BBS 讨论区,欢迎在下方展开技术拆解、实测反馈与延伸讨论。
完整原文内容
完整原文共 24,000 字Many problems have a generator–verifier gap: it’s often far easier to verify that a solution is correct than to come up with one. Sudoku is a classic example. It’s simple to check the solution (just count the numbers in each row, column, and box), but finding that solution can take a long time. Many ambitious Claude projects have relied on this gap: formalizing proofs in mathematics or migrating large, well-tested codebases are tasks Claude can take on as long as it has a reliable way to verify its work. But as Claude has become more capable, it’s begun to take on projects in live systems, where generating the work is easier than verifying it. In these systems, users often rely on edge cases and quirks that fall outside the test suite , and it’s hard to write a definition of “correct” that covers everything . Without a reliable way to check Claude’s work, the migration of a live system is hard to trust—however quickly Claude can generate the code for it. We ran into this problem when we migrated our Messages API from Python to Rust. This API is the primary way that customers—as well as our own apps, like Claude Code and Cowork—reach Claude. From early 2024 to fall 2026, API traffic grew roughly 1,800 times. Rust would allow us to use far less CPU per request. Claude wrote a first version of the API’s core request path in about a week. But building trust in the migration required us to find a way to verify that our Rust API was at parity with our production API. This proved hard for several reasons, including that the Python API continued changing throughout the migration, so parity was a moving target; Claude can reply nondeterministically to the same request, so a difference between two outputs didn’t necessarily mean a bug; and we couldn't read customer requests, so w…