Cursor 正式发布 Agent SDK:以纯代码方式定义、评估与部署定制化 AI Agent
英文标题:🔶 The Agent SDK
Cursor 正式推出 Agent SDK,该框架此前用于构建其内部的 Bugbot、Security Reviewer 和 Rollouts 等托管 Agent,现已全面可用(GA)。通过 Agent SDK,开发者可以用代码定义 Agent,Prompt 采用 Markdown 编写,工具以 TypeScript 形式实现,并纳入团队现有的版本控制与审查流程。SDK 原生支持评测(Evals)、事件重放及多 Agent 协同分工,且支持通过一条命令部署至 Cursor 基础设施或容器化自托管。这一工具为软件工程团队将 AI Agent 深度定制并嵌入实际开发流水线提供了标准化的工程范式。
2.0 KB
696 B
1.1 KB
477 B
473 B
596.3 KB
中文
软件工程团队正在使用以代码定义的 Agent,来处理贯穿整个开发生命周期的重复性工作。这些 Agent 能够接入团队工作的各个环节,并在相关事件发生时主动响应——无论是代码审查(Pull Request)、执行合规工作流,还是调查线上故障。
最有价值的 Agent 往往是针对特定团队的运作方式量身定制的。在此之前,构建这类 Agent 通常意味着必须妥协采用围绕他人工作流设计的产品,或者完全从零开始编写。
今天,我们正式发布 Agent SDK。这是我们用来构建自身托管 Agent(例如 Bugbot、Security Reviewer 和 Rollouts)的底层框架。Agent SDK 允许你使用代码定义 Agent,并像管理任何普通软件项目一样对它们进行维护。你可以从模板开始,也可以直接将你的 Coding Agent 指向我们的官方文档。当 Agent 准备就绪后,只需一条 agent-sdk deploy 命令即可将其部署到 Cursor 的基础设施上。
围绕你的工作流构建
Agent SDK 让你可以快速构建并部署符合团队自身工作习惯的 Agent。它们能够响应团队当前正在处理的事件,并严格遵循团队可检查、可修改的策略与规范。
代码审查就是一个典型例子。每个团队对于哪些代码需要关注、应当由谁来审查都有自己的标准。借助 Agent SDK,你可以构建能够响应来自 GitHub、GitLab 或 Bitbucket 的 Pull Request 事件的 Agent。该 Agent 可以评估代码变更的风险、将其路由给对应的团队,并自动批准符合团队策略的变更。
举个例子,Cursor 内部的一个团队积累了一个庞大且快速增长的经验教训知识库,并希望每一次 Pull Request 都能根据该知识库进行核对。这样一来,即使代码库持续更迭,团队过往的技术决策也能得以延续。借助 Agent SDK,他们在一天左右的时间内就构建出了 kb-reviewer。如今,它会在他们主代码库的每个 PR 上运行,标记与已记录经验相悖的改动,附上每条发现所依据的记录出处,并提示工程师协调处理报告中的差异。
对于更复杂的任务,Agent 可以将工作交接给配备专属工具与会话的其他专业化 Agent,也可以将一项任务拆分给多个子 Agent 并行处理。
Agent SDK 还开箱即用地支持自动化评测(Evals)与事件重放(Event Replay),在确保关键工作流按预期执行的同时支持敏捷迭代。美巡赛(PGA Tour)正使用 Agent SDK 来驱动其软件开发工厂,而 Evals 让他们能够保持高速迭代。
Agent SDK 使 PGA 能够在 Cursor 的基础设施上构建我们软件工厂的每个组件。它提供了我们构建驱动开发流程的 Agent 所需的灵活性。此外,开箱即用的 Evals 支持使我们能够快速迭代新想法,并可靠地优化现有能力。
Michael Gyarmathy
Principal Engineer, PGA America
在代码中定义一切
基于 Agent SDK 构建的 Agent 的组织结构就像一个微型软件项目。指导 Agent 的指令提示词与工具代码、外部服务连接以及用于测试它的 Evals 代码并存放在一起。
每个文件代表 Agent 所掌握的知识或能够执行的操作。Prompts 使用 Markdown 编写,工具则定义为 TypeScript 函数。由于一切皆代码,所有变更都可以像其余业务软件一样走相同的版本控制与代码审查流程。
随处部署 Agent
当你准备好将 Agent 投入实际使用时,只需在项目目录下运行 agent-sdk deploy 即可将其部署至 Cursor。该命令会构建 Agent、为其分配 URL,并在我们的基础设施上启动运行。你可以通过仪表板管理密钥与集成,同时继续使用本地环境提供的相同日志、Evals 与演练场(Playground)。
你也可以将 Agent 运行在自己的基础设施上。每个 Agent 均作为单个 Node 进程运行,可以轻松打包到容器中。
快速上手
上手 Agent SDK 与启动任何其他软件项目非常相似。创建一个项目目录,然后启动本地 Playground:
typescript import { homedir } from "node:os"; import { join } from "node:path"; import { defineAgent } from "@cursor/agent-sdk";
export default defineAgent({ name: "Robo", model: { id: "composer-2.5", params: [ { id: "effort", value: "high" }, { id: "fast", value: "true" }, ], }, local: { cwd: join(homedir(), ".cache", "factory", "robo"), }, })
随后,你可以在本地进行迭代并运行 Evals,确认无误后使用 agent-sdk deploy 进行部署。
Agent SDK 还随附了一套引导 Coding Agent 完成开发流程的技能(Skills)。你可以让 Agent 阅读官方文档,让它与你一同协作构建 Bot。
Agent SDK 现已正式全面可用(GA)。欢迎阅读 文档 开始体验。
English / 原文
Software teams use agents defined as code to handle recurring work across the development lifecycle. These agents connect to the places where a team works and act when relevant events occur, whether that means reviewing a pull request, executing a compliance workflow, or investigating an incident.
The most useful agents are tailored to how a particular team operates. Until now, building one has generally meant adopting a product designed around someone else's workflow or starting from scratch.
Today, we're releasing the Agent SDK, the framework we use to build our own managed agents like Bugbot, Security Reviewer, and Rollouts. Agent SDK allows you to define agents in code and manage them like any other software project. Start from a template or point your coding agent at our docs. When the agent is ready, agent-sdk deploy it to Cursor infrastructure with one command.
#Build around your workflow
The Agent SDK lets you quickly build and deploy agents that work the way your team does. They respond to the events your team already handles and follow policies your team can inspect and change.
Code review is one example. Each team has its own standards for what requires attention and who should review it. With the Agent SDK, you can build an agent that responds to pull request events from GitHub, GitLab, or Bitbucket. The agent can assess the risk of a change, route it to the right team, and approve changes that meet your policy.
As an example, a team within Cursor had built a large, fast-growing knowledge base of lessons learned and wanted every pull request checked against it. This way, the team's past decisions would hold even as the codebase changed. With the Agent SDK, they built kb-reviewer in about a day. It now runs on every PR in their main codebase, flags changes that contradict a recorded lesson, cites the note behind each finding, and encourages engineers to reconcile the discrepancies it reports.
For more complicated work, agents can hand a task to another specialized agent with its own tools and sessions. They can also divide a job among subagents working in parallel.
The Agent SDK also supports evals and event replay out of the box, allowing for rapid development with assurances that critical workflows execute the way you expect. The PGA Tour uses the Agent SDK to power their software development factory. Evals keep them moving quickly.
The Agent SDK has enabled PGA to build every component of our software factory on Cursor's infrastructure. It provides the flexibility we need to build agents that drive our development process. And built-in support for evals allows us to quickly iterate on new ideas and optimize existing capabilities reliably.
Michael Gyarmathy
Principal Engineer, PGA America
#Define everything in code
An Agent SDK agent is organized like a small software project. The instructions that guide it sit alongside code for its tools, connections to outside services, and the evals used to test it.
Each file represents something the agent knows or can do. Prompts are written in Markdown, while tools are defined as TypeScript functions. Because everything is code, changes can go through the same version control and review process as the rest of your software.
#Deploy agents wherever you need them
When you're ready to put an agent into use, you can deploy it to Cursor by running agent-sdk deploy from the project directory. The command builds the agent, gives it a URL, and starts it on our infrastructure. You can manage secrets and integrations from the dashboard, while continuing to use the same logs, evals, and playground available locally.
You can also run the agent on your own infrastructure. Each agent runs as a single Node process that can be packaged in a container.
#Get started
Getting started with the Agent SDK looks much like starting any other software project. Create a project directory, then launch the local playground:
import { homedir } from "node:os";
import { join } from "node:path";
import { defineAgent } from "@cursor/agent-sdk";
export default defineAgent({
name: "Robo",
model: {
id: "composer-2.5",
params: [
{ id: "effort", value: "high" },
{ id: "fast", value: "true" },
],
},
local: {
cwd: join(homedir(), ".cache", "factory", "robo"),
},
})
From there, you can iterate locally and run evals before deploying with agent-sdk deploy.
The Agent SDK also ships with skills that guide coding agents through the development process. You can point an agent at the docs and have it help build the bot with you.
The Agent SDK is generally available today. Read the docs and get started.