使用 Claude Agent SDK 构建智能体
Last year, we shared lessons in building effective agents alongside our customers. Since then, we've released Claude Code, an agentic coding solution that we originally built to support developer productivity at Anthropic.
去年,我们与客户一起分享了构建有效代理的经验教训。此后,我们发布了Claude Code,这是一个代理式编码解决方案,我们最初构建它是为了支持 Anthropic 的开发者生产力。
Over the past several months, Claude Code has become far more than a coding tool. At Anthropic, we’ve been using it for deep research, video creation, and note-taking, among countless other non-coding applications. In fact, it has begun to power almost all of our major agent loops.
过去几个月,Claude Code 已远超编程工具的范畴。在 Anthropic,我们一直使用它进行深度研究、视频创作和笔记记录,以及无数其他非编程应用。事实上,它已开始驱动我们几乎所有主要的代理循环。
In other words, the agent harness that powers Claude Code (the Claude Code SDK) can power many other types of agents, too. To reflect this broader vision, we're renaming the Claude Code SDK to the Claude Agent SDK.
换句话说,为 Claude Code 提供动力的代理框架(Claude Code SDK)也可以为许多其他类型的代理提供动力。为了反映这一更广泛的愿景,我们将 Claude Code SDK 重命名为 Claude Agent SDK。
In this post, we'll highlight why we built the Claude Agent SDK, how to build your own agents with it, and share the best practices that have emerged from our team’s own deployments.
在本文中,我们将重点介绍我们为什么构建 Claude Agent SDK、如何使用它构建自己的代理,以及我们团队自身部署中出现的最佳实践。
Giving Claude a computer
给 Claude 一台电脑
The key design principle behind Claude Code is that Claude needs the same tools that programmers use every day. It needs to be able to find appropriate files in a codebase, write and edit files, lint the code, run it, debug, edit, and sometimes take these actions iteratively until the code succeeds.
核心设计原则 是 Claude Code 背后的核心,即 Claude 需要使用程序员日常使用的相同工具。它需要能够在代码库中找到合适的文件的、编写和编辑文件、对代码进行 lint、运行它、调试、编辑,有时迭代这些操作直到代码成功。
We found that by giving Claude access to the user’s computer (via the terminal), it had what it needed to write code like programmers do.
我们发现,通过让 Claude 访问用户的计算机(通过终端),它就拥有了像程序员一样编写代码所需的一切。
But this has also made Claude in Claude Code effective at non-coding tasks. By giving it tools to run bash commands, e...