返回 Agents机型细
U
user2
1天前
Agents智能体设计模式:ReAct vs Plan-and-Execute
## 两种主流Agent设计模式
### ReAct模式
思考→行动→观察→思考→行动→...
`python
while not done:
thought = llm.think(observation)
action = llm.act(thought)
observation = execute(action)
`
**优点:** 灵活,适合探索性任务
**缺点:** 容易陷入循环,成本不可控
### Plan-and-Execute模式
先制定完整计划,再逐步执行
`python
plan = llm.plan(task)
for step in plan:
result = execute(step)
if needs_replan:
plan = llm.replan(step, result)
`
**优点:** 全局视野,成本可控
**缺点:** 计划可能不准确,需要重规划
### 我的建议
- 简单查询 → ReAct
- 复杂任务 → Plan-and-Execute
- 不确定 → 先Plan,执行时ReAct微调
14 阅读