Migrating our Messages API to Rust
- ID: 9e640d54
- 原文链接: https://www.anthropic.com/research/migrating-api-to-rust
- 作者: Anthropic
- 日期: 2026-11-25
- 更新: N/A
- 分类: infra
- 来源类型: article
- 标签: rust, migration, verification, production-oracle, api
- 质量评分: 5/5
- 抓取时间: 2026-11-26T15:44:07Z
中文导读
Anthropic 工程复盘:Messages API 从 Python 迁到 Rust,该 API 是客户与 Claude Code 到达 Claude 的主路径,流量 2024 年初到 2026 年秋约 1800 倍headline:每请求 CPU 约降 70%,TTFT 改善约 20%更值钱的是验证:约 700 条集成测试通过率约 98%,生产输入只匹配约四分之一,审计发现 100 多处被弱化断言;团队改用仍在运行的生产服务当校验器,配指纹脱敏 shadow 流量与沙箱/生产/memory 三层验证环,agent 团队修 diff,人审守住匹配但不可上线的改动,9 月切流
为什么值得关注
Anthropic's Rust migration needed production as oracle: 98% test-green matched only ~25% of production traffic
Fetched via the vault research package (jina full text, 2026-11-26 morning): numbers cross-checked against research HTML 200, coverage gate passed, canonical URL is /research/ (same content on engineering path).
关键信息
- 标题: Migrating our Messages API to Rust
- 作者: Anthropic
- 链接: https://www.anthropic.com/research/migrating-api-to-rust
- 发布时间: 2026-11-25
- 分类: infra
- 关联标签: rust, migration, verification, production-oracle, api
English Summary
Anthropic retrospective on moving the Messages API - the main path customers and Claude Code use to reach Claude - from Python (2023) to Rust, traffic up ~1800x from early 2024 to fall 2026. Gains: ~70% lower CPU per request, ~20% better TTFT, >80% lower memory per request (Figure 15 alt). The durable lesson is verification: by April 2026 ~700 integration tests passed at ~98% while only a quarter of production inputs matched, with 100+ weakened assertions found in tests coupled to the implementation. The team kept the live production service as oracle: shadow traffic with request fingerprinting (repair agents saw shapes, not raw requests), three loops - sandbox input/scripted-output checks, production shadowing, a memory loop - with an agent team fixing diffs and human review rejecting matches that were not shippable. Cutover September 2026; published 2026-11-25.
Source Excerpts
Article opening (jina full text)
Many problems have a generator-verifier gap: it's often far easier to verify that a solution is correct than to come up with the solution in the first place. Migrating a live API that serves Claude traffic is one of them.
Vault dump: official numbers and timeline (01-dump-official-numbers-timeline.md)
对象是 Messages API——客户与 Anthropic 自家应用(Claude Code、Cowork)到达 Claude 的主路径。2023 年 Python 起步;早期有人叫它 basically a request forwarder。流量 early 2024 → fall 2026 大约 1800 倍。收益(正文 headline):每请求 CPU 约降 70%,TTFT 约 20% 改善;Figure 15 alt 另记每请求内存降超 80%。发文 2026-11-25,切流 2026-09。
Vault dump: tests vs production (02-dump-tests-shadow-oracle.md)
约 700 条集成测试;测试在 Python 进程内跑,并 mock 计费/限额等。测试与实现耦合:移植时代码与测试同改;审计发现 100+ weakened assertions。2026-04 Rust 测试通过约 98%,对应生产输入匹配约四分之一。
Vault dump: three verification loops (03-dump-verification-loops.md)
内环(快):云沙箱双代码库,输入检查不调模型、秒级比 prompt,后加输出检查(假模型 scripted reply);agent 只见 fingerprint 不见原请求,自写请求复现后改 Rust 并补旧挂新过测试。外环:生产 shadow。memory 环留住否决规则;人审守住匹配但不可上线的改动。