读书笔记 · 约 13,543 字 · 预计推送 2 部分

Anthropic《Building Effective Agents》精读笔记 —— 工作流 vs Agent 的取舍原则 未开始

目录

题记与说明

- 精读日期:2026-10-28
- 精读方式:主题研究。先用网络检索筛选互补来源,再逐一全文精读(本文所用 webReader 均返回全文,非仅摘要)
- 主题判断:确认是"研究主题"——一篇工程经验文章(不是学术论文),按研究主题流程处理,围绕"工作流 vs agent 的取舍原则"重点展开
- 来源说明:用户给的 URL 是 https://www.anthropic.com/research/building-effective-agents,该路径与 https://www.anthropic.com/engineering/building-effective-agents 指向同一篇文章(原文实际归在 Engineering 栏目下,作者 Erik Schluntz & Barry Zhang,发布于 2024-12-19,页面标注"Last updated 9 Oct 2026",并带有 Managed Agents 的推广提示)

0. 精读来源清单(检索筛选结果)

#来源精读深度价值定位
1Anthropic《Building effective agents》(2024-12-19)全文精读(主来源)取舍原则的原始出处:workflow/agent 定义、五种工作流模式、agent 适用判据、反框架立场
2Anthropic《How we built our multi-agent research system》(2025-06-13)全文精读把取舍原则在生产中落地的量化证据:多智能体的收益(90.2%)、代价(15× token)、适用边界(研究型任务 vs 编码任务)
3OpenAI《A practical guide to building agents》(2025-04,商业指南)全文精读(落地页全文;官方 PDF 版本未能直接抓取)同期对家的独立立论,交叉验证"何时用 agent"的判据;编排模式与护栏视角可对照
4Hacker News 讨论(item?id=42470541)(2024-12-20)全文精读社区批评与一线实践:定义争议、可预测性主张、去框架化案例(LangGraph→原生 Python)

检索中还见过以下来源但未精读(仅出现在搜索摘要里,本笔记不引用其细节):Microsoft Azure "Workflow-First vs Code-First vs Hybrid"(2025-11)、Orkes《Workflows vs Agents》、多篇 Medium 转述/评述。另:原文末尾链接的 Anthropic cookbook 示例库 未打开验证。


1. 核心问题

这篇文章要解决的问题非常明确:当"agent"概念被过度炒作时,工程团队到底该怎么决定"要不要上 agent、上多复杂的 agent"?

具体拆成四个子问题:

  1. 概念问题:workflow 和 agent 的边界到底在哪?(很多团队把"LLM + 一点工具调用"就叫 agent,导致讨论失焦)
  2. 决策问题:什么情况下值得用"模型动态自主决策"(agent),什么情况下应该用"预定义代码路径"(workflow)?
  3. 设计问题:决定要做之后,有哪些可复用、可组合的架构模式?复杂度应该从哪里起步?
  4. 实践问题:不用框架行不行?agent 在生产中真正难的地方在哪?

文章自己的立场是反炒作的:它开篇就警告不要为了 agent 而 agent,全文的主旋律是"找到能用的最简单方案"。

2. 主要主张

2.1 基础定义(整篇取舍讨论的地基)

原文的核心定义(逐字):

"Workflows are systems where LLMs and tools are orchestrated through predefined code paths. Agents, on the other hand, are systems where LLMs dynamically direct their own processes and tool usage, maintaining control over how they accomplish tasks."
(工作流:LLM 和工具通过预定义代码路径编排的系统;agent:LLM 动态指导自身过程和工具使用、自己掌握任务完成方式的系统。)

以及 agent 的极简定义(逐字):

"An agent can be defined as an LLM in a loop with tools."
(agent 可以定义成"带工具、跑在循环里的 LLM"。)

关键点:二者不是对立类别,而是控制权光谱——控制权在"代码"手里是 workflow,在"模型"手里是 agent。原文明确说 workflow 和 agent 都可以组合、分阶段使用。

2.2 取舍原则(本笔记重点)

综合原文与三篇互补来源,取舍原则可以提炼成 六条判据:

#判据选 workflow选 agent出处
1可预测性任务需要可预测、一致的行为允许每次执行路径不同原文:"Workflows offer predictability and consistency for well-defined tasks, whereas agents are the better option when flexibility and model-driven decision-making are needed at scale."(大意)
2步骤可否预知子任务可以事先分解、路径可硬编码"it's difficult or impossible to predict the required number of steps, and where you can't hardcode a fixed path"原文 When to use agents 一节
3错误成本与信任错误代价高、需要强护栏"the cost of errors is acceptable or can be effectively managed",且要在低风险环境起步、靠测试与护栏建立信任原文 When to use agents 一节
4成本与延迟可接受固定开销agent 更贵更慢(多智能体文章给出量化:multi-agent ≈ 15× chat 的 token)多智能体文章
5可评测性(复杂度自由度)问题能表示成 DAG,"正确"有明确定义自由度指数级放大,系统性评测变难HN 评论 #60:"Agents increase the degrees of freedom in your system exponentially making it so much more challenging to evaluate systematically."
6并行化空间任务串行、无可拆分子问题重度并行、信息超出单上下文窗口、需要操作大量复杂工具多智能体文章:"Multi-agent systems excel at valuable tasks that involve heavy parallelization, information that exceeds single context windows, and interfacing with numerous complex tools."

决策流程(原文的实际建议顺序):

最简单的 Augmented LLM(检索 + 工具 + 记忆)
  → 任务能否拆成固定子任务? → 是:五种 workflow 模式之一(按需组合)
  → 步骤数不可预知、路径不可硬编码、错误成本可控、需要规模化灵活决策?
      → 是:agent(仍从最简形式起步)

原文的总纲(逐字):

"The key is finding the simplest solution possible, and only increasing complexity when needed."
(关键是找到尽可能简单的方案,仅在确有必要时增加复杂度。)

2.3 模式库(复杂度阶梯)

原文给出一个从简到繁的模式谱系,每个模式都标注了"何时用 + 代价":

  1. Augmented LLM(积木):LLM + 检索 + 工具 + 记忆。一切的地基。
  2. Prompt chaining(链式):任务分解为固定子任务顺序执行,中间可加程序检查点。代价:延迟(更多计算)换更高准确率。适合能干净分解的固定流程(如先生成营销文案→再翻译)。
  3. Routing(路由):先分类输入再分流到专门化的后续处理。适合"同一类大问题、但每类各有优化空间"的场景(客服问题的分流)。
  4. Parallelization(并行):两个变体——sectioning(切块并行处理)与 voting(多次独立运行取多数/择优)。适合可独立并行的大任务,或需要多视角交叉验证的场景。
  5. Orchestrator-workers(编排者-工人):中央 LLM 动态分解任务、派发给 worker、再综合结果。与 parallelization 的区别在于子任务不是事先定死的,而是按输入动态确定的(原文点名的典型用例:对多个文件做无法预知数量的复杂改动)。
  6. Evaluator-optimizer(评估者-优化者):一个 LLM 生成、另一个 LLM 评审反馈、循环迭代。前提是存在清晰的评价标准且反馈能带来实质改进(如文学翻译、需要多轮检索补全信息的复杂搜索任务)。
  7. Agent(智能体):以上模式的终点形态——模型在循环中自主规划、调工具、根据环境反馈决定下一步。原文强调"每个行动都由模型完成",因此难以预测、难以解释决策。

2.4 反框架立场

原文在"Building agents from scratch"一节明确建议直接用 API,不用框架。承认框架有好处(简化调模型、串工具、管状态),但(大意,原文):"this often comes at the cost of reduced transparency to the underlying prompts and responses, making debugging harder. They can also add unnecessary complexity for simpler setups."——框架遮住了底层的 prompt 和响应,让调试变难,对简单场景还引入不必要的复杂度。

这一立场在社区得到强共鸣(HN):

2.5 两个容易被忽略的配套主张

3. 方法

这不是论文,立论方式是"工程经验 + 模式分类学",没有任何 benchmark 数据表:

  1. 来源:作者与"数百家客户"合作构建 agentic 系统的经验(原文自述:learnings from building many agents with customers)。
  2. 论证结构:定义 → 积木 → 模式谱系(每个模式给配置图 + 适用判据 + 代价)→ agent 专门章节 → 反框架 → 生产建议(工具优先、评估先行)。本质是案例归纳出的模式库,而非受控实验。
  3. 主张的可检验性:原文给的是"何时用 X"的定性判据;真正把判据变成可测量证据的是配套的多智能体文章——用内部研究评测集 + 公开 BrowseComp 做了量化归因(见第 4 节)。
  4. 交叉验证方法(本笔记采用):用 OpenAI 同期指南独立立论对照(两家实验室是否收敛到同一套判据),用 HN 一线工程师的实践检验(哪些主张被生产环境证实/质疑)。

4. 数据与证据

4.1 原文本身的证据形态(局限所在)

原文几乎没有定量数据——证据是客户合作实践和模式复用性。这是它被批评的主要原因之一(HN 有评论指出缺少 memory、治理与失败案例的讨论)。

4.2 Anthropic 多智能体研究系统文章的量化证据(对取舍原则的实证)

以下数字均出自该文全文:

4.3 HN 社区的实践佐证与反证

4.4 OpenAI 指南的交叉验证

5. 结论

  1. 取舍原则一句话版:默认 workflow,例外才用 agent。workflow 买的是可预测性、一致性、低成本;agent 买的是灵活性、规模化下的模型驱动决策。购买 agent 的前提是:步骤数不可预知、路径无法硬编码、错误成本可管理、任务结构适合并行。
  2. 复杂度永远从最简方案起步(可能是零 agent、甚至一次 LLM 调用),按"证明有需要"逐级升级;改工具 > 改 prompt > 加架构。
  3. 框架默认不用;要用也只用在确实需要它的地方,因为透明度损失是真实成本。
  4. 多智能体是 agent 路线的极端形态:收益真实(90.2%)但代价同样真实(15× token),只对高价值、重并行、超出单上下文窗口的任务成立——这是"取舍原则"最量化的注脚。
  5. 两家头部实验室(Anthropic、OpenAI)在"何时该用 agent"上独立得出了收敛的判据,这本身就是这套原则最强的外部效度证据。

6. 局限

原文自认的:

我推断的(有依据):

多智能体文章自认的:

7. 对我的启发(结合当前知识库/精读流水线)

  1. 精读流水线本身就是"workflow 包 agent"的正确示范:nightshift 流程(检索筛选 3-5 来源 → 逐个精读 → 按七维度提取 → 落盘笔记)是预定义代码路径(workflow),agent 只出现在叶子环节(检索、精读、写作)。这符合"默认 workflow"原则——比"派一个全自主 agent 去调研"可控得多。
  2. subagent 产出落盘 + 只回传引用:精读员把笔记写成 markdown 文件、结构化结果里只带 notePath,正是多智能体文章"subagents store work in the filesystem as artifacts and only pass back a reference"的做法,避免了把全文塞回主上下文的传话失真。
  3. effort scaling 规则可以直接写进 prompt:文献检索类任务可套用"简单检索 1 agent 3-10 次调用;对比型 2-4 个 subagent 各 10-15 次;复杂综述 10+ subagent 分工"的显式规则,把"努力程度"从隐式猜变成显式指令。
  4. 搜索策略:"Start wide, then narrow down"(先宽后窄、先理解问题再收敛到具体来源)应作为检索类 subagent 的默认指令。
  5. evaluator-optimizer 模式用于笔记质量闭环:生成精读笔记(optimizer)+ 按七维度标准评审(evaluator)循环,前提是评价标准清晰——七维度模板恰好就是那个"clear evaluation criteria"。
  6. 改任务描述 > 改模型:40% 的任务完成提升来自修一句话的工具描述;同理,子代理的任务描述质量(要读什么、排除什么、输出什么格式)是整条流水线里杠杆最大的地方,值得花时间打磨模板而不是换模型。
  7. token 经济账:15× 的多智能体成本只配得上高价值任务。逐篇精读高信号来源属于高价值、中等成本,合算;但不要把多智能体扩散到低价值环节(比如让多个 agent 讨论格式问题)。
  8. 评测纪律:多智能体文章的"20 条真实样例起步 + LLM-as-judge 有偏 + 人工抽查不可省"可直接用于知识库笔记质量的抽检流程。

8. 附:重要原文引述备查

以下引述均出自精读全文,标注来源;翻译为本笔记所加。
  1. "Workflows are systems where LLMs and tools are orchestrated through predefined code paths. Agents, on the other hand, are systems where LLMs dynamically direct their own processes and tool usage, maintaining control over how they accomplish tasks." —— [原文]
  2. "An agent can be defined as an LLM in a loop with tools." —— [原文]
  3. "The key is finding the simplest solution possible, and only increasing complexity when needed." —— [原文]
  4. "Agents can be used for open-ended problems where it's difficult or impossible to predict the required number of steps, and where you can't hardcode a fixed path." —— [原文]
  5. "However, this often comes at the cost of reduced transparency to the underlying prompts and responses, making debugging harder." (谈框架)—— [原文]
  6. "In a production setting, the most reliable, significant gains are from modifying the tool, rather than the prompt." —— [原文]
  7. "Multi-agent systems excel at valuable tasks that involve heavy parallelization, information that exceeds single context windows, and interfacing with numerous complex tools." —— [多智能体文章]
  8. "Agents typically use about 4× more tokens than chat interactions, and multi-agent systems use about 15× more tokens than chats." —— [多智能体文章]
  9. "Before committing to building an agent, validate that your use case can meet these criteria clearly. Otherwise, a deterministic solution may suffice." —— [OpenAI 指南]
  10. "too many people rush to build autonomous agents when their problem could easily be defined as a DAG workflow. Agents increase the degrees of freedom in your system exponentially making it so much more challenging to evaluate systematically." —— [HN 评论 #60]

来源链接汇总

← 资料库今日播报 →