跳到主要内容

ReAct (Reasoning + Acting)

定义

ReAct 是一种范式,其中模型交替进行推理(接下来做什么、为什么)和行动(工具调用). 来自环境的观察 feeds back into the next 推理 step, forming a loop until the task is done.

它是 the standard pattern for agents that use tools: each action is preceded by a thought, which reduces blind or repetitive tool use. Often combined with chain-of-thought (推理 inside the thought) and with RDD when specs guide 决策s.

工作原理

提示格式为思考 → 行动 → 观察 → 思考 → … → 最终答案用户给出一个任务代gent produces a thought (推理 about what to do), then an action (例如 tool call). The environment/tools return an observation, which is appended to the context for the next thought. The loop continues until the agent outputs a final answer. The model decides when to call tools and when to conclude, which reduces arbitrary or repetitive actions. The sequence diagram below summarizes this flow; frameworks like LangChain implement ReAct-style agents with tool registration and message handling.

应用场景

ReAct fits agent workflows where each tool call should be preceded by a clear 推理 step.

  • Agents that use tools (search, calculator, API) with explicit 推理
  • Reducing arbitrary or repetitive 工具调用 by interleaving thought
  • Debuggable agent behavior via visible thought–action–observation traces

外部文档

另请参阅