推理与规划 · ReAct、分解与自我纠错Reasoning · ReAct, Decomposition, and Self-Correction.
好的 Agent 不只是执行指令 —— 它会拆解任务、制定计划、发现错误后回头修正。A good agent doesn't just follow instructions — it decomposes tasks, makes plans, and backtracks when it spots mistakes.
10 分钟 · 初稿 2026.0510 Min · Drafted 2026.05
研究助手现在能搜、能抓、有记忆,但它还是反应式的:搜一个读一个,撞了墙也不回头。好的 agent 先想再做 —— 先规划要查哪几个角度,发现来源矛盾时回头修正。这一章把「会调工具」变成「会研究」。The research assistant can now search, fetch, and remember, but it's still reactive: search one, read one, no turning back at a wall. A good agent thinks before acting — it plans which angles to search and backtracks when sources conflict. This chapter turns 'calls tools' into 'actually researches.'
— I
让它先想再做Let It Think Before It Acts.
反应式的 agent 看一步走一步;好的 agent 先推理再行动。把「想」显式化,是质量的第一个杠杆。A reactive agent goes one step at a time; a good agent reasons before it acts. Making the thinking explicit is the first lever on quality.ReAct 把这件事写成范式:每一步先输出一段推理(为什么调这个工具),再行动。1注 1Note 1Yao et al. · 「ReAct: Synergizing Reasoning and Acting in Language Models」(2022,arXiv:2210.03629)—— 把推理与行动交替:每步先推理再行动,把环境反馈带回下一步。Yao et al. · 'ReAct: Synergizing Reasoning and Acting in Language Models' (2022, arXiv:2210.03629) — interleave reasoning and acting: reason before each act, carry environment feedback into the next step.现在模型把这步内建成 extended thinking —— 开 thinking: {type: "enabled", budget_tokens: N},模型会在 thinking 块里推理,再给出 tool_use 或答案(Opus 4.8 / 4.7 改用 {type: "adaptive"})。2注 2Note 2Anthropic 文档 · Extended thinking —— thinking: {type: enabled, budget_tokens: N} 让模型在 thinking 块里先推理再行动;Opus 4.8 / 4.7 改用 {type: adaptive};带工具时 thinking 块必须原样回传。截至 2026-05。Anthropic docs · Extended thinking — thinking: {type: enabled, budget_tokens: N} lets the model reason in thinking blocks before acting; Opus 4.8 / 4.7 use {type: adaptive}; thinking blocks must be passed back unchanged with tool results. As of 2026-05.ReAct turns this into a paradigm: each step emits a stretch of reasoning (why this tool) before acting.1注 1Note 1Yao et al. · 「ReAct: Synergizing Reasoning and Acting in Language Models」(2022,arXiv:2210.03629)—— 把推理与行动交替:每步先推理再行动,把环境反馈带回下一步。Yao et al. · 'ReAct: Synergizing Reasoning and Acting in Language Models' (2022, arXiv:2210.03629) — interleave reasoning and acting: reason before each act, carry environment feedback into the next step. Models now build this in as extended thinking — turn on thinking: {type: "enabled", budget_tokens: N} and the model reasons in a thinking block before its tool_use or answer (Opus 4.8 / 4.7 use {type: "adaptive"}).2注 2Note 2Anthropic 文档 · Extended thinking —— thinking: {type: enabled, budget_tokens: N} 让模型在 thinking 块里先推理再行动;Opus 4.8 / 4.7 改用 {type: adaptive};带工具时 thinking 块必须原样回传。截至 2026-05。Anthropic docs · Extended thinking — thinking: {type: enabled, budget_tokens: N} lets the model reason in thinking blocks before acting; Opus 4.8 / 4.7 use {type: adaptive}; thinking blocks must be passed back unchanged with tool results. As of 2026-05.
带推理的工具调用(thinking 块要原样回传)Tool use with reasoning (pass thinking blocks back unchanged)
但想得多不等于想得对,也不是免费的 —— thinking token 要计费,延迟也涨。2注 2Note 2Anthropic 文档 · Extended thinking —— thinking: {type: enabled, budget_tokens: N} 让模型在 thinking 块里先推理再行动;Opus 4.8 / 4.7 改用 {type: adaptive};带工具时 thinking 块必须原样回传。截至 2026-05。Anthropic docs · Extended thinking — thinking: {type: enabled, budget_tokens: N} lets the model reason in thinking blocks before acting; Opus 4.8 / 4.7 use {type: adaptive}; thinking blocks must be passed back unchanged with tool results. As of 2026-05.简单任务别开;把它留给多步、要规划、要权衡的活。But thinking more isn't thinking better, and it isn't free — thinking tokens are billed and latency rises.2注 2Note 2Anthropic 文档 · Extended thinking —— thinking: {type: enabled, budget_tokens: N} 让模型在 thinking 块里先推理再行动;Opus 4.8 / 4.7 改用 {type: adaptive};带工具时 thinking 块必须原样回传。截至 2026-05。Anthropic docs · Extended thinking — thinking: {type: enabled, budget_tokens: N} lets the model reason in thinking blocks before acting; Opus 4.8 / 4.7 use {type: adaptive}; thinking blocks must be passed back unchanged with tool results. As of 2026-05. Don't enable it for simple tasks; save it for the multi-step, plan-heavy, trade-off work.
— II
把大任务拆成小步Break the Big Task into Small Steps.
一个 agent 解决不了的难题,常常不是它不够聪明,是你让它一口吞下了整个任务。A problem an agent can't solve often isn't a matter of intelligence — it's that you made it swallow the whole task in one bite.分解的做法:让模型先产出一个计划(子任务列表),再逐个执行 —— plan-then-execute 在长任务上比一步到位更稳,因为计划可检查、可中断、可恢复。Anthropic 的 orchestrator-workers 模式就是分解的工程化:一个协调者把任务拆开,分给各个 worker。3注 3Note 3Anthropic · 「Building Effective Agents」(2024-12-19)—— orchestrator-workers 等模式:把复杂任务分解、由一个协调者拆给子任务。Anthropic · 'Building Effective Agents' (2024-12-19) — patterns like orchestrator-workers: decompose a complex task and have a coordinator hand subtasks out.The move: have the model produce a plan (a list of subtasks) first, then execute each — plan-then-execute is steadier than one-shot on long tasks, because a plan can be inspected, interrupted, and resumed. Anthropic's orchestrator-workers pattern is decomposition engineered: a coordinator splits the task and hands pieces to workers.3注 3Note 3Anthropic · 「Building Effective Agents」(2024-12-19)—— orchestrator-workers 等模式:把复杂任务分解、由一个协调者拆给子任务。Anthropic · 'Building Effective Agents' (2024-12-19) — patterns like orchestrator-workers: decompose a complex task and have a coordinator hand subtasks out.别过度分解。把一个两步的活拆成七个子任务、每个子任务一次模型调用,是在用规划的名义烧钱加延迟。分解的价值,只在「步骤多到记不住、或需要中途检查」时才兑现。Don't over-decompose. Splitting a two-step job into seven subtasks, each its own model call, burns money and latency in the name of planning. Decomposition pays off only when 'there are too many steps to track, or you need a mid-way checkpoint.'
— III
发现错了能回头Notice the Mistake and Turn Back.
区分玩具和能用的 agent 的,往往不是它第一次做对的概率,是它做错后能不能自己发现并修正。What separates a toy from a usable agent is often not its odds of getting it right the first time, but whether it can notice and fix a mistake on its own.自我纠错有两个来源。一是环境反馈 —— 第三章那个带 is_error 的工具结果就是最好的纠错信号,喂回去,模型能改参数重试。二是自我反思 ——Reflexion 的做法是让模型在失败后写一段反思,带进下一轮上下文,下次就少踩同一个坑。4注 4Note 4Shinn et al. · 「Reflexion: Language Agents with Verbal Reinforcement Learning」(2023,arXiv:2303.11366)—— 让 agent 把失败的反思写进下一轮上下文,从反馈中自我纠错。Shinn et al. · 'Reflexion: Language Agents with Verbal Reinforcement Learning' (2023, arXiv:2303.11366) — have the agent write reflections on failure into the next round's context, self-correcting from feedback.Self-correction has two sources. One is environment feedback — the is_error tool result from chapter 3 is the best correction signal; feed it back and the model fixes its arguments and retries. The other is self-reflection — Reflexion has the model write a reflection after a failure and carry it into the next round's context, so it stumbles on the same spot less.4注 4Note 4Shinn et al. · 「Reflexion: Language Agents with Verbal Reinforcement Learning」(2023,arXiv:2303.11366)—— 让 agent 把失败的反思写进下一轮上下文,从反馈中自我纠错。Shinn et al. · 'Reflexion: Language Agents with Verbal Reinforcement Learning' (2023, arXiv:2303.11366) — have the agent write reflections on failure into the next round's context, self-correcting from feedback.但自我纠错要有上限 —— 给纠错轮数设顶(呼应第二章的 max_steps)。一个会反思却停不下来的 agent,会在「我再试一次」里无限循环。反思要有,但要带刹车。But self-correction needs a ceiling — cap the correction rounds (echoing chapter 2's max_steps). An agent that reflects but can't stop will loop forever in 'let me try once more.' Reflection, yes — but with a brake.动手 · 给一个要两步以上的任务装上推理:Hands-on · add reasoning to a task that needs two or more steps:
01
开推理,比计划质量Turn on reasoning, compare plan quality
对同一个任务,开和不开 thinking 各跑一次,看它的下一步选择有没有变靠谱。Run the same task once with thinking and once without; see whether its next-step choices get more sensible.
02
加一步「先列计划」Add a 'plan first' step
让模型在动手前先输出子任务列表,再逐个执行,感受 plan-then-execute 在长任务上稳在哪。Have the model output a subtask list before acting, then execute each, and feel where plan-then-execute is steadier on long tasks.
03
故意让一个工具失败Make one tool fail on purpose
把工具错误喂回去、加一轮反思,看它能不能从这次失败里恢复 —— 别忘了给纠错轮数设上限。Feed the tool error back, add one reflection turn, and see if it recovers from the failure — and cap the correction rounds.
会做对的 agent 很多,
会发现自己做错的才少。.
Many agents get it right;
few notice when they got it wrong..
Aklman Library
— 讨论Discussion
讨论Discussion.
评论区初始化中…Initializing comments…
01 / 01
没有匹配结果No matches.
换个关键词,或按 Esc 回到页面Try another keyword, or press Esc to return