跳到主内容
@wquguru
精选88The Pragmatic Engineer(RSS)产品与增长

Anthropic Python转Rust实践:影子测试与AI辅助代码审查

How Anthropic builds software in 2026 with Katelyn Lesse

原文
发到 X
推荐理由

提供了高相关度的工程落地细节:用影子测试替代传统Code Review来验证重构、以及AI Agent介入PR路由和Oncall的具体机制,独立开发者和初创团队可直接参考其低成本验证思路。

Programming note: there will be no The Pulse tomorrow. For those of you who celebrate, Happy Thanksgiving! The regular schedule returns next week.

编程提示:明天没有《The Pulse》节目。对于那些庆祝感恩节的朋友,感恩节快乐!常规节目安排将于下周恢复。

Listen and watch now on YouTube, Apple, and Spotify. See the episode transcript at the top of this page, and timestamps for the episode at the bottom.

立即在 YouTube、Apple 和 Spotify 上收听和观看。在本页顶部查看本期节目的文字稿,在底部查看时间戳。

Brought to You by

由以下内容赞助播出

• turbopuffer – companies like Anthropic, Cognition, and Notion build their search infrastructure on turbopuffer because it is insanely reliable and performant at the frontier of AI scale. It also powers the The Pragmatic Engineer search site. Sign up today and start building.

• turbopuffer – Anthropic、Cognition 和 Notion 等公司选择在其搜索基础设施上使用 turbopuffer,因为它在 AI 规模的前沿具有极其可靠和高性能的表现。它还为 The Pragmatic Engineer 搜索网站提供支持。立即注册并开始构建。

• Antithesis – Verify your system’s correctness without human review or traditional integration tests, and avoid bugs and outages. Antithesis launched a plugin that makes your coding agent incredibly effective at finding and fixing bugs, and is dead simple to set up. There’s also a new, self-service Team plan for $2,999/month. Use the code PRAGMATIC50 for 50% off your first month. Learn more

• Antithesis – 无需人工审查或传统集成测试即可验证系统的正确性,并避免错误和服务中断。Antithesis 推出了一款插件,使你的编码代理在查找和修复错误方面变得极其高效,且设置非常简单。此外,还推出了新的自助式团队计划,每月 2,999 美元。使用代码 PRAGMATIC50 可享受首月五折优惠。了解更多

• Entire – Entire has launched its own Git forge, and you can now host private repos directly in the US, Europe, India, Australia, Brazil, and Singapore. They’ve also reinvented the pull request with Trails, which is a much more natural workflow when agents are pushing new changes after iterating on feedback. You get more context and control on when a change is ready to merge. Check it out

• Entire – Entire 推出了自己的 Git 仓库平台,你现在可以直接在美国、欧洲、印度、澳大利亚、巴西和新加坡托管私有仓库。他们还通过 Trails 功能重新定义了拉取请求(Pull Request),当代理在根据反馈迭代后推送新更改时,这是一种更加自然的工作流程。你可以获得更多关于何时准备合并更改的上下文和控制权。点击查看

In this episode

本期节目内容

How did Anthropic rewrite the API serving every Claude token from Python to Rust?

Anthropic 如何将每个 Claude token 的 API 服务从 Python 重写为 Rust?

Today’s guest is Katelyn Lesse, who leads platform engineering at Anthropic and previously led engineering teams at Stripe. Her team owns the Claude API and the infrastructure behind products like Claude Code and Claude Desktop.

今天的嘉宾是 Katelyn Lesse,她领导 Anthropic 的平台工程团队,此前曾在 Stripe 领导工程团队。她的团队负责 Claude API 以及 Claude Code 和 Claude Desktop 等产品背后的基础设施。

We start with Anthropic’s move from a Python monolith to Rust. Katelyn explains why adding CPU capacity is tricky due to a global CPU shortage, how Claude helped engineers get up to speed in Rust, and how the team used shadowing to verify the rewrite against production traffic. Just today, Katelyn and the team published a deepdive on their Python → Rust migration.

我们从 Anthropic 从 Python 单体架构迁移到 Rust 开始谈起。Katelyn 解释了由于全球 CPU 短缺,增加 CPU 容量为何棘手,Claude 如何帮助工程师快速上手 Rust,以及团队如何使用影子模式(shadowing)在生产流量中验证重写结果。就在今天,Katelyn 和她的团队发布了一篇关于他们从 Python 迁移到 Rust 的深度解析文章。

Katelyn walks us through what the software engineering job looks like today at Anthropic, and how code review and oncall interact with agentic workflows. We also get into the frontier lab’s “software factory”, how a product manager shipped a feature to production, and why Anthropic is replacing traditional coding interviews with agent-based exercises.

Katelyn 向我们介绍了 Anthropic 当前的软件工程工作面貌,以及代码审查和值班(oncall)如何与智能体工作流程相互作用。我们还深入探讨了前沿实验室的“软件工厂”,一位产品经理如何将功能部署到生产环境,以及为什么 Anthropic 正在用基于智能体的练习取代传统的编码面试。

As of last week, Anthropic is a publicly traded company, with a market capitalization of around $1T, all while having a tenth of the headcount of other businesses with similar market capitalizations. Learning how Anthropic does software engineering might be instructive for companies that want a similar structure.

截至上周,Anthropic 已成为一家上市公司,市值约为 1 万亿美元,而其员工人数仅为其他具有相似市值企业的十分之一。了解 Anthropic 如何进行软件工程实践,对于希望构建类似架构的公司而言可能具有借鉴意义。

Takeaways from the conversation with Katelyn

与 Katelyn 对话的要点

Here are 12 interesting learnings on how software engineering is changing inside of Anthropic:

以下是关于 Anthropic 内部软件工程变革的 12 条有趣洞察:

1. Anthropic rewrote its API from Python to Rust in around five months. The API called ‘Messages API’ serves all Claude tokens externally, as well as for Claude Code and Claude Desktop. This service does authentication, tokenization, billing, and safety checks, then calls the GPU stack to generate tokens. The service was a Python monolith and the team initially optimized Python, but found the performance overhead was still large. Eventually, they decided to rebuild it in Rust. It took a few engineers and a few months in total; all without anyone being expert in Rust!

1. Anthropic 在大约五个月内将其 API 从 Python 重写为 Rust。该名为“Messages API”的 API 对外提供所有 Claude token 服务,同时也供 Claude Code 和 Claude Desktop 使用。该服务负责身份验证、分词、计费和安全检查,随后调用 GPU 堆栈生成 token。该服务最初是一个 Python 单体应用,团队曾尝试优化 Python,但发现性能开销仍然很大。最终,他们决定用 Rust 重新构建它。整个过程由几名工程师耗时数月完成,且其中无人是 Rust 专家!

How the Claude API team had the Rust system shadow the Python one. See more details in the Anthropic engineering blog about the migration

Claude API 团队如何让 Rust 系统并行运行以影子测试 Python 系统。有关迁移过程的更多细节,请参阅 Anthropic 工程博客的相关文章。

The Anthropic team published a longer walkthrough of the migration – check it out.

Anthropic 团队发布了一篇更详细的迁移指南——欢迎查阅。

2. Hang on, why was the monolith written in Python in the first place? Back in 2023, Anthropic was still a research company when it decided to create an API, and the team that built it was small, with a large crossover to Research. It was the case that researchers worked mostly with Python, which made it very easy to integrate the API with inference and other infrastructure code. Similarly, OpenAI’s API was also written in Python – and later rewritten to Rust. Anthropic and OpenAI faced the same challenge with the Python monolith: the CPU footprint of the monolith started to become a growing problem.

2. 等等,为什么单体应用最初要用 Python 编写?早在 2023 年,Anthropic 仍是一家研究公司,当时决定创建 API,而构建它的团队规模较小,且与研发团队有大量重叠。研究人员主要使用 Python,这使得将 API 与推理及其他基础设施代码集成变得非常容易。同样,OpenAI 的 API 也是用 Python 编写的——后来也重写为 Rust。Anthropic 和 OpenAI 都面临着 Python 单体应用的相同挑战:该单体应用的 CPU 占用逐渐成为一个日益严重的问题。

3. The rewrite was done without Rust experts on the team or strict code reviews. A year earlier, the same team picked Go for their new services because it was a language that team members knew how to read and write. But by 2026, they felt that Claude was good enough at Rust, and Claude helped engineers learn more about Rust during the rewrite. The team did not do strict code reviews, but had the “unfair” advantage of the existing Python API being a perfect test harness. They set up the new Rust API to shadow the current API, and iterated until all responses were identical. Also, Katelyn estimates that engineers looked closely at only ~20% of the code generated:

3. 这次重写是在团队中没有 Rust 专家且没有严格代码审查的情况下完成的。一年前,同一团队选择 Go 作为新服务的语言,因为团队成员知道如何阅读和编写 Go。但到了 2026 年,他们认为 Claude 在 Rust 方面已经足够好,并且 Claude 帮助工程师在重写过程中更多地了解了 Rust。团队没有进行严格的代码审查,但拥有“不公平”的优势:现有的 Python API 是一个完美的测试工具。他们设置新的 Rust API 来覆盖当前的 API,并不断迭代,直到所有响应完全一致。此外,Katelyn 估计工程师只仔细查看了约 20% 生成的代码:

“As long as you can really boil something down to make it verifiable in some way, then you don’t have to look at every single line of Rust code that’s getting written.”

“只要你能真正将某些内容简化到某种方式可验证,那么你就不必查看正在编写的每一行 Rust 代码。”

4. Anthropic has its own code review agent running at all times. The company has a Claude code review classifier running for all pull requests. It decides:

4. Anthropic 拥有一直运行的自有代码审查代理。该公司为所有拉取请求(pull requests)运行一个 Claude 代码审查分类器。它决定:

  • Does it need a human review? For “mechanical” and low risk changes like an SDK version bump or using a newer model, Claude can decide there’s no human review needed. This is also the case for fixing flaky tests, in which case, another Claude does the review, then merges and deploys it.
  • How many human reviews does it need? For changes that do need human reviews, Claude scores the risk and takes into account additional rules to decide how many human reviews are needed.
  • Which team needs to do a review? Claude routes the PR to the right teams.
  • 是否需要人工审查?对于像 SDK 版本升级或使用较新版本模型这样的“机械性”低风险更改,Claude 可以判断无需人工审查。修复不稳定测试的情况也是如此,在这种情况下,另一个 Claude 执行审查,然后合并并部署它。
  • 需要多少个人工审查?对于确实需要人工审查的更改,Claude 会对风险进行评分,并考虑额外规则来决定需要多少个人工审查。
  • 哪个团队需要进行审查?Claude 将 PR 路由到正确的团队。

5. A Claude agent is paged before a human for API oncall. For months, a Claude agent has been shadowing the API oncall rotation of the API team for training. As the team have gained confidence that Claude can tell if an alert is “real” or “noise,” they now let this agent categorize an incoming alert first. The long-term goal is for Claude to handle actual incidents without waking up a human – but they’re not there yet. We cover more on how AI SRE startups are tackling the same challenge in our recent deepdive, AI SRE: what is it, how could it change on-call – and does it work?

5. 在 API 值班期间,Claude 代理比人类更早被呼叫。几个月来,一个 Claude 代理一直在模拟 API 团队的 API 值班轮换以进行训练。随着团队对 Claude 能够判断警报是“真实”还是“噪音”的信心增强,他们现在让该代理首先对传入的警报进行分类。长期目标是由 Claude 处理实际事件而无需唤醒人类——但他们尚未达到这一阶段。在我们最近的深度分析文章《AI SRE:它是什么,它将如何改变值班制度——以及它是否有效?》中,我们更详细地介绍了 AI SRE 初创公司如何应对这一相同挑战。

6. Onboarding for new Anthropic engineers is “talk to Claude.” New joiners at tech companies used to have “onboarding buddies” and engineers who explained the architecture of systems to them, often by drawing boxes and diagrams. Not so at Anthropic, where Claude is connected to the codebase and internal systems, and engineers just ask it to explain how things work. Claude can even create interactive tutorials and visualizations. It’s pretty similar to how OpenAI engineers use Codex for onboarding, as covered in our podcast episode with Tibo Sottiaux.

6. 新加入 Anthropic 的工程师的入职培训是“与 Claude 交谈”。科技公司的新员工过去会有“入职伙伴”和向他们解释系统架构的工程师,通常通过绘制方框和图表来进行。但在 Anthropic 并非如此,Claude 已连接到代码库和内部系统,工程师只需询问它即可了解工作原理。Claude 甚至能创建交互式教程和可视化内容。这与 OpenAI 工程师使用 Codex 进行入职培训的方式非常相似,正如我们在与 Tibo Sottiaux 的播客节目中介绍的那样。

7. One thing that hasn’t changed is the need for planning and alignment. Katelyn’s team interacts with Inference, Research, Safety, and App teams. When kicking off a project, a lot of time and effort is spent on getting everyone on the same page. Katelyn says that planning time has not changed much from “pre-AI”. The average engineer actually spends more time coordinating than on implementation!

7. 有一件事没有改变,那就是对规划和协调一致的需求。Katelyn 的团队与推理(Inference)、研究、安全和应用团队进行互动。在启动项目时,会花费大量时间和精力让所有人达成共识。Katelyn 表示,规划时间与“人工智能之前”相比变化不大!普通工程师花在协调上的时间实际上比花在实现上的时间还要多!

8. Another thing that has not changed is two-pizza teams. Teams at Anthropic are still two-pizza teams of around 5-8 people. Katelyn says it’s because this is the right size for understanding a complex system and staffing an oncall rotation. Teams still own systems, and get paged. And it is a team – not an individual – that’s responsible for each system!

8. 另一件没有改变的事情是“两个披萨团队”。Anthropic 的团队仍然是由大约 5-8 人组成的两个披萨团队。Katelyn 表示,这是因为这个规模适合理解复杂系统并安排值班轮换。团队仍然拥有系统,并接收呼叫通知。而且,负责每个系统的主体是团队——而非个人!

更进一步:量化金融体系

看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力

进入量化体系 →

相似阅读

关联信息,但可能不是同一事件