先试一试 · 入门探针
讲前判断:一个采购 agent 要比完四家 GPU 工作站厂商、对照内部 wiki 查兼容性后再提交采购申请。有人说:把四次厂商搜索放在同一个对话线程里依次跑完再决定,比每次搜索各开一个干净上下文更稳妥,因为信息都在一起,agent 看得更全。
本讲地图
点击卡片下钻详解第 3 讲总起:一条 GPU 工作站采购轨迹引出的四问
双节结构总起:3a 用一条 GPU 工作站采购轨迹(context 128k→14k、四家结果都不理想仍硬选一家提交)引出 Value/Representation/Commitment/Oversight 四问;3b 进入第一个领域专场,编码智能体,验证信号最干净的落地场。先建全讲地图,再入详解。
入门6 分钟#planning#coding-agents#overviewL5 ↗
先承诺还是边走边改:规划的收益账
规划何时有用何时有害?预先承诺更快、更便宜、更可预测,重规划只在执行揭示新信息时才值回票价。固定工作流 / 先计划后执行 / 自适应三栏对比,加上 Cursor 式 Plan Mode 的产业佐证,把这笔账算清楚。
入门15 分钟#planning#commitment#plan-modeL5 p.2-5 ↗p.7 ↗p.16 ↗
分解即泛化:从 CoT 到模块化 handler
CoT 就是计划,但没有任何环节显式检查它。Least-to-Most 在 SCAN 上 14 例破 99%(CoT 仅 16%)、Decomposed Prompting 把分解做成可路由的模块:分解即泛化、即架构;而推理与行动的分界,逼计划直面不可逆。
入门12 分钟#decomposition#cot#modularityL5 p.8-12 ↗
计划该长什么样:从 STRIPS 到「代码即政策」
形式计划可校验、语言计划通用、程序居中:从 STRIPS 的前置条件,到 SayCan 的 affordance 接地,再到 Code as Policies 的策略代码。表示选择同时决定可验证性与安全性:程序能从页面取值而不接受新动作。
进阶14 分钟#representation#strips#code-as-policiesL5 p.13-15 ↗p.32 ↗
拆开 planner 与 executor:专业化与训练
四支柱(Modularity/Feedback/Long horizon/Control)怎么落成机制:UGround 用 7B executor 补 planner 的短板、Plan-and-Act 用教师轨迹训 planner、LLM Compiler 把分工编成 DAG;分离的收益是专业化,代价是接口要自己设计。
进阶14 分钟#planner-executor#four-pillars#trainingL5 p.17-22 ↗
多想、多看还是多做:test-time 三岔口与长视野税
拉长 CoT、多采候选、多与环境交互,是 test-time 算力的三条去向。Overthinking 越多解决率越低、Vending-Bench 25M tokens 的失败级联、self-conditioning 的长视野税,共同回答何时该停:先校准,再行动。
前沿15 分钟#test-time#calibration#long-horizonL5 p.24-30 ↗
单 Agent 还是多 Agent:委派的账本
Neubig 的警告(handoff 是摘要、会丢上下文)对撞 MACU 的 DAG 编排(较强单 agent 基线提升 3.4–25.5%);MAST 的 14 种失败模式与 Anthropic 的 15× token 账本夹在中间。RAO 指出第三条路:委派本身是动作,可以被训练。
编码 Agent 主循环:定位-编辑-验证 vs 固定流水线
localize–edit–verify 主循环对 Agentless 固定流水线;从 bash-only 工具集到 diff 格式 20% vs 61% 的实测差距;编码 Agent 的进步主要来自接口与环境设计(ACI),而非单纯堆模型。
入门15 分钟#coding-agents#aci#swe-benchL6 p.2 ↗p.32-37 ↗p.39-43 ↗
尺子的进化:从 SWE-bench 到时间视界
从 BLEU 的文本相似陷阱(x>=0 只在 x=0 处错)到 pass@k 的执行口径;SWE-bench→Verified(500 题人工校验)→Pro(1,865 道企业级难题)→Terminal-Bench,再到 METR:50% 时间视界每 7 个月翻一倍。尺子本身在进化。
进阶13 分钟#benchmark#pass-at-k#time-horizonL6 p.20 ↗p.23-27 ↗p.29-30 ↗
收束:四问设计清单——谁批准不可逆动作?
四问检查清单收束全讲:子任务可分吗?哪些失败或观察应当改变计划?系统如何阻止错误与 context 累积?谁批准不可逆动作?开放问题四格(校验、校准、全局状态、脚手架)串起后继讲次。
进阶5 分钟#checklist#control#recapL5 p.46-47 ↗
伴读笔记
导语
第三讲开讲时,Agent 已经会调工具、会管上下文;这一讲回答的,是怎么把一个大而模糊的目标变成 Agent 真能一步步走完的小路,以及任务大到一个人干不完时,什么时候值得分工。
先看一条真实轨迹(slides L5 p.2-3)——Fried 说这是他们几周前亲身遇到的例子。任务只有一句话:为实验室采购一台新的 GPU 工作站,跨厂商网站比配置、比价格,对照内部 wiki 的集群要求查兼容性,最后提交采购申请。
反应式 agent 却走了两百多步:四次厂商搜索挤在同一条线程里跑,中途上下文被压缩,从 128k 掉到 14k tokens;四家搜完只有一家满足规格,交期却要 20 周;它犹豫了一下「选 D?找第五家?还是放松某项要求?」,然后直接进了采购门户,把申请提交了。3a 剩下的四十多页,都在回答这条轨迹立起的四个问题:
- Value:规划何时有用?何时反而有害?
- Representation:计划用什么表示?
- Commitment:计划何时制定,什么能改它?
- Oversight:人如何、何时介入?
3b 是课程的第一个领域专场:编码智能体。验证信号在这里最干净,测试跑过就是过、跑不过就是不过,四个问题都拿到了产业级答案;编码也是这条路修得最完整的地方。
这一版对齐官方两份讲义:3a《Planning and Task Decomposition》,Daniel Fried 主讲,48 页;3b《Agents for Coding and Software Development》,Graham Neubig 主讲,82 页。页码随文以 slides L5 p.X/ L6 p.X 标注。
正文第一至四节保留经典论文织成的旧地图,第五至十二节按讲义顺序把这四问与编码专场重新铺开;「本讲地图」的卡片可下钻到对应分节详解,采购轨迹的细读在第五节。事实与数字只出自这两份讲义、官方 readings 与文中注明的来源,把它当成课前预习、课后消化用的地图。
一、规划:把「装修」变成一张工序表
装修过房子的人都知道,「把家装好」这个目标没法直接执行:它天然要拆成拆旧、水电、瓦工、木工、油漆一串工序,工序之间还有依赖,水电没验收,墙就不能封上。真开工后你更会发现计划赶不上变化:墙一拆,才知道里面藏着一根不能动的梁。
规划的本质,是把目标 分解成一串子任务,并显式记录它们之间的依赖:
依赖关系通常构成一张有向无环图 DAG: 要等它的前驱全部完成才能开工。这条流水线上有三个里程碑式的做法。
由易到难(least-to-most prompting)分两步:先让模型把问题拆成一串由易到难的子问题,再按顺序求解,且每一步都把前面已求出的答案喂进上下文。
实验结果是硬的:在 SCAN 组合泛化基准上,仅用 14 个示例就达到 99% 以上的准确率,而 Chain-of-Thought 只有 16%。分解本身就是一种泛化能力。
先计划后执行(Plan-and-Solve prompting)则证明了一件更朴素的事:在零样本提示里加一句「先制定计划、把任务拆成子任务,再按计划逐个执行」,就能在十个数据集上稳定大幅超过 zero-shot CoT。「先想后做」这四个字,换来好几个点的准确率。
ReWOO(Reasoning Without Observation)把先想后做推到了工程极致。交错式做法如 ReAct,每调一次工具,就要把全部历史观察塞回上下文重新推理,提示长度随步数增长:
其中 是任务与计划的长度, 是第 步的观察。ReWOO 把系统拆成 Planner / Worker / Solver 三个模块,规划阶段完全不看观察:
前者随步数二次增长,后者线性。这就是它在 HotpotQA 上拿到 5 倍 token 效率、准确率还提升 4% 的来源。
代价也直白:规划时看不到世界,世界变了计划就容易过时。
二、计划是假说,不是承诺:分解的失败模式与重规划
真实的 Agent 项目里,初版计划很少是错得少的那份。失败模式常见的有四类。
- 粒度失当。太粗,子任务依旧不可执行;太细,管理开销吃光预算,模型还丢了全局观。
- 错误传播。第二步一个幻觉出的「事实」,被后面所有步骤当真理引用。
- 世界漂移。计划基于过时信息,执行到一半环境已经变了。
- 过度自信。从不回头复核已完成的部分。
对应的解药也已成套路。
- 重规划(replanning):定义触发条件,即工具报错、观察与预期不符、连续失败 N 次,而不是每次都重想。
- 验证回路:用测试、lint 或专门的 critic Agent 去证伪中间产物。
- 反思式修正(Reflexion 一类):把失败摘要带进下一轮上下文。
- 树搜索(Tree of Thoughts 一类):干脆保留多条候选计划,按评估分数剪枝。
课堂还给了一个最朴素的现场版(3a 字幕):具身环境里,机器人计划拿土豆做饭,走到跟前才发现没有土豆、只有一台冰箱;把这句观察原样喂回去,重新生成的计划第一步就成了开冰箱。反馈驱动的重规划,不需要更聪明的模型。
一句话总结:把计划当假说,用观察去证伪它,别当承诺去履行。
三、多智能体:分工的收益与通信的代价
为什么要多个 Agent?收益通常列四条。
- parallelism,并行:独立子任务同时跑。
- context isolation,上下文隔离:每个 Agent 一个干净的小窗口,不共享一个爆满的大窗口。
- 角色专业化:MetaGPT 把软件公司的岗位分工编码进系统。
- 多视角:debate /voting,多个视角互相纠错。
代价也是实打实的四项:通信开销、协调失败、错误跨 Agent 传染、调试成本。一条轨迹变成 N 条互相纠缠的轨迹。
并行收益有个经典上界,即阿姆达尔定律:若任务中可并行的比例为 ,则 个 Agent 的加速比满足
串行依赖占一半的任务,加再多 Agent,加速比也封顶在 2。
实证研究 MAST 的警告更具体,下文详述。14 种失败模式里,大量属于「组织问题」:规格没对齐、中间结果没人校验、Agent 之间互相客套地确认错误结论。
所以当下的工程共识是:默认单 Agent 加好工具,只在确有并行或隔离需求时才升级多 Agent。
先用阿姆达尔定律估上限,串行一半封顶 2 倍;再过一遍 MAST 的失败清单:规格对齐了吗?中间产物谁校验?多数不够快、不够好的问题,答案是多花在工具接口上,而不是多招几个 Agent。
四、编码智能体:验证信号最干净的领域
为什么编码是 Agent 落地最成熟的领域?原因有三。
- 验收标准客观:测试跑过就是过,跑不过就是不过,几乎不需要裁判。
- 环境工具齐全:shell、编辑器、测试框架、lint 构成一个反馈即时的训练场。
- 语料与任务天然对齐:真实 issue 就是任务书。
编码 Agent 的主循环可以概括成:
while 未完成:
定位: grep / 读文件 / 跑测试,缩小嫌疑范围
编辑: 做最小改动
观察: 运行测试与 lint
若观察与预期不符: 更新计划,或回滚重来
SWE-bench 把这件事变成了尺子:2,294 个来自 12 个流行 Python 仓库的真实 GitHub issue。基准发布时,最强的模型只能解决约 2%;SWE-agent 靠给 Agent 专门设计接口,把解决率拉到 12% 以上;到本讲开课的 2026 年 9 月,swebench.com 榜单头部系统已过半。
这条陡峭曲线指向本讲的主题:进步主要来自环境与接口设计,而不是单纯堆模型能力。
SWE-agent 把这套接口称为智能体 - 计算机接口(Agent-Computer Interface, ACI):Agent 是一类新的「最终用户」,有自己的需求和能力,工具该为它设计,比如简洁的编辑反馈、防呆护栏、改完即 lint。Anthropic 工程团队的经验与此呼应:做 SWE-bench 相关工作时,花在工具接口上的功夫不亚于花在提示词上的功夫。
五、先承诺还是边走边改:规划的收益账
3a 全讲只用一条贯穿案例:为实验室采购一台新的 GPU 工作站(slides L5 p.2)。任务听上去不难:跨厂商网站比价、比配置,对照内部 wiki 的集群要求查兼容性,最后提交采购申请。反应式 agent 的实际执行却是这样一串:
Action 1 goto vendor-a.com → Workstations → spec sheet → GPU comparison
Action 15 选定配置:2× RTX 6000, 128 GB RAM, 850 W PSU
Observe 31 wiki:「racks accept 4U chassis; each slot with 1600 W」
……期间 context 被压缩:128k → 14k tokens
Observe 四家厂商搜完,只有厂商 D 全部满足,但交期 20 周
Action 201 选 D?找第五家?还是放松某项要求?
Action 202 直接进采购门户,提交申请
讲义页边的三条批注指向同一组问题:四次独立搜索挤在同一线程同一个 context 里跑;挑的四家站点结果都不理想;最后还是硬选一家提交了申请。
把轨迹画成任务图(slides L5 p.3),结构立刻显形:各厂商搜索本可并行,兼容性检查依赖 wiki 这个迟到的信息源,采购申请是不可逆的一步。图上还留着 replan 边:四家都不满足时,任务图本身要改,新增第五次搜索。
长任务天然长这样:并行子任务、依赖、迟到信息、不可逆步骤,以及一张会变的图。
Value 这一问的答案是笔账(slides L5 p.16 的三栏对照):
| 形态 | 做法 | 长处 | 软肋 |
|---|---|---|---|
| 固定工作流(Agentless 式) | 开发者写死循环:for v in VENDORS: 读规格; 过滤; 提交最便宜者 | 快、省、可预测 | 厂商清单是死的,世界一变就报废 |
| 先计划后执行 | 模型先产出完整计划,提交后再照单执行 | 省去步步重规划的开销 | 规划时看不到世界,计划易过时 |
| 自适应 agent | 执行反馈驱动修订:四家失败 → 新增第五家搜索 | 能适应执行中揭示的新信息 | 每步都可能重想,贵且慢 |
讲义的结论引 Anthropic 2024 年的《Building effective agents》:预先承诺更快、更便宜、更可预测;重规划让模型在执行揭示新信息时适应,当反馈值不回额外成本与复杂度时才用。
第一节的 ReWOO 是先计划后执行的工程极致,而它的软肋就是第三种形态存在的理由。讲义过渡页那句程序员谚语说的是这笔账的反面:“Weeks of programming can save you hours of planning”(slides L5 p.7)。用几周编程省下几小时规划,亏在没算 Value。
Commitment 与 Oversight 的产业形态是编码工具集体上线的 Plan Mode(slides L5 p.4)。Cursor、Claude Code、Codex 都把先写一份持久计划、人审核、再执行做进了默认动线,五步是:
- read-only investigation,只读侦查;
- clarifying questions,提澄清问题;
- written plan,写出书面计划;
- human review,人审核;
- 执行,可派 sub-agent 并行。
讲义给了五个它可能起效的原因:更多计算、更好的 context、外部 artifact、分解,以及人的批准。
计划本身则有个刻意保守的工作定义(slides L5 p.5):对预期未来行为的显式表示,即将尝试的动作或子目标及其次序与依赖。三条限定值得记住:计划属于本任务,对照 skill,即跨任务可复用的指南,计划可以比 skill 更具体;计划组织未来的工作;计划是提案不是保证,可被用户、另一个模型或环境交互检查修订。
拳王 Tyson 那句话放在这里不是玩笑,原话引在先规划还是边走边适应篇。
六、分解即泛化:从 CoT 到模块化 handler
回头看,CoT 其实就是最原始的计划(slides L5 p.8)。Kojima et al.(2022)那句逐步思考的提示让模型先把推理步骤草拟出来再作答;Plan-and-Solve(Wang et al., 2023)则明确说「先理解问题并制定计划,再逐步执行」。
CoT 的价值在于额外计算与一块可回看的草稿板;但它有个结构性缺陷:计划与答案在同一次生成里,没有任何环节显式检查计划。顺带一提,CoT 可以被训练强化,STaR(Zelikman et al., NeurIPS 2022)与 2025 年的 DeepSeek-R1 都走通了这条路。
把检查补上来的第一步,是先分解、再求解。第一节已述的 Least-to-Most,两阶段设计带来三条经验发现(slides L5 p.9):模型答复杂问题吃力,答分解出的子问题明显更好;子问题所需的 context 更少;问题越长、提升越大。
这解释了第一节 SCAN 上的悬殊对比:分解把「长程组合」换成了「短程泛化」。
分解的另一重收益是模块性。Decomposed Prompting(Khot et al., ICLR 2023;slides L5 p.10)让分解器生成子任务并路由给专用 handler。
例句:问「1910 年出生的人制片的影片拿过什么奖?」,分解器把它拆成「谁 1910 年出生?」交给简单 QA handler,「上一问答案是哪些片的制片?」交给位置 QA handler,依此类推。每个 handler 可以独立改进,换更好的 in-context 示例或专门训练;坏一个不拖垮全局。
讲义在这页埋了伏笔:分解一旦程序化、结构化,就通向后面的 RAO、Recursive Language Models(Zhang et al., 2025)与 MACU,第八、十节会回访。
分解的边界画在推理与行动之间(slides L5 p.12):CoT 的推理步只改文本,可以再写覆盖,中间状态全部可见;世界中的行动则改变 agent 下一步遭遇的状态、可揭示信息、可能失败、还可能不可逆,比如 submit、send。
过渡页用一句双关语点破这条边界(slides L5 p.11):“We’ll burn that bridge when we come to it.”—— 到了桥跟前,再决定烧不烧。行动迫使计划直面可行性、后果、信息与恢复,下一节的表示问题从这里接棒。
七、计划该长什么样:从 STRIPS 到「代码即政策」
Representation 这一问的经典起点是 STRIPS(Fikes & Nilsson, AI 1971;slides L5 p.13)。状态是谓词的集合:on-table(x)、on(x,y)、clear(x)、holding(x)、hand-empty。
动作带前置条件与效果:pick-up(x) 要求 on-table(x) ∧ clear(x) ∧ hand-empty,执行后得到 holding(x),并撤销 on-table(x) 与 hand-empty。初始状态 on(blue, orange)、目标 on(orange, blue),合法计划是四步:unstack(blue, orange) → put-down(blue) → pick-up(orange) → stack(orange, blue)。
合法的动作序列必须逐步满足前置条件,所以规划本质上是搜索问题,PlanBench(Valmeekam et al., NeurIPS 2023 D&B)至今仍在用它量模型的规划能力。
难点在 LLM 时代变了(slides L5 p.14):一切都隐式化之后,写出一个像样的计划更容易了,判断自己的世界模型是否正确反而更难。讲义给的设计取向是少用深度搜索、多用检查世界:观察、验证、从错误恢复;搜索与动作可适用性 applicability 这两个经典概念依然有效。
表示的选择是一条谱系:形式计划可校验,语言计划通用,程序居中。2023 年前后的一条工作线证明了程序这一端的威力:用代码模型直接写调用感知 / 控制 API 的代码,Code as Policies(Liang et al., ICRA 2023)、ProgPrompt(Singh et al., ICRA 2023)、Binder(Cheng et al., ICLR 2023)都是代表(slides L5 p.15)。程序可运行、可检查,代价是受限于 API 与程序结构,不过 API 内部可以再调 LLM。
表示还决定安全性(slides L5 p.32):ReAct 式 agent 让每个页面的内容都能影响下一个动作,等于给提示注入开了门;程序化的计划则可以从页面取值,而不接受页面向它注入的新动作(Piet et al., 2026)。读什么与允许改什么,被表示层隔离开了。
八、拆开 planner 与 executor:专业化与训练
讲义第四部分回答为什么要给 agent 加规划结构,理由有四(slides L5 p.17),也就是贯穿后半场的四支柱:
- modularity:模块性
- feedback:反馈
- long horizons:长视野
- control:控制
讲义并引 Fred Brooks《人月神话》的忠告:计划本就是拿来改的(原话见拆开 planner 与 executor 篇)。
落到工作站任务上是四种规划压力(slides L5 p.18):
- 各厂商搜索分开跑:Modularity;
- 全不满足就修订计划:Feedback;
- 申请人批后才提交:Control;
- 需求与进度跨全任务持久:Long horizon。
从 p.19 起每页页眉都钉着这四支柱的口号:Modularity = decompose and specialize|Feedback = replan when needed|Long horizon = limit context|Control = separate authority。它们是本讲机制设计的词汇表。
四支柱最直接的落法是分离 planner 与 executor:分离的模块可以用不同的模型与训练数据(slides L5 p.19)。
UGround(Gou et al., ICLR 2025)是直接案例。GPT-4o 做 planner 有视觉接地,却给不出像素级动作;于是 planner 只用语言描述下一步动作,再由单独训练的 7B executor 把语言映射到屏幕坐标。Agent S(Agashe et al., ICLR 2025)同属此脉。
训练侧的代表作是 Plan-and-Act(Erdogan et al., ICML 2025;slides L5 p.20):教师模型对成功轨迹做切分并标注出计划,再在标注轨迹上分别微调 planner 与 executor。分工不光可以设计,还可以教。
工程侧还有 LLM Compiler 一类做法,把子任务分工编译成 DAG 一次调度。分离的收益是专业化,代价是接口要自己设计。
经典规划里动作有前置条件,这份遗产在神经时代也有对应物:建模 affordance(slides L5 p.22)。
SayCan(Ahn et al., CoRL 2022)为每个机器人技能学一个价值函数,预测该技能当下完成的概率,再与 LLM 给出计划的概率相乘,用技能的可供性给子任务重打分。LLM 想做的与世界能做的,在此对齐。Zero-Shot Planners(Huang et al., ICML 2022)是同族更早的尝试。
九、多想、多看还是多做:test-time 三岔口与长视野税
test-time 的算力有三条去向:拉长 CoT、采样更多候选、或者与环境更多交互。Test-Time Interaction(Shen et al., NeurIPS 2025;slides L5 p.24)的核心主张,是在这三种方式之间对齐算力:把算力花在当前最缺的那种采样上。
它甚至可以在 agent 宣告完成时插入一句叫停的追问,让模型先别收工、再想一遍;扩展交互还能像 Reflexion 那样从环境拿到更多反馈。
一味多想是有实测代价的。The Danger of Overthinking(Cuadron et al., 2025;slides L5 p.25)归纳出三种模式:分析瘫痪、失控动作链、过早退出;并且跨模型成立地观察到:overthinking 越多,issue 解决率越低。
与多做相对的另一岔是多看。Calibrate-then-Act(Ding, Tomlin & Durrett, 2026;slides L5 p.26-27)的设定是每个文件隐藏三要素:分隔符 , ; \t,引号字符 " ',跳过表头行数 0 或 1,共 12 种组合,全对才能正确解析;文件名如 sales_fr.tsv 暗示 tab 分隔,是唯一线索。
要点在于 agent 不知道什么。CTA 把估计的格式似然注入提示,模型自己读出「分隔符最可能是 ;,概率约 0.85…… 但不是 100% 确定,也许该跑几个单元测试确认」:校准的不确定性直接改变行为,先看、再动。
长视野的账有实测极端案例。Vending-Bench(Backlund & Petersson, 2025;slides L5 p.28)让 agent 长时间经营一门自动售货机生意,定价、下单、补货;视野上限 2,000 条消息、约 25M tokens、最多 222 个模拟日。
失败链条清晰可辨。先是过早补货:把今天到期当成已送达,环境如实报无货;再是错误推断:从现在没货跳到生意失败了,从不等履约邮件到达,也从不复查;最后错误固化:把每日费用当成欺诈,写出主题行带着 EMERGENCY 字样的告急邮件。后期动作不断 condition 在早期错误上。
机理研究给出了名字。The Illusion of Diminishing Returns(Sinha et al., 2025;slides L5 p.29-30)指出,提高单步准确率确实能延长可执行视野,但 self-conditioning,即后续步骤以自身输出为条件,会让后面的步骤变差,两股力对抗;更大的模型执行更长任务,self-condition 也更强,RL 能否修复仍是开放问题。
三岔口的选择不靠直觉靠校准:想之前问「我有把握吗」,像 CTA 一样把置信度说出来;没把握先看,跑个单元测试、读个文件,别拉长推理链或在错误假设上继续行动。
十、单 Agent 还是多 Agent:委派的账本
3a 里 Graham Neubig 客串了一页,专门提醒多 agent 的坑(slides L5 p.21):多 agent 系统的角色在任务到来前就固定;verifier 无法把故障定位到能自查答案的粒度;编码任务的角色分解收益有限;最关键的是,handoff 是摘要报告,会丢掉下一个 agent 需要的 context。
他的文章《Don’t Sleep on Single-agent Systems》发于 2024;CodeR(Chen et al., 2024)是编码侧多 agent 的对照样本。这与第三节 MAST 的诊断互相印证:14 种失败模式大量是组织问题。
Anthropic 的账本给了硬币另一面:其研究系统多 agent 的 token 消耗约为聊天的 15 倍,在并行子任务多的研究型任务上换回 90.2% 的提升,token 用量解释了 BrowseComp 上 80% 的方差。多 agent 的适用条件是任务结构,可并行、需隔离;不是热度。
正面案例在计算机使用域:MACU(Koh, Salakhutdinov & Fried, 2026;slides L5 p.35-44)把长视野 GUI 任务交给 manager-worker 编排,示例任务「finding ACL surgeons」出自 Odysseys(Jang, Koh, Fried & Salakhutdinov, 2026)。
消融数据(OSWorld,36 任务)把分工的账算得很细:
- 固定 Qwen3.5-4B worker,换更强的 manager,显著改善协调;
- 固定 Opus 4.6 manager,越弱的 worker 被拉得越多;
- worker 并行度在 Odysseys easy 子集的 45 任务上持续有收益;
- manager 还会按执行反馈修订任务图,见 Table 2。
重规划本身的消融更直接:把任务图锁死在初版、不许修改,这个长视野基准上的成功率只有约 25%;允许修改一次略有回升,允许的修改越多、成功率越高。计划是假说不是承诺,在这里有了自己的实验。
总体上,MACU 相对较强单 agent 基线提升 3.4–25.5%。
还有一条常被漏掉的账:跨子任务的全局约束。TravelPlanner(Xie et al., ICML 2024;slides L5 p.34)里机票、酒店、美食、景点可以干净分解,但预算、交通、饮食是全局的,且常被各分片分别违反:每个分片单看都合法,拼起来超支、赶不上、破戒。抗分解的约束要在汇合处单独守护。
第三条路是让委派本身可学。RAO(Gandhi et al., 2026;slides L5 p.31)指出委派本身是动作,故可被训练:agent 调 launch_subagent(goal) 跑一个自身副本干子任务,副本可继续委派;每个节点按自身任务成功率加子节点成功率打分;只在中等难度任务上训练,难任务上它自然委派得更深。
同族还有 Recursive Language Models 与 ADaPT(Prasad et al., NAACL Findings 2024)。
十一、编码 Agent 主循环:定位 - 编辑 - 验证 vs 固定流水线
3b 开场把编码 agent 分成三类(slides L6 p.2):写代码是单次补全,修改仓库是改多个文件,执行开发是完整软件生命周期。要素就三个:Prompt、Tools、LLM。
agentic 与单步的分野在循环(slides L6 p.32):单步是自含 prompt → 推理 + 代码 → 评估答案;agentic 是 issue 加既有文件进上下文,搜索 → 编辑 → 跑测试循环往复,产出补丁加证据。讲义用 SWE-agent 的教学图把这个主循环拆成 localize–edit–verify(slides L6 p.33-36),并完整走了一个案例:某配置模块的默认值把显式的 0 也吞掉了。
定位 $ rg 'retries' buggy_config.py
return config.get("retries") or 3 # 零是 falsy:一切 falsy 值都吃了默认
复现 $ RETRY_MODULE=buggy_config python3 -m unittest test_config
AssertionError: 3 != 0
FAILED (failures=1) # 修条件,不改测试
编辑 前:return config.get("retries") or 3
后:value = config.get("retries")
return 3 if value is None else value # 显式 0 得以存活
验证 missing→3 PASS None→3 PASS zero→0 PASS positive→2 PASS
Ran 4 tests: OK # 失败用于指导下一步
对照路线是固定工作流。Agentless(Xia et al.;slides L6 p.37)用分层定位 → 修复 → 验证的写死流水线替代自主循环,就是第五节三栏对照里第一栏在编码域的原型。
工具一端,mini-SWE-agent 证明了极简的底线:只给模型一个 bash(slides L6 p.39-40),读与搜用 rg/cat/find,改文件用 sed、Python 脚本或 patch,执行检查跑 pytest 与 build 命令,回传输出加 exit status 加 timeout。第四节的 ACI 论点在此最纯粹:接口的形状就是 agent 的能力边界。
编辑格式这个看似琐碎的 ACI 细节,实测差距惊人(slides L6 p.41-43):整文件重写简单,但重复未变代码、长文件易截断;SEARCH/REPLACE 块流行,但整段挪动的重构场景里无歧义匹配很脆弱;带行号的 diff 变体,反而给模型添了易错的行号负担。
Aider 重构基准(89 个此类 Python 任务、GPT-4 Turbo)实测:简化统一 diff 61% vs SEARCH/REPLACE 20%。结论是格式收益强依赖任务类型,统一 diff 并非万能;为自己的任务实测,别抄社区默认。
十二、尺子的进化:从 SWE-bench 到时间视界
评测编码生成的第一代思路是文本相似,而它恰好有个经典陷阱(slides L6 p.20):判断整数 x 是否为正,参考解 return x > 0;候选一 return x >= 0,只在 x=0 一处不同;候选二 return not (x <= 0),在整数上完全等价。exact match 把两个候选都拦下 —— 都不等于参考解;BLEU-4 却给长得像的候选一打高分、把行为等价的候选二排到后面:写得像但行为错的,反而排在写得不像但行为对的前面。文本相似不等于行为等价。
结构层面的修补有 CodeBLEU(Ren et al., 2020,n-gram 加 AST 加数据流匹配)与 CodeBERTScore(Zhou et al., EMNLP 2023,比较学习到的表示)。
但真正的口径转向是跑代码(slides L6 p.23-24):候选喂测试输入 −1/0/1,期望 F/F/T,输入 0 实际返回 T,Fail: zero is not positive。
执行式评测接受不同正确实现、能抓语义错误;极限也直白:有限测试会漏错、需要可信的测试与隔离执行、费时且要稳定环境;EvalPlus 专测测试够不够。
基准本体沿两条轴进化(slides L6 p.25-26)。任务粒度从函数级到程序级:HumanEval 是 164 个 Python 函数的 docstring 补全加隐藏单元测试,CodeContests/AlphaCode 是题面到完整程序加编译测试。
指标口径统一为 pass@k:k 个采样程序中至少一个全部通过测试的概率。
非功能需求另有尺子(slides L6 p.27):运行效率按加速比计分、延迟与资源用 DiffBLEU 对照参考编辑、可维护性与安全用 CodeQL × DiffBLEU;NoFunEval(Singhal et al., 2024)收了 397 个这类代码编辑任务。
推理能力也在尺子上。在 的范围内求 ,有三条路:
- 迭代
sum(range(n+1)):大 n 太慢; - 配对端点推出
n*(n+1)//2,并在 0、1 上验证:正确且高效; - 背公式但抄错成
n*(n-1)//2:n=1 就错(slides L6 p.29)。
DeepCoder 的 RL 曲线还显示:推理 token 预算从 16K 放到 32K,LiveCodeBench 成绩持续提升(slides L6 p.30)。
真实软件工程这条线,就是第四节那条陡峭曲线的延长:SWE-bench(2,294 个真实 issue)发布时最强约 2%,SWE-agent 靠 ACI 拉到 12%+,到 2026 年 9 月讲课时榜单头部已过半。
此后尺子一路加严:SWE-bench Verified,500 题人工校验;SWE-bench Pro,1,865 道企业级难题;Terminal-Bench,终端环境。再到 METR 的时间视界度量:agent 以 50% 成功率能完成的任务时长,约每 7 个月翻一倍。
这里的反馈信号干净,进步与度量都能落成数字。
论文与材料导读
- Least-to-Most Prompting(Zhou et al., ICLR 2023, arXiv:2205.10625):解决 CoT 在比示例更难的问题上失效的问题;先分解、再由易到难顺序求解,前答喂后问。局限是分解质量决定上限、误差沿链传递。值得读:分解即泛化最干净的证据。
- Plan-and-Solve Prompting(Wang et al., ACL 2023, arXiv:2305.04091):解决零样本 CoT 的漏步骤问题;一条提示让模型先定计划再逐项执行。结论是十个数据集上稳定超过 zero-shot CoT;局限是计划静态、不响应执行反馈。值得读:证明先想后做零成本起效。
- ReWOO(Xu et al., 2023, arXiv:2305.18323):解决交错式工具调用的 token 爆炸;Planner/Worker/Solver 解耦,规划不依赖观察。结论是 HotpotQA 上 5 倍 token 效率且准确率反升;局限是环境多变时计划易过时。值得读:规划与执行关注点分离的工程范本。
- CAMEL(Li et al., NeurIPS 2023, arXiv:2303.17760):解决对话高度依赖人类逐步引导的问题;双 Agent 角色扮演加 inception prompting,自主分工协作。它既证明了自主协作可行,也暴露了跑偏与无限循环;更大贡献是低成本对话数据生成与「LLM 社会」研究范式。
- AutoGen(Wu et al., 2023, arXiv:2308.08155):解决多 Agent 应用缺统一编程抽象的问题;一切皆可对话 Agent,用对话编排 LLM、人类与工具。它成了事实标准框架之一;值得读:理解对话即控制流的编排思想。
- MetaGPT(Hong et al., ICLR 2024, arXiv:2308.00352):解决朴素串联 LLM 导致幻觉级联的问题;把人类的标准作业程序 SOP 编码为提示流水线,角色分工、中间产物结构化校验。结论是生成比聊天式多 Agent 更连贯的方案;局限是工作流硬编码、欠灵活。值得读:组织结构本身也是一种提示工程。
- Why Do Multi-Agent LLM Systems Fail?(Cemri et al., 2025, arXiv:2503.13657):回答「多 Agent 热闹但提升常微乎其微,为什么」;人工标注轨迹,归纳出 MAST 失败分类法:14 种失败模式、三大类,即系统设计、Agent 间失调、任务验证;开放 1600 多条标注轨迹。值得读:上多 Agent 之前先过一遍失败清单,能省掉大半弯路。
- SWE-bench(Jimenez et al., ICLR 2024, arXiv:2310.06770):解决代码基准与真实软件工程脱节的问题;从真实仓库取 issue 与对应测试,以测试通过为验收。发布时最强模型仅约 2%;局限是以 Python 为主、且验收受测试覆盖度制约。值得读:编码 Agent 领域的尺子本体。
- SWE-agent(Yang et al., NeurIPS 2024, arXiv:2405.15793):解决 LM 直接使用人类接口操作仓库效率低的问题;为 Agent 量身设计 ACI:简洁编辑反馈、防呆护栏、即改即验。结论是 SWE-bench 12% 以上、当时 SOTA;局限是接口需按领域手工打磨。值得读:把工具的可用性设计第一次当成一等研究对象。
- Building Effective Agents,Anthropic 工程博客:不是论文,但与本讲严丝合缝:workflows 与 agents 之辨、五种可组合模式、从简单开始,以及「ACI 值得与提示词同等的投入」。值得读:把本讲所有概念落到工程判断上。
官方指定读物(3a readings)
官方 readings 十篇均在讲义中被逐一引用:Cursor Plan Mode 于 p.4、Least-to-Most 于 p.9……MACU 于 p.38,与上文各节一一对应,此处补短导读:
-
Cursor: Introducing Plan Mode(Cursor 博客,2025) 问题:编码工具为什么集体上线先写计划、人审再执行?要点:持久计划 artifact + 人审核 + 可并行执行,是 Commitment/Oversight 两问的产业答案;讲义用它佐证计划作为外部 artifact 的价值。 https://cursor.com/blog/plan-mode
-
Least-to-Most Prompting(Zhou et al., ICLR 2023) 问题:模型答复杂问题吃力怎么办?要点:先拆成由易到难的子问题、前答喂后问,SCAN 上 14 例即破 99% 而 CoT 仅 16%,分解即泛化最干净的证据。 https://arxiv.org/abs/2205.10625
-
Decomposed Prompting(Khot et al., ICLR 2023) 问题:分解能不能不只切小,还切给对的人?要点:分解器生成子任务并路由给专用 handler,各 handler 独立改进;分解即架构,是 RAO/MACU 委派机制的前身。 https://arxiv.org/abs/2210.02406
-
Code as Policies(Liang et al., ICRA 2023) 问题:计划写成自然语言还是代码?要点:用代码模型直接写调用感知 / 控制 API 的策略代码,可运行、可检查,表示谱系里程序一端的代表作。 https://arxiv.org/abs/2209.07753
-
SayCan(Ahn et al., CoRL 2022) 问题:LLM 的计划接不接地?要点:为每个机器人技能学价值函数预测完成概率,与 LLM 计划概率相乘重打分;affordance 是前置条件的神经版。 https://arxiv.org/abs/2204.01691
-
Plan-and-Act(Erdogan et al., ICML 2025) 问题:planner/executor 分工能不能训出来?要点:教师模型切分成功轨迹并标注计划,再分别微调 planner 与 executor;分工不光可设计,还可教。 https://arxiv.org/abs/2503.09572
-
Thinking vs. Doing(Shen et al., NeurIPS 2025) 问题:test-time 算力该花在想还是做?要点:在拉长 CoT、多采候选、多与环境交互三种方式间对齐算力,三岔口的系统化答案。 https://arxiv.org/abs/2506.07976
-
Calibrate-Then-Act(Ding, Tomlin & Durrett, 2026) 问题:agent 什么时候该先看再动?要点:把估计的置信度注入提示,让校准的不确定性直接改变行为;不知道什么,也是行动依据。 https://arxiv.org/abs/2602.16699
-
Recursive Agent Optimization(RAO, Gandhi et al., 2026) 问题:委派要不要人工设计?要点:委派本身是动作、故可被训练;agent 调
launch_subagent(goal)跑自身副本,按自身与子节点成功率打分,难任务上自然委派更深。 https://arxiv.org/abs/2605.06639 -
Multi-Agent Computer Use(MACU, Koh, Salakhutdinov & Fried, 2026) 问题:多 agent 在 GUI 长任务上到底值不值?要点:manager-worker 编排加任务图修订,消融显示更强 manager 改善协调、越弱 worker 被拉得越多,是多 agent 收益的任务结构证据。 https://arxiv.org/abs/2606.01533
完整资料库见本讲资料区。
实践视角
站主在 SecondPal(本地优先的桌面 Agent)与 PalWave(移动终端)上的实践,给这一讲提供了几条一手观察。
其一,规划粒度不只是效率问题,更是产品交互问题。桌面上 Agent 连跑十步没人管,但手机屏幕上一条计划只有三到五步是可读的:规划器输出的粒度,实际上定义了用户可审批的最小单位。
SecondPal 的计划必须为在小屏幕上被快速批准而设计,这和论文里按任务难度定粒度是两个视角。
其二,ReWOO 式的分离在本地运行时格外划算。本地模型的 token 预算和推理速度都受限,先一次性规划、再批量执行能省下可观的重复提示开销;代价是必须配一个像样的重规划触发器,否则一次文件系统意外就能让整条计划作废。
其三,多 Agent 的真实用途往往在上下文隔离,而不在更聪明。一个 Agent 翻遍整个仓库会把窗口撑爆,拆成「侦查」和「施工」两个角色、各持一个小窗口反而更稳,这与 MAST 的诊断一致:先解决组织问题,再谈智力问题。
其四,编码 Agent 的经验可以整体迁移:给任何 Agent 做工具时,最大的收益永远来自改完立即校验、加简短报错回执这类 ACI 细节。Anthropic 那句「工具接口值得与提示词同等的功夫」,在本地 Agent 上同样成立。
本讲要点
- 规划的本质是把目标拆成带依赖的子任务 DAG:先规划后执行省 token、交错执行更灵活,二者是谱系而非对立。
- 计划是假说不是承诺:失败多源于粒度失当、错误传播与世界漂移,重规划与验证回路比打磨初版计划更重要。
- 多 Agent 用通信成本换并行与隔离收益,阿姆达尔定律封顶;编码 Agent 的成熟则证明:客观验证信号加专为 Agent 设计的接口,比单纯堆智能更有杠杆。
- test-time 算力有三条去向,多想、多采、多做;overthinking 与 Vending-Bench 的失败级联说明何时停比想多久更关键;self-conditioning 是长视野的隐形税,先校准,再行动。
- 编码 Agent 的陡峭曲线是 ACI 与尺子共同进化的结果:从 SWE-bench 到 Verified、Pro、Terminal-Bench,再到 METR 的时间视界度量 —— 最长能以五成成功率干完的任务,时长每 7 个月翻一倍。
收束在讲义末页的设计清单上(slides L5 p.46-47)。给任务加规划结构之前,先过四问:
- 子任务可分吗? 分出来的 planner 与 executor,换不同模型或训练是否有益 —— 第八节的 UGround 与 Plan-and-Act 给的是正例。
- 哪些失败或观察应当改变计划?—— 第二节的触发器要显式定义,第十节 MACU 锁死任务图只剩约 25% 成功率的消融把这笔账摆在了明面。
- 系统如何阻止错误与 context 累积?—— 第二节用验证回路证伪中间产物,第三节让各 Agent 持干净小窗口,第九节的 self-conditioning 税靠校准与训练缓解。
- 哪些信息或权限保持隔离,谁批准不可逆动作?—— 第七节的程序化计划只从页面取值、不接受注入的新动作,第五节的 Plan Mode 把人的批准做进动线。
四格开放问题收尾:语言计划没有通用校验器;agent 误判何时该思考、查看、提问;跨子任务约束既抗分解也抗长上下文;训练出的推理能否吸收这些结构,未有答案。
这门课会逐一回访:多 Agent 角色与通信留给 Interaction 1,澄清与人批留给 Interaction 2,计划上的搜索以及 MACU、RAO 的回归留给 Search 1–2(slides L5 p.6)。
回看导语那条采购轨迹,四问的答案是同一张任务图:独立搜索各自隔离,四家全不满足就是重规划触发器,需求与进度跨全任务持久,提交申请前过人批准。谁批准不可逆动作 —— 这一讲把它交还给人,也把答案的代价算清楚了。
延伸阅读
- Least-to-Most Prompting
- Plan-and-Solve Prompting
- ReWOO
- CAMEL
- AutoGen
- MetaGPT
- Why Do Multi-Agent LLM Systems Fail?
- SWE-bench 论文 与 swebench.com 榜单
- SWE-agent 论文 与 swe-agent.com
- Building Effective Agents,Anthropic 工程博客
- OpenHands,开源编码 Agent 平台
- Cursor: Introducing Plan Mode
- Decomposed Prompting
- Code as Policies
- SayCan
- Plan-and-Act
- Thinking vs. Doing
- Calibrate-Then-Act
- Recursive Agent Optimization,RAO
- Multi-Agent Computer Use,MACU
概念回顾
翻卡自测 · 「再看看」的卡进入复习队列别只读一遍——先看正面的问题,心里作答,再翻面对照。主动提取比重复阅读记得牢。
把目标拆成一串子任务并显式记录依赖,依赖关系通常构成有向无环图(DAG)。
先拆成由易到难的子问题、前答喂后问的提示策略。分解本身就是一种泛化能力。
Planner/Worker/Solver 解耦、规划阶段不看观察,token 成本从随步数二次增长降为线性,代价是计划易过时。
计划过时的解药,关键是定义触发条件(报错、预期不符、连续失败)而非每次重想。
加速比受串行比例封顶:串行占一半的任务,Agent 再多也快不过两倍。
人工标注归纳的 14 种失败模式,结论是大量失败属「组织问题」,即规格未对齐、中间产物无人校验。
为 Agent 量身设计的工具接口:简洁反馈、防呆护栏、改完即验。
用真实 GitHub issue 加测试验收的编码 Agent 基准,领域的尺子本体。
状态=谓词集合,动作带前置条件与效果;合法计划须逐步满足前置条件,规划本质是搜索。
动作在当前世界的可行性:SayCan 用技能价值函数给 LLM 计划重打分,前置条件的神经版。
后续步骤以自身输出为条件:单步更准拉长可执行视野,错误也沿链放大,是长视野的隐形税。
多 Agent 间传递的中间报告;因为是摘要,必丢下一个 Agent 需要的上下文(Neubig 的警告)。
分析瘫痪、失控动作链、过早退出三种模式;实证上想得越多,issue 解决率越低。
k 个采样程序中至少一个全部通过测试的概率,执行式代码评测的标准口径。
官方指定读物
本讲资料库
查看全部 28 条 →- Calibrate-Then-Act: Cost-Aware Exploration in LLM Agents ↗论文2602.16699前沿官方指定
官方指定 reading、L5 p.26-27 主线论文(2026,v1 2026-02-18)。agent 在「继续探索还是提交答案」之间做成本-不确定性权衡:先校准不确定性、再据此决定行动;格式解析实验里文件名是唯一线索,校准的先验直接改变行为。
为什么读
三岔口的「何时停」判据,与 TTI 互补。
Wenxuan Ding、Nicholas Tomlin、Greg Durrett(UT Austin) · arXiv preprint · 2026
- Code as Policies: Language Model Programs for Embodied Control ↗论文2209.07753进阶官方指定
官方指定 reading、L5 p.15 表示谱系主线论文(ICRA 2023)。让代码补全 LLM 直接写机器人策略代码(含循环、感知 API、第三方库),层次化代码生成可组合复杂行为。与 SayCan 构成「选动作 vs 写程序」两条具身规划路线的对照。
为什么读
「程序居中」表示档位的代表,程序可运行可检查的实证起点。
Jacky Liang、Wenlong Huang、Fei Xia 等(Google Robotics) · ICRA 2023 · 2022
- Introducing Plan Mode ↗博客入门官方指定
官方指定 reading(2025-10-07)、L5 p.4/p.33 引用。给 agent 加计划工具与可内联编辑的交互计划,产出含文件路径与代码引用的 Markdown 计划;官方称「先计划后施工显著改善生成代码质量」并支持更长 agent 运行。Shift+Tab 进入,复杂任务自动建议。
为什么读
承诺支柱的产业落地样本,语言计划表示的产品化。
Jai Smith(Cursor/Anysphere) · Cursor 官方博客 · 2025
支撑:先规划还是边走边适应:一次 GPU 采购的三种摆法从 STRIPS 到 Code as Policies:计划表示的谱系与安全账一条采购轨迹,四个问题:第三讲的读法
- Decomposed Prompting: A Modular Approach for Solving Complex Tasks ↗论文2210.02406入门官方指定
官方指定 reading、L5 p.10 主线论文(ICLR 2023)。把分解做成「模块」:难子任务可继续递归分解或换专门子 LLM,输入过长按规模递归拆解,还能挂符号检索器做多跳 QA——「分解即架构而非提示技巧」的代表作。
为什么读
从提示技巧到架构设计的转折点,模块化 handler 路线的源头。
Tushar Khot、Harsh Trivedi、Matthew Finlayson、Yao Fu 等(AI2) · ICLR 2023 · 2022
- Least-to-Most Prompting Enables Complex Reasoning in Large Language Models ↗论文2205.10625入门官方指定
经典·高引(ICLR 2023)。官方指定 reading、L5 p.9 主线论文。把复杂问题拆成由易到难的子问题链再顺序求解、前答喂后问;SCAN 上仅 14 个示例达 ≥99% 准确率而 CoT 只有 16%——「分解本身就是泛化能力」最干净的证据。
为什么读
分解有效性的基准证据,详解篇「分解即泛化」的数字锚点。
Denny Zhou、Nathanael Schärli、Le Hou、Jason Wei 等(Google/Brain) · ICLR 2023 · 2022
- Multi-Agent Computer Use ↗论文2606.01533前沿官方指定
官方指定 reading、L5 p.35-44 收束段主线论文(2026)。manager 把计算机使用任务分解为 DAG,按就绪前沿并行派发子 agent 并随新信息增删改节点;下游不可重观察的信息经 manager 结构化前传。较强单 agent 基线在 OSWorld/Online-Mind2Web/WebTailBench/Odysseys 提升 3.4–25.5%,Odysseys 平均完成时间快约 1.5×。
为什么读
多 agent 正方的旗舰证据,消融三图直接支撑「manager 强弱」讨论。
Jing Yu Koh、Ruslan Salakhutdinov、Daniel Fried(CMU) · arXiv preprint · 2026
自测13 题 · 约 23 分钟即时反馈 · 答错的题自动进入复习队列先自己作答,再看解析——检索练习的效果来自「先提取、后对照」。数字键 1-4 可快选,Enter 提交。
ReWOO 相对交错式(ReAct 式)执行的核心收益是?
下列哪些属于任务分解的常见失败模式?(多选)
串行依赖占一半的任务,Agent 数量趋于无穷时加速比上限是?
「MAST 研究发现,多 Agent 系统失败主要因为模型智力不足。」
把概念与其一句话定义配对:
你手头任务的可并行比例只有 30%,老板想加 10 个 Agent 提速。用本讲概念给出回应。
你的 GUI agent 里,planner 用 GPT-4o:看得懂屏幕却给不出可靠的像素级点击坐标。参考 UGround 的做法(L5 p.19),最合理的设计是?
编码 agent 要做重构:把一个大类里的方法挪成顶层函数(整段挪动、原位置删除、语法仍需成立),任务集是 89 个此类 Python 任务、模型为 GPT-4 Turbo。候选编辑格式:① 整文件重写;② SEARCH/REPLACE 块;③ 带行号的统一 diff;④ 省略行号的简化统一 diff。按 Aider 重构基准的实证结论,优先选?
把 Cursor / Claude Code 式 Plan Mode 的流水线排成正确顺序(L5 p.4)。
TravelPlanner 把旅行任务分解给子任务后(L5 p.34)。下列哪些属于「全局的、常被各分片分别违反」、必须在汇合处单独守护的约束?(多选)
把四支柱与 GPU 工作站采购任务中的具体做法配对(L5 p.18)。
团队提案:给客服工单系统上多 agent——检索、草拟、审核三个角色串联。手头证据:MAST 对 7 个框架 1600+ 条轨迹标注出 14 种失败模式,大量属规格未对齐等组织问题;Anthropic 研究系统多 agent 耗 token 约为聊天 15 倍、在并行型研究任务上换回 90.2% 提升;Neubig 提醒 handoff 是摘要报告、会丢下游需要的 context。最合理的评估是?
为「帮我在 5 个候选房源中选定并付定金」设计 agent 的规划结构。任务要素:5 个房源页面要逐一查证(每页信息很长)、总预算有上限、家人共同决策、付定金不可逆。请写出:① 哪些子任务可并行、上下文如何隔离;② 全局约束如何守护;③ 不可逆动作的审批设计;④ 至少两个重规划触发条件。
题目与解析 AI 辅助生成 · 人工审校。答错的题会按间隔重复节奏在复习页重现。
AI 生成 · 仅供参考,与课程方无关。选中正文里的任何一段也能直接问我(解释一下 / 举个例子)。
英文文字稿(YouTube 自动字幕机转,未校对)
Okay. Yeah, let’s go ahead and get started. So, today is going to be about planning and task decomposition. And uh planning is kind of an interesting topic because it’s a little bit of a a moving target. Um it’s about uh well, we we’ll see. It’s about like
how agents kind of produce a representation of what they plan to do in the future. Um and it builds on some ideas from chain of thought, for example. Um but in agentive settings it’s more um interesting and challenging because the agent is going to reveal
some information from the environment that is going to change what it should do. So plan should always be revisable and there’s a question of like you know how much should the agent be committing to one course of action which could help make things like understandable and uh
overseeable by a person versus how much should the agent be flexible and be able to deal with things that come up um along the way. And we’ll see some different points in the design space that that trade off between these. This is going to touch a little bit on
multi-agent just because, you know, if you have a plan and you try to carry out parts of it in parallel, that’s sort of naturally a multi- aent system. But we’ll be getting more into multi- aent and the way that agents communicate with each other in a later lecture.
But just as a motivating example, let’s think about a task which you could ask an agent to carry out now. And you can think about whether you would trust the agent to do this task or do all of this task. But maybe you want um maybe you want the agent to do some research on uh
GPUs for a research lab that you’re running and you need to compare different configurations from different vendors and but you also have some constraints. You need to check whether they’re compatible with the existing cluster that you have and there’s some
documentation for that and then if things go well the agent should actually buy the the GPUs. So, an agent carrying this out using like a standard React loop, it’s probably going to take it like hundreds of steps, right? Um, it’s going to need to go to the first vendor,
uh, navigate their website, uh, and, uh, you know, find a particular configuration, um, get some of the details of that and then come back to a wiki which has the constraints and compare the available options against that. And then you need
to repeat this process for like some number of other vendors as well. And you know, how do you figure out how many vendors to look at? Um, do you change that up on the fly? At some point, you’re going to probably need to uh compact the context, right? And we’ve
talked about compaction before, but you can think of it as a way of kind of like producing um an artifact which summarizes the things that you’ve done in the past. Planning is going to be a little bit like that. It’s going to be an artifact which the model can refer
to. But the plan is also going to need to specify what should be done in the future um that can help you know inform the agents um actions. So somewhere after like hundreds of steps maybe the agent has like searched four different vendors but it hasn’t found something
that’s a great fit. There’s only one vendor that meets the specifications but it’s going to take 20 weeks for the GPUs to arrive. This is a real example that we ran into a few weeks ago. Um, so now what do you do? Does the agent like go ahead and just buy that? Does it ask a
person? Does it look for additional vendors? Um, so the plan, the actions that the agent needs to take probably need to change based on what it comes across in the environment. So there’s a few things to notice here. Uh, you don’t have to carry all of this out linearly,
right? There’s four different vendors and um you could do separate independent investigations on each one and none of the four you know vendor sites that it chose um were a particularly good fit. So you need to change um and react to this um feedback
that you get from the environment. And at some point along the way there’s also probably a good opportunity to ask a person for feedback. um is this should I go ahead with this thing that’s suboptimal? Should I do something else? And if so, what would be the right thing
to do? So, plans and task decomposition will give us a general way to address some of these challenges um but with some trade-offs as we’ll see. So, one way to think about this particular example is um there’s some underlying structure of the task that
the agent needs to carry out and you can think of this as being sort of like a dependency graph. We’ll see this come up um in one of the papers we talk about towards the end of the lecture. But vendor A, B, C, and D, the um search on each of their sites could be done
independently from each other. If you just have some specification of the task, you could carry out each of those in parallel and then you can take the information you get from each of those and check it against the list of specifications that you have. So there’s
a dependence of doing this compatibility check on the information from the vendors, but each of those vendors um does not depend on each other. And then after you’ve done this compatibility check, you would ideally want to do a requisition, right? Maybe
you start the task and you think, I’m just going to look at those four vendors, do the compatibility check, then do the requisition. But if none of them actually matches then maybe we need to add in some new subtasks which we could represent as new nodes in say a
graph um based on some feedback that we got from the environment along the way. So this is called replplanning like um you have this plan this um structured representation of what you want to do and then you make changes to it based on observations from the environment.
So yeah, some of the questions that we’ll ask today are is planning like having an agent commit to what it intends to do in the future, is that useful? Um when can it be useful? When might it not be worth the additional cost or the additional kind of rigidity
that it places on the agent? What are some ways to represent plans? Is it just text? Is it a structured graph like this? Um code is also a way that you can represent plans. And if you make a plan, when should you change it? Like should you in this
example add in another vendor to search? And also like how and when should a person weigh in? So um how many of you would be comfortable like having the agent actually like buy GPUs for you? Uh yeah, you probably would ask for input from the person. Um and you would
probably ask towards the end of this right after you’ve collected more information. But for lower risk tasks, maybe you’re okay with the person, you’re okay with the agent um just carrying out a plan and adapting where you’ve only signed off on the initial
plan or maybe you don’t even need to sign off on the plan at all. So, how many folks have used uh planning mode in a in a coding agent? These became Okay. Yeah. So, a number of folks have these became pretty popular I think about about a year ago. Um, and they’re
um they exist in in cursor. I think cursor was maybe one of the first ones. And it’s also pretty interesting and fully featured. We’ll we’ll see a demo of it later on in the lecture. Cloud code and codecs do too. But the idea between all of them is you prompt the
agent um with a complex task. It produces a natural language description of the steps that it’s going to do. Um sometimes after doing some initial kind of nondestructive um actions like exploring your codebase or taking other information gathering
actions that don’t actually change things but just get the information that would be helpful to let you weigh in on whether the plan is good. Um so the human verifies it or maybe makes some edits to it um by editing the plan directly or by giving some you know
feedback messages that let the agent update the plan. And then after the plan’s confirmed you would do something like click build and then the agent carries it out. And this is also a chance for um parallelizing the execution of the plan um like using sub
aents to carry out individual items in it. And we’ll see some research papers later on that show methods for for doing this. So why might this be helpful? Does anybody can anybody suggest some reasons that you might want an agent to plan?
Any hands? >> Yeah. >> Yeah. Definitely. Yeah, you for tasks where it’s hard to trust the agent, the plan can help like build that trust um help you know that it’s likely to do the right thing.
>> Yeah. Yeah. So, this is like it’s in cloud code, this is actually phrased as a permission mode, right? Like um in the same way that like the agent would either carry out all actions or ask on every action. There’s like plan where you carry out the information gathering
actions and then you can act more permissively afterwards. >> Yeah, >> maybe the plan out like a lower global cost than like >> Yeah, planning and then executing could have a lower total cost than greedily
executing. Yeah, that’s true. And that’s a big motivation for for planning. Um there’s a few ways that could play out. Like one could be maybe these tasks are simpler, these, you know, items in the plan are simpler and so you um could have like a weaker agent carry them out.
Um but you need a stronger agent which is more expensive to run to actually generate a good plan. Um it could also be faster if you can parallelize the agent, you know, the sub agent calls. So it might um even if you’re using kind of the same size agent for everything um
maybe you’re not spending less compute but maybe it is like more time efficient but also like a plan could potentially um avoid the agent make it easier for the agent to not make mistakes that would like send it into you know loops and cause more actions. Um yeah
>> sometimes like when you have class you don’t have a very structured how to explain it so you might just learn about all the uh whatever ideas you have you might structure it out and plan both you agent and yourself >> right yeah so a plan can kind of be like
a um scratch pad for um thinking about how to solve a problem that’s shared by the person and the agent together. Yeah, that’s right. Cool. Yeah, maybe one more. Go ahead. >> A very long task which needs to be divided into multiple subtasks.
So like visibly split it into multiple task that structured present itself. >> Yeah, that’s right. So having kind of like a structured artifact of what was done and what still needs to be done in the future can help the agent keep track
of um its progress through the task. Yeah. And so like this is also you know that that motivation is kind of similar to the ones that we talked about for like context management. Um yeah but it’s doing it in a human interpretable human editable way. Yeah. Great. These
are all great um arguments for planning and uh yeah, I think we I think we covered all of those. Cool. So yeah, so we’ve gotten at this already, but our working definition for a plan for the sake of this lecture is some representation of what the agent is
likely to do in the future. So the actions are the sub goals that it will attempt with any ordering or dependencies between them like you know the dependency edges that we saw in that graph or just kind of like a linear ordering of steps.
So um skills which we talked about last time were about reusable guidance that applies across tasks um things that are common for different distinct tasks whereas a plan is just for this particular task. um and doesn’t deal with generality as much. Um so plans can
be more specific than skills and can um uh be uh you know tied to a particular repo. Um for example, so yeah, like we said, a plan is um sort of an organization of future work and it’s just a proposal, right? Um the agent may need to deviate from that plan depending
on some things that it finds in the environment. So it might need to replan, but um that is also the ability to replan is also going to make the agents behavior less predictable or less specifiable by a person. So that’ll be a trade-off that we’ll uh we’ll deal with
a little bit later. Yeah. And I like this quote, everybody has a plan until they get punched in the mouth, which was from the boxer Mike Tyson. Um so it’s good to have a plan, but it’s also good to adapt your plan your plan on the fly.
So we will talk about planning a few different uh times in this course. So mostly today but in the coding agents lecture I think Graham is going to talk about agent lists which is um sort of a structured um uh plan that the the agent will stick to um when um solving uh code
like when implementing pull requests when solving coding issues. We’ll also talk a little bit about multi- aent. Well, we’ll talk a lot about multi-agent which has connections to planning in one of the interaction lectures. Um, we will talk a lot more about how humans can uh
provide supervision to agents with plans is one mechanism for that in the second interaction lecture and also in the search lecture we’ll we’ll talk about um uh search applied to multi- aent systems um including the the MACU and the the row systems that we’ll talk about today.
Yeah. Any questions before we get started? Okay. So, planning has um has a history um and the first part of this history is the more recent one. It’s from um LLMs and chain of thought. So, I think folks
should be people have seen chain of thought, right? Like um uh people are familiar with reasoning models. Quick. Yeah, we’ll do just a very very quick recap of those. Um, but chain of thought is um kind of exemplified by these two papers that had
prompts um for even before models were trained to produce chains of thought explicitly. They were, you know, um, before models were trained to produce chains of thought that the model could condition on to produce an answer, which would be a reasoning model like R1 or
01, um, people were having models produce chains of thought just by prompting them. Um, and they found that prompting the models to produce chains of thought, um, made them better at producing answers. And here were some of the prompts that people explored. So
this paper from Kojima at all they had a pretty fun table in the paper where they like listed out the prompt that they used and then the accuracy of the model um when prompted in that way and they found the most successful one was let’s think step by step. U so this kind of
became famous for a little bit like let’s think step by step is all you need. Um and you know then uh models later on were trained to produce chains of thought in a way that was more robust to the prompt. Um but the basic idea in these works was the chain of thought
will provide um a way for the model to use extra compute. So it’s taking in these tokens um in the chain of thought that it produces um and um that’s allowing it to do extra operations before predicting the answer. And it also provides like a scratch pad for the
model to refer back to. So for complex problems it’s useful to um write down some intermediate results that you get and sort of like externalize the process of solving the complex problem. And that’s the same kind of motivation that we’ll have for agents planning. Um
so in these works the model was doing the chain of thought generation and the solution just in one generation pass from the model generating the tokens of the chain of thought one at a time then producing the answer. And um we’ll also see some planning approaches for agents
that look like this. But you could also imagine something like explicitly you know modifying the chain of thought or inspecting the chain of thought and then using that um controlled chain of thought as conditioning context for the answer. There’s analogies of that for
agent planning too. And uh so I think kind of right now for agents we’re sort of here like after these you know we’re we’re sort of like after these two approaches and starting to do work that is like training an agentive system to produce a plan that’s
also useful for the answer. Um but that has been more thoroughly explored for reasoning models. Um with like star and and deepseek being some of the first papers to do that. We will see some papers toward the end of this lecture like Ralph for example that train models
to produce a plan that’s also useful for producing a verifiable answer. So building on kind of the foundation of chain of thought people developed approaches for decomposing complex reasoning problems um into subtasks and showing that that could improve
performance. So a couple papers that did this, one was called least tomost prompting from iClar a few years ago. And a more recent one that I also think of as being sort of like this is the recursive language models paper. Um but the idea here is you will have um you
will call your reasoning model once you will call your LLM once to take a complex problem and decompose it into parts. So for like this paper, the least to most paper was validating on math problems um and they have the language model taken a more complex problem and
then predict um some sub questions from it and the idea is those sub questions will be easier for the language model to solve than the initial problem. So the model can take you can then make um successive calls to the language model on the simpler problems and um solve
each one in turn where some of the calls can also depend on the answers to earlier questions. So like we might first start by solving how long does each trip take and we’ll get a solution to that. Each trip takes five minutes and then you’ll move on to the next
question generated by the language model and as an input to that question you’ll also feed in um you know the full complex question and the answers to the previous ones. And for the models at the time this was really helpful because the models were not as good at answering um
questions that involved multiple reasoning steps um in one shot. Um and you also don’t need as much context to answer um the sub questions in compared to the full question. Right? So maybe to answer this you just um need some parts of the initial question and um the
answers to some of the tasks that you’re depending on. So these motivations will be the same for for the agents that we have now. like it’s potentially easier for an agent to solve a subtask because it doesn’t need all of the context that you need for the full task. Like um if
you’re you know searching for one particular uh vendor’s GPUs, you don’t need to reason about like um the information from the other vendors. You can just bring that back and then aggregate it afterwards. And another advantage of um decomposing
um a complex task into subp parts is that you can use different models to solve some of the subp parts. Can anybody think of uh of motivation for for doing this? Why might it be useful to use different models um to solve different like types of questions?
That’s right. Yeah, you could um find or develop a model that’s sort of specialized to that particular type. Um we’ll see some examples of that. Um another motivation is what we had earlier that like um it might be more efficient. Uh like uh you may not need a
model that’s as expensive to run to solve like a simpler question. So a paper that did this was called decompose prompting. The idea was kind of similar to the ones that we just saw where you like take a complex question and you have a decomposition uh model generate
sub um questions from it and each of those questions also has a type predicted for it. So they were focused on question answering. So um they had different types of questionans answering tasks like one was just general QA um like who were born in the year 910 1910
um and others involved uh some relational information about people and their jobs um like which movies was um this would be a reference back to the answers of previous questions. um for which movies was argument number one the producer and that would be um predicted
as this particular type of QA problem. So um in this work I think they were using um different prompts for a language model to implement these models where um the model had um some few shot examples that uh made it better at general QA or made it better at this
sort of positional QA. But you could also imagine some of these models having access to like specialized knowledge or in a language model context like specialized tools that the others do not. And this paper also uh had a simple form
of programmatic control where um you basically like specified an ordering over the subtasks that you would be doing in the future and you allowed passing some information from the answers of one subtask to the next. Like um this would refer to this would allow
using the answer from a previous subtask as an argument here. and they had a pretty structured representation for this. But just like in the skills lecture, we went from sort of templates to code. You can also imagine going from uh a kind of structured domain specific
language to just generally using code to control this sort of orchestration of subtasks and we’ll see that later on when we talk about route. Okay. So some brief uh motivation from kind of the OLM chain of thought side, but I also want to talk about what
breaks down when you move to agentive settings um that actually need to act in the world. So a chain of thought, reasoning step, it’s just producing text, right? Um it’s not um making changes in the environment like an agent could. And it’s usually not revealing
more information either, right? everything that’s being generated in the chain of thought kind of came from the language model. Um we’re not using tool calls. Um and the model can sort of undo you know the reasoning steps by just saying something like never mind and
then saying you know the change um which then ideally it would be able to condition on. So if we’re actually acting in the world we have a lot of challenges. Um, so the agent is going to be taking actions that reveal information like finding out what GPUs
are available from a vendor. Actions could fail. So you might have a really great plan, but then it turns out, you know, the thing that you need to carry it out is just not available to you. Um, and you can also make like actions that irrevocably change the state of the
environment, like deleting all of your files. Um and those are challenges that don’t exist for reasoning models. So there’s been a long tradition of work in AI on um planning and the plans in classical AI have some important differences from the ways that we use
plans to you know describe LLM agents. But kind of a core of classical planning is you have a structured grounded in logic um representation of the world. You have um states which are a set of um predicates. So like you know functions that can be true about particular
arguments. So this is from like a robotics domain um where you have objects um which instantiate these X and Y arguments and you have predicates which are true or false about these arguments like an object could be on a table. One object could be on another
object Y um and so on. And you also have actions that your AI system can take in the world which will update the states. So these are also these are basically functions that are applied to um two arguments and to be able to represent like changes in states you will define
um preconditions and effects for each of your action functions. So a precondition is basically like when is it when are you allowed to apply that action. So like you can pick up an object if an object is on a table and there’s nothing on top of the object and your robot hand
is empty and then after you apply that action then you have a new state which is a conjunction of predicates. So you’re holding that object the object’s not on the table and the robot hand is not empty. And this is um this is a language called
strips which was really widely used um for for planning. Um PDDDL is is another one um that people are actually using as an evaluation target for LLMs. Um you can take a look at that paper if you’re interested. Um and people are thinking about the ways to combine you know kind
of the strengths of both. But a planning problem is you have like some initial state and you have a goal and the goal is also a state. And your problem is how do you find a valid sequence of actions that get you from this initial state to the goal? And an action sequence is
going to be valid if um every action has its prerequisites met by the state that you’re currently in. So here’s an example plan. Like if you have blue and orange blocks and the blue block is on the orange and you don’t have anything on top of red, blue and yellow, you can
have a sequence of actions like this which you could uh hopefully I checked this carefully enough. You could take a look and see this is a valid action sequence and it does get you to the goal. So a lot of work in planning was and still is about search like you
develop search algorithms things like BFS, DFS, AAR with different heruristics that given this very structured representation um figure out a plan that gets you from a start state to an end state. So that’s classical planning and there’s
a lot of differences from planning with LLMs but some important similarities too. So with LMS like everything here everything is explicit right you know exactly when an action applies you know exactly what the action does you also a lot of the time know a lot about the
world um there’s also ways to represent uncertainty in those approaches but with LMS everything is implicit right like um for an LLM you don’t know exactly what an action entails like when you could apply the action most of that lives externally to the agent you have to just
like try stuff in the environment and see if it works. But for an LLM agent, you don’t have to do a lot of search to write a plausible plan because, you know, LMS have just seen a lot of information about all of these different settings that we’re operating in. So,
they could just generate some text that’s probably a reasonable first guess at how to move one block to another or more complex tasks like how to debug an issue in a codebase. So for LMS planning is less about doing search although we will later on in the end of the course
see ways to bring search into improve LM agents and more about just like checking to see if your plan is actually feasible and executable. Um but important concepts are still search to some degree and also action applicability. So we don’t have a way of
like doing these you know precondition checks that we did with classical planning but we will see some approaches that um try to incorporate information about what you can do in your environment into the way that you choose your plans.
you might now’s a really good time to start to think well if we aren’t doing classical planning um what do our plans actually look like? And formal plans like the ones we saw with strips they’re checkable. Language plans like the you know ones that we saw in the plan mode
um at the beginning of the lecture are pretty general. Um programs are also a way to represent plans that sit somewhere in between. And there were uh a number of papers around I think 2023 was kind of the start of these that use a code language model to write basically
a code structured plan um which controls the system um and it was applied to um some domains including robotics and also others including kind of like structured question answering this paper binder we also did some work on this here um for kind of like semi-structured question
answering. But the basic idea here is you have a task that comes into your LLM like stack the blocks on the empty bowl and the LLM will be prompted to generate a program which um makes calls to um domain specific APIs or functions and those functions are going to be
implemented using um sort of like uh rob primitives from you know the robotic system like uh calling an object detector on an image to see are there any blocks or are there any bulls um and then actually like making calls to um object manipulators also. So for this to
work, you need to have um good APIs and good primitives. Um but you also need to have sort of the tasks that you want the system to carry out be well representable by code. And code has some nice features like you can say like wall I haven’t put the block on the other
block retry doing this thing and which is sort of a way to you know implement kind of like search and post conditions. Um, but it’s also like we talked about in the skills lecture, a little bit more rigid. Yeah. And a way to make it more flexible
is your API functions here can also be calls to an LLM for example or another sort of neural model like um you know a ResNet based object detector. So you get some benefits of like you know having the structured control programmatic control of code but also um you could
use um tailored models which can be machine learned and more flexible. Any questions about this? Yeah, these approaches have started to at least for robotic domains. My understanding is these approaches have not taken off as much as um you know
endtoend like uh multimodal LLM based VLA uh type systems which can be directly trained. Um but these sorts of approaches are still like very useful for for example coding agents. Um we’ll see a little bit about that with code act um in the next lecture.
So another dimension to think about is like changing up the plan um based on feedback that you get from the environment and is that useful or not to do. So Anthropic put out this blog post a couple years ago called building effective agents um where they’re
basically kind of coaching you don’t start with an agent like start with something simpler that’s easy to reason about that you can specify in advance and they call those uh workflows. So in a workflow you have a um fixed programmatic way of making calls to
language models um that specify a lot of the information that you have about the task. So um say for this GPU example say that we were going to buy GPUs very frequently uh because we’re rich and we always want to follow the same procedure for doing that. So we have a fixed list
of vendors whose sites we are going to go to and do research. We’ll read those specifications. We’ll check if they fit and then we will pick the cheapest one and buy it. Um this is actually somewhat similar to like the agentless harness that I think we’ll talk about in the
next lecture. Um so this is nice because you you basically like know kind of the highle structure of the task that the agent’s going to carry out. it has some flexibility to adapt like if the vendor website has changed it will hopefully find the right information um from it
and you know that it’s going to like you know pick the cheapest one so so that’s nice um but it’s also pretty rigid right like you know what if um these vendors are no longer the best ones to do research on so it can be useful to relax some of these constraints too and for
example like have the agent predict the list of vendors um that should be researched searched and maybe you do like a search that produces that list. Um, or you just go fully adaptive and don’t have this structure at all, but just give the agent sort of like the
description of what you want it to do. You turn it loose and there’s not much planning that happens um in a way that’s specified by the person in advance. So, there’s a trade-off here. like committing to a plan upfront. Um it’s potentially like faster and cheaper and
more predictable um because you could maybe like use smaller, simpler models to implement each of these parts. Um but if you aren’t changing this at all, you like lose the ability to adapt to changes in the environment. And uh we’ll see a little bit later on
that replanning um can sometimes be you know worth the extra cost and complexity and unpredictability that it adds to your system. Any questions about this or or other things? Yeah. So if you take a look at this uh
blog post, they’ll say we’ve deprecated this um and they point you to another one. But I think part of the reason they’ve done that is the agents that we have now are stronger um kind of the most recent agents with the most recent models are stronger at making reasonable
actions a lot of the time um not constrained by workflow. I think we’ll see this with coding agents also where um this agentless framework is no longer um the most successful framework for like solving issues. Um, so some of this scaffolding can be replaced as your
agents get stronger for a particular domain, but you also potentially like lose reliability. And if you’re working on a new problem where you haven’t um, you know, where agents haven’t been trained um, to be able to react to changes in the environment, starting
with a workflow is probably a safer way to go. Questions, thoughts? Okay. So, reasons to um add some structure to planning. Um and we’ll talk about some of these that were motivated by our initial example. Um coming back
to it again, we have you know um this modularity like carrying out each of these subtasks independently from each other. Um feedback like uh potentially changing the plan based on things that you observe in the environment.
One thing that’s really common across all of these is that they’re long horizon like um you need to keep track of information and um it could be helpful to have some you know prediction of what you are going to do in the future and then potentially also you
know control where a person might weigh in on the plan um or changes to the plan along the way. And this will structure the next um the next part of the lecture which is mostly talking about kind of approaches that have been developed in the research literature to handle each
of these. So first with modularity, we touched on this a little bit before uh where uh we you know we said that it can be useful to have different models that are specialized in different ways to carry out different parts of a task. And these
types of approaches were really widely used for computer use agents for a while because um the the strongest models for producing like plans um were not very good at processing kind of like low-level fine grain visual details about websites. So um in 2025
um there were a few papers that were pretty successful by separate by like you know solving tasks on the web like finding the cheapest 4K monitors and they would decompose this into a planning step where you well actually a sequence of planning steps where you
have a strong planner model like at the time GPT40 um would take in the web page and would produce a natural language description of what should be like um you know type in the search bar at the top of the page but this model
would be very bad at like actually clicking on the search bar um especially if you needed to kind of like click on particular pixels. So what they did was they trained a small this was the U groundwork. They trained a small 7 billion parameter model on synthetic
data um where they you know had web pages and they were able to kind of like synthesize text descriptions like this for particular elements of the page and once they got that model to be very accurate then you could use it to execute these natural language
instructions that were produced by the planner model. Right? So decomposing and making the system modular can kind of like let you independently optimize each of the components and like hill climb on each one after you figure out what the bottleneck is. And these papers were
nice examples of this. After this work was done, um the companies that trained, you know, these big language models like the successors to GPT40 started putting a lot of like web um data with the same sort of like fine grained, you know, stuff directly
into the training of the big model. So these kinds of approaches were no longer as necessary for just improving performance, but still are potentially useful for improving efficiency. We’ll see a little bit about that later on. Yeah. So you can train um you know you
can train a model that carries out parts of a plan like they trained the grounding model here but you could also generate data to train a planner. One way you can do that um was explored by this plan and act paper where you want um so the task that they’re doing here
is um yeah the task that they’re doing here also involves like you know actions in an environment um interacting with a web page and they want to have a planner model be able to produce a plan that kind of looks like this like step one is going to be searching for this
particular place Step two is going to be analyzing the results um and then hand off um the execution of the plan to a model which looks sort of like the execution model we saw on the last slide. So they need to you don’t have sort of a naturally occurring source of
data for these plans. So what they’ll do is they’ll get entire trajectories um carrying out tasks um filter down the trajectories to ones that they predict are correct and then have a teacher LLM annotate that trajectory with basically a segmentation of the actions um and
labels in natural language for each of those action sequences. And once you have that, you can sort of like unzip that and create your training data for a planner, which goes from, you know, a natural language description of the task to the sequence of natural language
steps. And then the executor also, which maps from a natural language description of a step to the actual actions that you take in context. Does that make sense? In some ways, this is a little bit similar to the workflow induction stuff
that we talked about last lecture, right? Like workflow induction also started from a trajectory and did sort of a segmentation and labeling of it. Um, you’re doing a similar thing here, but you’re using it to generate training data for a model that produces those
uh those descriptions. So there’s some trade-offs also when you go to a modular system like this. You’re um you’re decomposing a task into you know kind of a set of subtasks and a sequencing of them. And this is an abstraction that can miss some of the
details and and be inflexible. Um there’s been some limited successes of like ro decompositions for coding. There were a sequence of papers that like um said we’ll have models implement sort of a software company or like a team of software engineers um that might have
like dedicated roles for testing um for editing. Some even have like a product manager and um those approaches have and some variants of them like like agentless which is kind of like very tailored to um solving um GitHub issues um have success in sort of the if the
task always matches that structure but they have some weaknesses too. um they’re not adaptable as we talked about before and they also require like passing information from one of these um modules to another and it could be hard to sort of get the right information
um that the other agent needs to solve its task. Whereas if you’re doing this just in a single agent and you have done a good job of handling all the context of the past actions that are available, all that information is going to be there for the agent to use. So those are
some of the trade-offs um between uh these approaches that you know just have a single agent try to do everything or use a planning based decomposition. So if you have like a sequence of subtasks that you want to execute in an environment, one thing that we’re
missing from classical planning is figuring out if you can actually do the subtask or not. So people started once LLM started to become you know really successful on NLP tasks people started to see if they could be used to control for example robotic systems and replace
some of the planning systems that were used in the past. So you would give a system something like uh an instruction like how would you put an apple on the table and just have an LLM produce kind of like a text standin for a plan and you could sample a lot of different
possible next steps in the plan from the language model and under each of these you get some score from the language model. Um these would be like you know uh sums of lojits. Um and some of these might be pretty plausible under the language model but the language model
doesn’t actually know what the robotic system can do in a particular context. So it might propose like you know pick up the apple but if there’s no apple within sight of the agent that’s a bad subtask to actually carry out. So this paper called sean um integrated the LLM
being used as the planner with a model of affordances like whether a subtask produced by the planner could actually be carried out in the environment. And they used some classic techniques from robotics to develop that model that value function. Um, but that value
function basically was able to predict the probability of being able to execute any of these natural language descriptions of a subtask in a particular context. And when you have that, so like you know, if you’re not near an apple or a Coke can, then those
have low probability and finding them has higher, right? And yeah, and like placing it has even lower probability because you don’t have it. So the simple way of like incorporating this value function of whether you can actually carry out a subtask with the planner is
to just multiply together the probability that’s given to you by the value function with the probability given to you by the language model. Any questions about this? Yeah. So the next thing that we want agents to be able to do is to
incorporate feedback from the environment, right? So we saw a precursor to this when we talked about reflection, right? Like you have an agent try out a trajectory, you see whether it succeeded or failed, you get some natural language feedback, you
condition on that and you try again. And this can also this is especially applicable in environments where you don’t get to see everything from the initial state that you’re at. So this example is from a paper that was operating in this embodied environment
called Alfred where you have a robot navigating around inside a simulated robot navigating around inside a simulated house and you have tasks like cook a potato and put it into the recycle bin. These tasks were synthetically generated so some of them
are kind of funny. Um but the model will produce an initial plan that makes calls to these um these primitives which can carry out tasks like navigate to a potato, pick up a potato, put it in the recycle bin and it’ll try to carry out that plan but um the plan might not
actually be executable by the robot in that context. So you might get feedback like I cannot find a potato but I do see a fridge. you can just feed that feedback into the language model and then try to repredict the plan which will now be updated to like open the
fridge and then hopefully there’s a potato in there and I should continue on with that. And so this is kind of a simple like reflection based way of doing replanning that can help. So there’s generally a trade-off between um you know thinking between doing the
reasoning steps without interacting with the environment and taking actions in the environment and it can be there’s a trade-off between these and different ones can be uh valuable to different degrees um but I think there’s this paper was pretty
interesting that showed um that if you have an agent that’s acting in an environment um you have choices about how to spend your compute. So you could um if this is a reasoning model, you could produce like longer reasoning chains um before
you take a particular action or you could just take more actions and interact more with the environment and um then you’ll potentially be getting more information but you’ll also need to you know process that information with your language model which will also be a
way to spend compute. Um and they uh they compared these two approaches on these tasks that they looked at and um they also compared to a baseline approach which uh we’ll cover this more in the search lecture but um which just like samples multiple different
trajectories from the environment and then chooses between them using a judge. That’s that orange line here. So an approach that just got the model to think longer, produced longer chains of thought before taking each action is this blue line. And an approach that
interacted more with the environment is the green line. And for like a given number of tokens um spent usually this green line which is using those tokens to interact more with the environment is doing better. Does that make sense? Was the description clear to folks?
So, I think that this is kind of like a nice way of thinking about um just the value of interaction. Um getting more information from the environment, as long as you’re not doing things which put you into a bad state, um is generally pretty helpful.
And another paper that looked at this from another angle um that Graham was actually involved in too looks at um kind of the perils of overthinking for coding models. So they um identified different sorts of behaviors that um reasoning models um used as a or models
that produce you know thinking traces used as foundations for agents different sorts of bad behaviors that those models could produce which um affect the actions that they take in the environment. So, one of these types is the model spending too much time
planning and not um taking as many actions. Another one is like taking actions which aren’t useful but make kind of like harmful changes to the environment. Um and then there’s a third one too like ending the task too early. So these um behaviors that they
identified they um don’t actually require access to the reasoning traces because if you know they just require access to like how many tokens were spent on reasoning which you can get from a lot of these API models. Um but they look at sort of the balance of the
actions that you can actually see in the environment with the number of reasoning tokens that are spent. And they developed some classifiers for these uh different types of behaviors and use that to produce a classifier which gives you sort of an overthinking score for a
given agent backed by a language model acting in a codebase. And they plot these comparing performance on this benchmark of solving SWEBench issues with the overthinking score and find pretty strong negative correlations. So that models that are overthinking more
like kind of um not uh acting appropriately and doing too much thinking um are doing worse on these benchmarks also. So they generally find that some of this is addressed by having like larger or stronger models. Um and so you can see like you know 01 with a
lower reasoning effort is worse. 01 with a higher reasoning effort is better overthinks less also does better. Um and even non-reasoning models which you know still produce some text before taking their actions um have this sort of behavior as well although it’s less bad
than it is for reasoning models. So uh yeah taking feedback from the environment is useful. Um and uh you don’t want to be spending too much time planning. Um you also want to replan as needed. Yeah.
So um this paper we won’t have time to go into the details of it uh for the sake of time but I think it’s a really interesting paper that I’d encourage you to take a look at uh if the idea is intriguing to you. But the idea is that like some actions that a language model
can take um are just sort of like plausible and m you can maybe do something reasonable without actually checking the details of the environment. So say like you you know ask a you um ask a coding agent to investigate a CSV file and find the item with the max
price. So most CSV files that are related to prices probably have a column which is called price, but not all of them do. So a language model could take an action like this and it’ll be right most of the time, but um sometimes it’ll be wrong. And this paper is sort of
about um how do we um explicitly represent the probability that a particular thing is true about the environment like you know it has these particular properties of the CSV file and if we explicitly represent those probabilities can it make the agent more
likely to do the right thing and they find that it can. Yeah. So I’ll encourage you to to check out that paper if that sounds interesting to you. Yeah. So part of the motivation too is for letting the model better be able to
carry out um long horizon tasks. And uh I think one of the canonical examples of a long horizon task is this task called vending bench which is challenging sort of because it’s a long time horizon more so than because it requires like complex reasoning but the
idea is to like run a simple business for a long time where the business is just operating a vending machine. Um so you have some set of items which have prices. You need to order new items if your stock gets low and put those in the vending machine. But the challenge is
you have to do this for up to 222 days which can require like 25 million tokens from a model. So you need to be able to like track state over time and make good decisions um over and over again um without being poisoned by things that you do wrong in the past.
And um models have gotten better at this uh as they’ve been trained um with long context and trained with RL to be able to recover from their mistakes. But there’s been some analysis that’s um looked at uh that’s looked at some
surprising properties of models um in these sorts of long horizon tasks. So if if you one thing that’s really challenging about um tasks that involve taking like hundreds of steps in a row is that you have to have extremely high accuracy on the individual steps in
order to have a high chance of being accurate on the full trajectory, right? Because probabilities get multiplied by each other. If you have like a 90% chance of getting the first step correct, if you have a 90% chance of getting each step correct, um getting
all the steps correct is like 9.9 * 0.9 * 0.9 * 0.9. And uh this paper looks at so on the left here is the accuracy of individual um steps on a simple task and on the right is um the length of the task that the model is able to carry out correctly. So even you
know going from like 0.9 to like.999% um accuracy on individual steps produces a really large uh impact on the length of the task that you’re able to do correctly. But one really interesting thing is because the model’s using its past
context um to uh make future actions and since these models were you know trained um on uh were trained on like uh sequences of varying quality um if you have mistakes in the past that can actually make mistakes in the future more likely.
So why might this be? You know, one way to think about this is like models were were pre-trained on all the code from the internet. And if you have like good code in a file, like highquality code, then it’s probably likely that the rest of the code in that file is also high
quality. Whereas if the code is like, you know, maybe has some bugs or was sloppily written, probably the rest of the code in the file is also lower quality. So for a long time and still to some extent now, people found that if you sort of like seed a model with bad
quality inputs, it’s more likely to produce bad quality outputs in the future. And this paper finds that that’s true for um agentive um systems as well, although it’s corrected to a big extent by training models with reinforcement learning. And that makes sense, right?
Because as we’ll see a little bit later on, reinforcement learning teaches models to um be able to correct mistakes um and to try to optimize their reward in the future independently of the past. But something to watch out for in long horizon tasks and that’s some motivation
for uh yeah so they showed that this is true for example with the quen 3 models which are pretty recent models right they find that if you insert errors into the past context of the model at higher and higher rates um the strongest you know the presumably strongest the
largest model quen 3 32b actually has the biggest drop off in accuracy in comparison to the other models So it’s um sort of more susceptible to being poisoned by mistakes in the past. Cool. So we’ve I’ve kind of alluded a few times to this paper row um which is
uh recursive agent optimization from Aporva who’s one of our TAs um and uh and Graham is also um an author on this paper and this paper is really cool because it um trains the models. So we’ve we’ve talked a lot about like you know is planning useful is decomposition
useful. One way to make sure that it’s useful is to just train the model to be able to do it um to succeed on a task. We’ve also talked about kind of what’s the right representation for a plan and how code can be useful as a representation. And I’d say those are
two of kind of the main ideas of this paper. You’ll train a model to produce a plan in code. um and then execute that plan using sub agents which have more limited context so they can be more efficient. They don’t see you know some of the unnecessary stuff that other
agents are doing. Um, and so if you have a task like plan a 3-day Kyoto trip in early April that has these properties, they train the model to produce code that looks like this, which launches sub agents that have these subtasks where the subtasks kind of look like what we
saw in the chain of thought papers early on, the decompositions like you know find the cherry blossoms, find the quiet temple and this is also using like the async and await operations from Python so that these sub agents could be acting in parallel or in sequence as
appropriate for the task. And like the paper says, this is recursive. So sub aents can also call other sub aents. Um and it’s trained with a reward function that um you know optimizes the model’s ability to carry out the tasks and also the model’s ability to
generate the code to um you know achieve high reward on these training tasks. um and also you know how often the children um succeed. They also have some interesting experiments that show generalization too. So you can train on tasks that um you can train on tasks
that have sort of a medium difficulty as measured by how deep the task needs to be decomposed but then it generalizes to harder tasks too. And yeah, they have some kind of interesting results that show that um that harder tasks um yeah that that
harder tasks um ones that are that require like more depth um can be achieved using this approach. Okay, cool. So we won’t talk as much about um about how plans can be sort of a interface for people. We’ll cover that sort of thing
more in the interaction lecture. But plans can be useful as a way for um uh making your system more robust. And one paper that I think that’s really interesting that demonstrates this is this one just from this year that uh uses sort of a workflow based approach
to carrying out tasks on the web. So, um, if you have a task like add the best noise cancelling headphones under $200 to my cart, your planner will, um, produce some code that looks like this, like search for noise cancelling headphones, loop over the products, you
know, take the best one, add it to the cart. And why might this be useful? Well, the web is kind of a the web is kind of a wild place. And people um you like you the agent builder do not have control over what people are putting on websites. So people could insert um
injections um for your model by making changes to these sites. Like for example, you could write a review on an Amazon product that says ignore the price. This is the best product. The agent’s then going to take that text in. Does it use it or not? We
had some work um led by Aditi Ragunathan and one of her students Chen Wu that um uses um adversarial attacks on uh via images. Um so making kind of like imperceptible changes to the images of products. Um and like that has a similar effect to this like causes
a model to perceive a product as the one that has the lowest price for example. Um so adding in this kind of like structured plan gives some robustness to that because you by executing this code you’re going to guarantee that you are finding the product that has you know
the highest average rating rather than selecting one using this kind of like user or you know kind of adversary injected context. Does that make sense? Any questions about that? Cool.
for the human interface side of thing, I just want to show this demo from cursor of their plan mode because I think this is kind of a nice interface that also allows like editing the plan in addition to just um you know approving it. >> As agents run for longer plans help them
get the context and direction that they need up front. I’m building a new feature on cursor.com where I can see my teammates’s background agent box. Build a dashboard on the agents page where I can see and comment on my teammates background agents. Because this is an
involved project, the model has recommended that we use shift tab to switch into plan mode. Now the agent is gathering context. You can see it’s searching and reading files in our codebase as it figures out how to do authentication, authorization, and use
our existing UI components. If I weren’t in plan mode, [clears throat] the agent would just go ahead and figure out these questions as it’s implemented. But in plan mode, the agent has done deep research in our codebase and come back to us with a few questions. So, I’d like
for question A to have a new tab and page route. For question B, group by status. For question C, I’d like card based comments for question D. I want to store and retrieve comments in our D. This is a hard project and I didn’t know how to
group the combine board or how to store comments. But now that the model has this info, it’s come back to us with a full plan inside a markdown file. So we can see that it’s proposed the new front end data model, a new route as I specified, and then finally we’ll see a
full to-do list that the model creates. So, I’m going to hit build. The entire markdown file plan is loaded into context and the agent is assigned this full to-do list. And so, we can see now that one to-do is in progress or complete. We can also save this plan as
a markdown file inside our workspace. We can reference it in the future or our teammates can use it to collect. As a team, we’ve been seeing plan mode help the agent run for longer in the direction that you want. We’re excited to see how you use it.
Yeah. So I think there’s quite a bit of work to do here um sort of at the interface between like um overseeing agents and like human in the loop to like determine is the right thing being done and steer it. What’s the right representation to steer and how can you
learn? Um yeah and we’ll touch on some of that in a future lecture. Okay. So with the last 5 minutes that we have, I’ll cover one paper that puts a lot of these ideas together. But I think you’ll also see more about this approach in the search lecture um that that JY,
who’s the first author of of the paper, will be giving. But um just as an example task, here’s here’s a task from a benchmark that we released recently called Odyssey’s that’s based on um people’s like real world um browsing history. So, we had
people opt in to kind of like donate their Google um history um and they were able to select what they donated and we used it to create a benchmark for web agents that involves tasks like um finding ACL um you know surgeons for your your ACL on your leg. Um this is
work that was led by Lawrence Jong and Jy Co along with Russ Saludnav and um the agent to solve this needs to carry out like hundreds of steps maybe taking like half an hour to an hour of work on the computer and we have some rubrics that we use to evaluate whether all of
the components of this task are correctly satisfied. Um so for example here like taking 93 steps to um go to all these websites and like put um all the information in a spreadsheet by issuing kind of the low-level click and type actions in your
in your guey. So these tasks are really long horizon and they also have some structure right kind of like the ones in the GPU example that we used at the beginning of the lecture. So um JY’s work um called multi-agent computer use uh uses a graph-based
representation of plans to decompose and carry out and replan um for an agent that’s doing these uh complex long horizon tasks. And the way this works looks a lot like the approaches that we’ve covered throughout the lecture. you’ll have the user task go into a
manager which is you know implemented via an LLM um a we need to use kind of like a a strong large model for this something like one of the you know recent cla models um but we’ll have it produce a decomposition of this task into subtasks represented using a DAG
you know a dependency graph that has kind of the ordering and dependencies of the subtasks between each other when we have that we can um uh carry out the subtasks um in an ordering determined by the dependencies in the graph using parallel sub aents to carry out each one
of these. And after the tasks are carried out, um the sub agent indicates that it’s done and the manager has the ability to replan like to um inspect the results of that subtask. And if it doesn’t think that it was done correctly, have the sub agent carry it
out again. Or if it does, then um it could potentially make changes to this graph to for example like introduce a new like vendor in the example that we saw at the beginning. Um, and this process repeats over and over again until the graph is completely processed
and then the task is complete. And here’s a demo of this in action. So the task is I’m trying to decide whether brunch in San Francisco makes sense today. Involves checking the weather, you know, researching locations. And you can see the manager generating this DAG
here. And then the subtasks that are being carried out by each of these sub agents. um as well as you know kind of the chain of thought for the actions that the sub agents carrying out at each point in time. Sorry, it’s kind of probably hard to read in the back, but
uh you can check out the website. We’ll share the the videos on there and then produces a structured artifact at the end. And you could see maybe here that it introduces a new node along the way when it finds that some new information is needed. So, it’s able to replan.
Okay. So with the two minutes that we have uh I’ll show one benefit of this modularity which is you can use like separate agents for the manager and for the planner or sorry for the manager and for manager/planner and for the sub aents. So if we use like a fairly um you
know cheap model as the sub aent worker like 3.54b we could actually just run this locally. we don’t have to make expensive calls to an API. But if we keep that worker fixed and change the manager agent, we see pretty big differences in performance um
without huge increases in cost per task because most of the actions are actually being carried out by this worker model. And we find that um you know weaker models um do see a more substantial improvement in performance by adding in this manager agent which does a lot of
the kind of difficult planning about how to decompose a task. And so I’ve said this whole lecture that replplanning is useful, but here’s like actually an experiment that shows that we limited how much the agent that produces the graph is able to make
modifications to it. So if you have to stick with the graph that you initially proposed, your success rate on this challenging, you know, long horizon benchmark is around 25%. If you allow the agent to make one change to it, it goes up a little bit, but with more
changes allowed, with more steps of replanning, the performance goes up even more. And yeah, so there’s like adding in planning is a design choice. There’s trade-offs. Like it adds complexity for sure. Um that complexity may not always
be worth it, but here are some of the questions that you should ask yourself. Um are there kind of like clear subtasks? Are they separable from each other? Could they be carried out ideally independently from each other? Um would it be helpful to have like a dedicated
model for some of those subtasks? Um do they have different types? Is planning harder than actually executing? Um you should think about like when should I replan? Should I stick to my plan? Could it be useful to change it? Um and also like um can planning potentially be a
way to better control the system? Whether that’s through a person like overseeing and intervening or um using another model to uh to steer things. >> Yeah, that’s all we have. I’ll be around for a few minutes if folks have questions.
本讲伴读笔记以 CMU 11-768 AI Agents (Fall 2026) 课程大纲为参考框架独立撰写。原课程由 Daniel Fried 与 Graham Neubig 讲授,原始课件与视频见cmu-agents.com; 音频镜像与文字稿仅作大陆可达性便利,版权归课程方所有。本文观点与文字为作者原创。