ReAct: Synergizing Reasoning and Acting in Language Models
为什么这篇论文重要
2022 年之前,让 LLM 调用工具是”先思考好答案再行动”的简单模式。 ReAct 论文提出:让 LLM 交替地思考(Reasoning)和行动(Acting)——
模型先 Thought,再 Action,再观察 Observation,再 Thought……
这个循环是后来所有 AI Agent 的基本骨架。LangChain 的 ReAct agent、AutoGen 的工作流、Devin 的执行循环、Cursor / Claude Code 的工具调用——全是这个范式。
一个例子
ReAct 论文里的经典例子(HotpotQA 任务):
Question: Aside from the Apple Remote, what other devices can control the program Apple Remote was originally designed to interact with?
Thought 1: I need to search Apple Remote and find the program it was designed to interact with.
Action 1: Search[Apple Remote]
Observation 1: The Apple Remote is a remote control... designed to control the Front Row media center program...
Thought 2: Apple Remote was designed to interact with Front Row. I need to search Front Row next.
Action 2: Search[Front Row]
Observation 2: Front Row is a discontinued media center software... can be controlled by Apple Remote, keyboard function keys.
Thought 3: So besides Apple Remote, Front Row can be controlled by keyboard function keys.
Action 3: Finish[keyboard function keys]
LLM 在每一步都显式写出思考,然后执行动作,再观察结果—— 这种交错让模型能:
- 修正自己的错误推理
- 动态调整搜索策略
- 利用工具补充未知信息
ReAct vs 之前的方法
| 方法 | 思考 | 行动 |
|---|---|---|
| Chain of Thought (CoT) | ✓ 多步推理 | ✗ 只能用模型内部知识 |
| Act only | ✗ 不显式思考 | ✓ 调用工具 |
| ReAct | ✓ | ✓ |
CoT 没法用工具——遇到模型不知道的知识就编(幻觉)。 纯 Action 没有思考——容易陷入低效搜索。 ReAct = 两者结合。
实验结果
论文测试了 4 个任务:
| 任务 | ReAct 改进幅度 |
|---|---|
| HotpotQA(多跳问答) | +6 个百分点 vs CoT |
| FEVER(事实验证) | +3 个百分点 |
| ALFWorld(文字游戏) | +35 个百分点 |
| WebShop(在线购物模拟) | +20 个百分点 |
特别在需要外部知识 + 多步规划的任务上,ReAct 大幅领先。
关键洞察
ReAct 之所以 work,源于几个细节:
1. 思考是”自由文本”,不是结构化
模型可以用自然语言自由表达它的推理—— 不像有的工作要求模型输出”plan: [step1, step2, …]”这种结构化。
这降低了 LLM 的认知负担,让它能在思考里回溯、修改、重新规划。
2. 思考和行动交错
不是”先写完整 plan 再执行”,是”想一步、做一步、看一步、再想一步”。
这让模型能用新观察到的信息调整策略——而不是按死板的初始 plan 执行。
3. Few-shot 示例就够
不需要 fine-tuning。Few-shot prompt + 强 base model(GPT-3 级别)就能 work—— 这意味着任何能 prompt 的 LLM 都能成为 ReAct agent。
这篇论文的真正影响
ReAct 在学术上的引用量不是最高的—— 但它定义的范式被复制到所有 AI Agent 工具:
| 产品 / 框架 | 用 ReAct 范式 |
|---|---|
| LangChain | ”ReAct Agent” 是默认 agent 类型 |
| AutoGen(Microsoft) | 多 agent 协作底层 |
| CrewAI | 同上 |
| Devin / Factory / Cognition | 编程 agent 循环 |
| Cursor / Claude Code | 编程过程的 思考 → 调用工具 → 观察 |
| OpenAI Operator | 浏览器操作 agent |
如果你在 2026 年用 AI agent 干过任何活—— 你已经在用 ReAct 的设计。
一个最小 ReAct 实现
def react_loop(question, tools, max_steps=10):
history = [f"Question: {question}"]
for step in range(max_steps):
# LLM 决定下一步是 Thought / Action / Finish
response = llm("\n".join(history) + "\nThought:")
if response.startswith("Finish:"):
return response[len("Finish:"):].strip()
# 解析 Action
action = parse_action(response)
if action:
tool_name, args = action
obs = tools[tool_name](*args)
history.append(f"Thought: {response}")
history.append(f"Action: {tool_name}[{args}]")
history.append(f"Observation: {obs}")
else:
# 纯思考
history.append(f"Thought: {response}")
return "Max steps exceeded"
50 行不到,但已经是一个工作的 Agent。
ReAct 的局限
后续工作发现 ReAct 有些问题:
1. 重复 / 循环
模型有时会反复执行同一动作——需要外加 loop detection。
2. 上下文爆炸
每步都把 Thought + Action + Observation 加到历史里—— 10 步后 context 几千 token。
后续工作(如 LangGraph)支持更细的状态管理。
3. 错误恢复
模型遇到 tool error 时容易”卡住”—— Reflexion(2023)等工作加了显式的”自我反思”步骤来解决。
4. 多智能体
ReAct 是单 agent。多 agent 协作需要更复杂的协调—— AutoGen 等工作做了扩展。
演化:从 ReAct 到现代 Agent
2022 ReAct
↓
2023 Reflexion (自我反思)
↓
2023 Tree of Thoughts (探索多条路径)
↓
2023 LATS (Language Agent Tree Search)
↓
2024 多 agent 协作(AutoGen / CrewAI)
↓
2024-2026 复杂 agent 框架(LangGraph / Computer Use)
每一代都建立在前一代之上——但ReAct 的”思考-行动循环”是不变的基底。
推荐配套阅读
- HelloAI: L4-04 Agent 构建 + L4-09 Tool Use 实战
- ReAct 原论文(arXiv:2210.03629)
- Reflexion 论文(2023)—— 自我反思扩展
- Tree of Thoughts 论文(2023)—— 多路径搜索
ReAct 是 2020s 最被低估的论文之一。
它没有 GPT-3 那么显眼,没有 Attention 那么有名。 但它定义了 AI 怎么”用工具”—— 而 “用工具” 是过去 2 年所有 AI 产品价值的核心。
如果只读 5 篇 Agent 相关论文,ReAct 是第一篇必读。
想要更多论文精读
订阅每周精选 —— 下一篇论文笔记直接送邮箱。
讨论区
· 用 GitHub 账号登录评论src/components/Comments.astro 顶部填入
仓库 ID 和分类 ID(见组件注释里的配置步骤)。