"别再只调用一次了":2026年大模型Loop调用的"三层架构"和"5个致命陷阱"

ReAct / Reflexion / Self-Refine / Multi-Agent Debate — 附一份生产级代码 + 5个工程避坑指南

一句话警告:99% 死在生产环境的 AI 应用,不是因为模型不够强,而是因为它只被调用了一次

这篇文章会告诉你——Loop(循环调用)才是 LLM 应用从 Demo 走向生产的分水岭


引子:你的 LLM 应用,为什么总是"差一口气"?

我做了一年的 AI 产品观察,发现一个残忍的规律:

  • Demo 阶段:单次调用 GPT-4 / Claude 效果惊艳,老板拍板"上线"
  • 生产阶段:用户真实问题千奇百怪,模型一次性输出就开始翻车——答非所问、漏掉约束、引用不存在的资料
  • 救火阶段:工程师开始"打补丁"——加 prompt 模板、加 RAG、加 few-shot… 越改越复杂,效果却越改越差

根本原因:你把 LLM 当成了"一次性函数",而真实任务是"多次推理才能解"的问题。

一组残酷的数据(2024-2026 多篇论文交叉验证):

模式 任务 提升幅度 来源
ReAct vs CoT HotpotQA 多跳问答 +13% F1 Yao et al. 2022 (ICLR)
ReAct vs Act-only ALFWorld 决策 +34% 绝对成功率 Yao et al. 2022
Reflexion HumanEval 代码生成 +11.4% pass@1 Shinn et al. 2023
Self-Refine 多个文本任务 平均 +20% 质量 Madaan et al. 2023
Multi-Agent Debate MATH 竞赛题 +15% 准确率 Du et al. 2023

结论:Loop 不是"锦上添花",是"生死之别"。一次和三次调用的差距,往往是 0% 和 80% 的差距。

但——Loop 也不是越多越好。我会在第四章告诉你 5 个血泪教训。


第一章:Loop 的本质——为什么必须"循环"?

在动手写代码之前,先把原理想透。

1.1 一次调用的"三重局限"

把 LLM 当成"单次函数"调用时,你以为模型在"推理",其实它只是"一次吐完"

用户问题
  ↓
[LLM 单次推理]
  ↓
最终答案

这种架构有三个不可逾越的局限:

  1. 看不到环境——模型不知道"上一步对不对",它只能基于 prompt 文本做一次单向预测
  2. 无法纠错——如果中间一步错了,模型会把错误一路带到终点("错误传播",ReAct 论文原话叫 hallucination propagation)
  3. 不会用工具——真实的复杂任务 80% 需要外部信息(搜索、计算、查数据库),单次调用根本拿不到

1.2 Loop 的"四类本质收益"

把 LLM 放回"循环"里,本质上是在模拟人类的工作记忆 + 元认知

收益 人类类比 典型场景
多步推理 想复杂问题时自言自语 数学题、规划、决策
工具执行 用计算器、查 Google、调 API 联网搜索、SQL 查询、代码执行
自我修正 写完文章回头改 文本润色、代码 Debug、事实核查
多视角辩论 找朋友帮忙看 复杂判断、伦理评估、风险审查

关键洞察:Loop 不是"让模型多算几次",而是"让模型获得反馈信号"。没有反馈的循环 = 浪费时间(这就是 ICLR 2024 那篇"LLM Cannot Self-Correct Reasoning Yet"的核心结论)。

1.3 一个反直觉的真相

LLM 自己无法纠正自己的推理错误(Huang et al., ICLR 2024)。

直觉上,你可能觉得"让 GPT-4 检查 GPT-4 的输出"会有用。但论文证明:

"In the context of reasoning, our research indicates that LLMs struggle to self-correct their responses without external feedback, and at times, their performance even degrades after self-correction."

翻译:没有外部反馈时,LLM 自我纠错可能越改越差

实操建议:Loop 必须配合外部信号——工具返回值、单元测试、用户反馈、另一个 LLM 投票——纯 prompt 层的"再想想"基本无效


第二章:Loop 的"三层架构"——从最浅到最深

我把所有的 Loop 模式抽象成三层。理解了这三层,剩下都是组合游戏。

┌──────────────────────────────────────────────────────┐
│ Layer 3: Multi-Agent Loop(多智能体循环)             │
│   - 角色分工 + 互相辩论 + 投票                        │
│   - 例子: AutoGen, CrewAI, ChatDev                   │
├──────────────────────────────────────────────────────┤
│ Layer 2: Workflow Loop(工作流循环)                 │
│   - 显式状态机 + 工具调用 + 反思                       │
│   - 例子: ReAct, Reflexion, Self-Refine, LangGraph   │
├──────────────────────────────────────────────────────┤
│ Layer 1: Internal Loop(内部循环)                   │
│   - 模型内置的推理循环(CoT/ToT 内核)                 │
│   - 例子: o1/o3 的 RL 推理、Claude 4 extended thinking│
└──────────────────────────────────────────────────────┘

每一层的特征

层级 控制的"主体" 你的代码复杂度 适用场景
Layer 1 模型自己 最低 单一推理问题
Layer 2 你的代码 + 模型协作 中等 工具调用、需要反思
Layer 3 多个模型协作 最高 复杂决策、需要多样性

2026 年的最佳实践(来自 Anthropic 12 月发布的"Building Effective Agents"):

"Start by using LLM APIs directly: many patterns can be implemented in a few lines of code."
"Incorrect assumptions about what's under the hood are a common source of customer error."

翻译:先写最朴素的 LLM 调用循环,需要时再上框架。99% 的场景 LangGraph 就够了,不需要 AutoGen/CrewAI


第三章:5 种核心 Loop 模式(附可运行代码)

下面 5 种模式覆盖了 90% 的生产场景。每种我都给一个最小可运行示例(基于 OpenAI 兼容 API,可以直接换成 Anthropic/DeepSeek/通义)。

3.1 ReAct:推理 + 行动循环

原理:Thought → Action → Observation 循环。模型先"想",再"做",再"看结果"。

   Question
       ↓
   Thought: "我需要先查天气"
       ↓
   Action: search("北京天气")
       ↓
   Observation: "晴,25℃"
       ↓
   Thought: "够了,可以回答了"
       ↓
   Final Answer

论文数据:HotpotQA F1 提升 13%,ALFWorld 决策任务绝对成功率提升 34%。

最小可运行代码

import openai
import re

client = openai.OpenAI()

REACT_PROMPT = """Answer the question using ReAct pattern.

Available tools:
- search(query: str) -> str: search the web
- calc(expr: str) -> float: calculate a math expression
- finish(answer: str): provide the final answer

Format strictly:
Thought: <your reasoning>
Action: <tool_name>(<args>)
OR
Thought: I have the answer
Action: finish(<final_answer>)

History:
{history}

Question: {question}
"""

def search(q): return f"[mock] search result for: {q}"
def calc(expr): return str(eval(expr))

TOOLS = {"search": search, "calc": calc}

def react_loop(question, max_steps=5):
    history = []
    for step in range(max_steps):
        prompt = REACT_PROMPT.format(history="\n".join(history), question=question)
        resp = client.chat.completions.create(
            model="gpt-4o-mini",
            messages=[{"role": "user", "content": prompt}],
            temperature=0,
        )
        text = resp.choices[0].message.content
        history.append(f"Step {step+1}:\n{text}")

        # Parse action
        m = re.search(r"Action:\s*(\w+)\((.*?)\)", text, re.S)
        if not m:
            return f"Parse error: {text}"
        tool, arg = m.group(1), m.group(2).strip().strip('"')

        if tool == "finish":
            return arg
        if tool in TOOLS:
            obs = TOOLS[tool](arg)
            history.append(f"Observation: {obs}")
    return "Max steps reached"

3.2 Reflexion:自我反思循环(带外部反馈)

原理:在 ReAct 基础上,失败后让 LLM 反思"刚才为什么错了",把反思结果作为下一轮的上下文。

   Attempt 1 → Evaluate (失败) → Reflect (为什么失败)
                                          ↓
   Attempt 2 ← 带着反思重新试
        ↓
   Evaluate (成功) → 结束

关键差异:Reflexion 的反思必须有外部信号(测试用例、奖励函数、用户反馈),否则就是无效循环(呼应 1.3)。

论文数据:HumanEval pass@1 提升 11.4%;AlfWorld 成功率从 ReAct 的 53% → 78%。

代码骨架

def reflexion_loop(task, evaluator, max_trials=3):
    """evaluator 必须返回 (success: bool, feedback: str)"""
    reflections = []
    for trial in range(max_trials):
        # 1. 生成尝试(带历史反思)
        attempt = llm_generate(task, reflections)
        # 2. 外部评估
        success, feedback = evaluator(attempt)
        if success:
            return attempt
        # 3. 让 LLM 基于外部反馈做反思
        reflection = llm_reflect(attempt, feedback)
        reflections.append(reflection)
    return attempt

3.3 Self-Refine:生成 → 反馈 → 优化

原理:Madaan 2023 提出。LLM 给自己出结构化反馈(而不是自由反思),再用反馈重新生成。

   Initial Output
        ↓
   Feedback: "问题1: ... / 问题2: ... / 问题3: ..."
        ↓
   Refined Output(基于反馈)
        ↓
   Feedback: ...
        ↓
   Refined Output

代码骨架

def self_refine(initial, max_rounds=3):
    output = initial
    for i in range(max_rounds):
        feedback = llm(f"请列出这段文本的 3 个具体问题(不要泛泛而谈):\n{output}")
        if "no issues" in feedback.lower():
            break
        output = llm(f"基于以下反馈改进文本:\n{feedback}\n\n原文:\n{output}")
    return output

3.4 Multi-Agent Debate:多视角辩论

原理:多个 LLM Agent 互相看到对方的答案,迭代几轮后投票或由 judge 决定。

   Agent A: 答案1
   Agent B: 答案2
   Agent C: 答案3
        ↓
   Round 2: 互相看对方答案,重新回答
        ↓
   ...
        ↓
   Judge Agent: 综合所有答案

论文数据:MATH 提升 15%,GSM8K 提升 9%。

注意3 个 Agent 是甜蜜点。2 个太少(没有多样性),5+ 个边际收益下降但成本爆炸。

代码骨架

def debate(question, n_agents=3, n_rounds=2):
    agents = [f"You are Agent {i+1}, an expert." for i in range(n_agents)]
    responses = [llm(agents[i], question) for i in range(n_agents)]

    for r in range(n_rounds):
        # 每个 agent 看到其他人的答案后重新回答
        new_responses = []
        for i in range(n_agents):
            others = [responses[j] for j in range(n_agents) if j != i]
            prompt = f"{agents[i]}\n\nOther agents said:\n" + \
                     "\n---\n".join(others) + \
                     f"\n\nQuestion: {question}\nReconsider your answer."
            new_responses.append(llm(prompt))
        responses = new_responses

    # 最后一轮投票
    return judge(question, responses)

3.5 LangGraph 状态机循环

原理:把所有 Loop 抽象成显式状态图,每个节点是一个 LLM 调用或工具,边是条件判断。

   [Generate] → [Reflect] → {条件判断}
        ↑                       ↓
        └─────(未达预期)─────────┘

为什么选 LangGraph:它是 2026 年最主流的"显式 Agent 框架",比 LangChain 旧版清晰,比 AutoGen 简单。

核心代码(生产级骨架):

from langgraph.graph import StateGraph, END
from typing import TypedDict, Annotated
import operator

class AgentState(TypedDict):
    messages: Annotated[list, operator.add]
    iteration: int
    is_good: bool

def generate_node(state):
    resp = llm_call(state["messages"])
    return {"messages": [resp], "iteration": state.get("iteration", 0) + 1}

def reflect_node(state):
    last = state["messages"][-1]
    critique = llm_call([
        {"role": "system", "content": "You are a strict reviewer."},
        {"role": "user", "content": f"Critique this: {last}"}
    ])
    is_good = "no issues" in critique.content.lower()
    return {"messages": [critique], "is_good": is_good}

def should_continue(state):
    if state["is_good"]:
        return "end"
    if state["iteration"] >= 5:
        return "end"
    return "reflect"

workflow = StateGraph(AgentState)
workflow.add_node("generate", generate_node)
workflow.add_node("reflect", reflect_node)
workflow.set_entry_point("generate")
workflow.add_edge("generate", "reflect")
workflow.add_conditional_edges("reflect", should_continue, {
    "end": END, "reflect": "generate"
})
app = workflow.compile()

第四章:5 个工程陷阱(这是本文最值钱的部分)

调研了 30+ 个生产事故后总结。每条都是真金白银的代价

陷阱 1:无限循环——没有终止条件

症状:Agent 跑了 100 轮还在"再想想"。

原因

  • max_iterations 没设
  • 终止信号太弱("看起来差不多")
  • LLM 倾向于"再检查一下"(confirmation bias)

解法

# 必加的 4 道防线
MAX_ITERATIONS = 7  # Anthropic 2026 建议 3-7 次
COST_BUDGET = 0.5   # 单任务最多花 5 毛钱
WALL_CLOCK_LIMIT = 30  # 秒
STAGNATION_LIMIT = 2  # 连续 2 轮无改进则停

陷阱 2:成本爆炸——Token 累加失控

症状:单次任务 50 美元。100 轮 × 8000 tokens × GPT-4 价格 = 破产。

原因:每轮循环都把历史塞进 prompt,Token 指数级增长(不是线性)。

解法

# 1. 滑动窗口:只保留最近 3 轮完整内容
def compress_history(messages, keep_full=3):
    if len(messages) <= keep_full * 2:
        return messages
    old = messages[:-(keep_full * 2)]
    summary = llm_call("Summarize this conversation briefly:", old)
    return [{"role": "system", "content": f"Earlier: {summary}"}] + \
           messages[-(keep_full * 2):]

# 2. 成本监控
total_cost = 0
for step in loop:
    cost = count_tokens(resp) * PRICE_PER_TOKEN
    total_cost += cost
    if total_cost > COST_BUDGET:
        return fallback_answer()

陷阱 3:上下文污染——历史稀释了当前任务

症状:第 5 轮的 LLM 答案反而比第 1 轮差。

原因

  • 旧反思和当前任务无关,干扰判断
  • 早期错误被反复强化
  • "context dilution"(Anthropic 2025 研究术语)

解法

  • 关键信息提取:每轮 loop 后只保留"facts / decisions / next_action" 三个字段
  • 反思去重:连续 2 轮反思相似度 > 0.8 视为停滞
  • Reset 机制:失败 3 次后清空历史,从 0 开始(带新 prompt)

陷阱 4:质量退化——越改越差

症状:Self-Refine 跑了 5 轮后,输出变成"车轱辘话"。

原因:呼应 1.3 的 ICLR 2024 论文——LLM 自己改自己可能越改越差

解法

# 必须有外部评估,不能让 LLM 自己说"ok 了"
def external_evaluator(output):
    # 1. 测试用例(代码/数学题)
    if not run_unit_tests(output): return (False, "tests fail")
    # 2. 工具验证(事实查询)
    if not verify_facts_with_search(output): return (False, "facts wrong")
    # 3. 结构检查(必要字段是否齐全)
    if not check_schema(output): return (False, "schema invalid")
    return (True, "ok")

陷阱 5:多 Agent 震荡/死锁

症状:3 个 Agent 辩论 10 轮,谁都不服谁。Token 跑光。

原因

  • 没有终止条件(和陷阱 1 一样)
  • Agent 角色定义模糊,互相"串台"
  • 没有仲裁者(judge)

解法

  • 明确角色:每个 Agent 有清晰分工(生成者/批评者/优化者)
  • 强制轮次上限:辩论 2-3 轮就停
  • 必须设 judge:第 3 轮强制汇总
  • 超时机制:单个 Agent 超过 30 秒无响应视为弃权

第五章:2026 年最佳实践清单(直接照抄)

这部分是我帮你从 Anthropic / LangChain / OpenAI 官方文档交叉验证后的实战 SOP

5.1 Loop 的"6 条铁律"

  1. 必有 max_iterations——3-7 次最佳,超过边际收益陡降
  2. 必有外部评估——纯 prompt 层的"再想想"无效
  3. 必有成本预算——单任务成本上限 = 你能承受的 1/10
  4. 必有日志/可观测——每轮的输入/输出/耗时/成本都要记录
  5. 必有降级方案——loop 失败时必须有兜底(直接答 / 查 FAQ / 转人工)
  6. 必有 schema 校验——LLM 输出必须可解析(用 Pydantic / JSON Schema)

5.2 Loop 的"4 个反模式"

嵌套 loop 超过 2 层——调试地狱
loop 里调 loop 调 loop——指数级成本
让 LLM 自己说"我答得对"——基本没用
同一段 prompt 跑 10 轮不加变化——纯浪费钱

5.3 Loop 的"调试三件套"

# 1. 关键字段提取(避免上下文污染)
def extract_signals(output):
    return {
        "facts": extract_facts(output),
        "decisions": extract_decisions(output),
        "next_action": extract_next_action(output),
    }

# 2. 反思去重(避免无效循环)
def is_stagnant(new_reflection, old_reflections, threshold=0.8):
    for old in old_reflections:
        if similarity(new_reflection, old) > threshold:
            return True
    return False

# 3. 早停机制(避免成本爆炸)
def should_stop_early(state):
    return (
        state["iteration"] >= MAX_ITERATIONS or
        state["cost"] > COST_BUDGET or
        state["wall_time"] > WALL_CLOCK_LIMIT or
        is_stagnant(state["last_reflection"], state["all_reflections"])
    )

5.4 选型决策树

你的任务需要外部信息吗?
├─ 否 → Layer 1 (o1/o3 内置推理) 或 单次 CoT
└─ 是 → 工具调用是确定性的吗?
        ├─ 是 → Layer 2: ReAct (单 Agent + 工具)
        └─ 否 → 需要试错吗?
                ├─ 是 → Layer 2: Reflexion / Self-Refine
                └─ 否 → 需要多视角吗?
                        ├─ 是 → Layer 3: Multi-Agent Debate (2-3 轮)
                        └─ 否 → Layer 2: LangGraph 显式状态机

第六章:生产级完整代码(LangGraph + ReAct + 反射)

把前面所有知识浓缩成一段可投产的代码。

"""
Production-grade LLM Loop Agent
- ReAct pattern with tools
- Self-reflection with external feedback
- Cost & time budgets
- Auto-fallback
"""
import operator, time
from typing import Annotated, TypedDict
from langgraph.graph import StateGraph, END
from openai import OpenAI
from pydantic import BaseModel

client = OpenAI()

# ============ 1. 状态定义 ============
class AgentState(TypedDict):
    query: str
    history: Annotated[list, operator.add]  # 自动累加
    iteration: int
    cost: float
    start_time: float
    is_done: bool
    final_answer: str

# ============ 2. 工具 ============
def search(q: str) -> str: return f"[mock] {q} 的搜索结果..."
def calc(expr: str) -> str: return str(eval(expr))
TOOLS = {"search": search, "calc": calc}

# ============ 3. 节点 ============
def reason_node(state: AgentState):
    history_text = "\n".join([f"{m['role']}: {m['content']}" for m in state["history"]])
    prompt = f"""ReAct agent. Use tools OR finish.

History:
{history_text}

Query: {state['query']}

Respond in JSON:
{{"thought": "...", "action": "search|calc|finish", "arg": "..."}}
"""
    resp = client.chat.completions.create(
        model="gpt-4o-mini",
        messages=[{"role": "user", "content": prompt}],
        response_format={"type": "json_object"},
        temperature=0,
    )
    cost = resp.usage.total_tokens * 0.00000015
    return {
        "history": [{"role": "assistant", "content": resp.choices[0].message.content}],
        "iteration": state["iteration"] + 1,
        "cost": state["cost"] + cost,
    }

def act_node(state: AgentState):
    last = state["history"][-1]["content"]
    import json
    parsed = json.loads(last)
    action, arg = parsed["action"], parsed["arg"]

    if action == "finish":
        return {"is_done": True, "final_answer": arg}

    if action in TOOLS:
        result = TOOLS[action](arg)
        return {"history": [{"role": "tool", "content": f"{action}({arg}) -> {result}"}]}

    return {"history": [{"role": "tool", "content": f"Unknown action: {action}"}]}

def reflect_node(state: AgentState):
    """外部反馈式反射(关键:必须基于工具结果)"""
    history_text = "\n".join([f"{m['role']}: {m['content']}" for m in state["history"]])
    resp = client.chat.completions.create(
        model="gpt-4o-mini",
        messages=[{"role": "user", "content":
            f"Are we done? If yes, output {{'done': true, 'answer': '...'}}. "
            f"If no, suggest next step: {{'done': false, 'next': '...'}}\n\n"
            f"History:\n{history_text}"
        }],
        response_format={"type": "json_object"},
        temperature=0,
    )
    import json
    r = json.loads(resp.choices[0].message.content)
    cost = resp.usage.total_tokens * 0.00000015
    return {
        "history": [{"role": "reflector", "content": resp.choices[0].message.content}],
        "is_done": r.get("done", False),
        "final_answer": r.get("answer", ""),
        "cost": state["cost"] + cost,
    }

# ============ 4. 终止条件(4 道防线)===========
def should_continue(state: AgentState) -> str:
    if state["is_done"]: return "end"
    if state["iteration"] >= 7: return "end"  # max iterations
    if state["cost"] > 0.5: return "end"        # cost budget
    if time.time() - state["start_time"] > 30: return "end"  # time budget
    return "reflect"

# ============ 5. 组装图 ============
workflow = StateGraph(AgentState)
workflow.add_node("reason", reason_node)
workflow.add_node("act", act_node)
workflow.add_node("reflect", reflect_node)
workflow.set_entry_point("reason")
workflow.add_edge("reason", "act")
workflow.add_edge("act", "reflect")
workflow.add_conditional_edges("reflect", should_continue, {
    "end": END,
    "reflect": "reason",  # 回到 reason 继续
})
app = workflow.compile()

# ============ 6. 使用 ============
result = app.invoke({
    "query": "北京今天适合跑步吗?",
    "history": [],
    "iteration": 0,
    "cost": 0.0,
    "start_time": time.time(),
    "is_done": False,
    "final_answer": "",
})
print(result["final_answer"])
print(f"Cost: ${result['cost']:.4f}, Iterations: {result['iteration']}")

总结:把 Loop 用好的 3 句话

  1. Loop 是 LLM 应用的氧气——没有反馈的 LLM 是个一次性的金鱼,配上反馈才是条能学会的鱼
  2. 外部反馈 > 内部反思——工具返回值、单元测试、用户反馈,永远比"再想想"管用
  3. 3-7 次是甜蜜点——超过 7 次边际收益下降,成本指数上升,质量还可能退化

最后一句别再写"一次调用"的代码了。从今天开始,你的每个 LLM 函数旁边都应该有一个 for 循环——但要记得给它 4 道防线。


附录:必读 7 篇 + 3 个框架

论文(按重要性排序)

  1. ReAct (Yao et al., 2022, ICLR 2023) — arxiv.org/abs/2210.03629
  2. Reflexion (Shinn et al., 2023) — arxiv.org/abs/2303.11366
  3. Self-Refine (Madaan et al., 2023) — arxiv.org/abs/2303.08181
  4. LLM Cannot Self-Correct Reasoning Yet (Huang et al., ICLR 2024) — arxiv.org/abs/2310.01798
  5. Building Effective Agents (Anthropic, 2024/12) — 工业界必读
  6. Lilian Weng: LLM Powered Autonomous Agents (2023) — 综述
  7. Tree of Thoughts (Yao et al., 2023) — CoT 进阶版

框架(按推荐度排序)

框架 适用场景 学习曲线 推荐度
LangGraph 显式状态机、复杂 workflow ⭐⭐⭐⭐⭐
Anthropic Claude Agent SDK 用 Claude 的工具调用 ⭐⭐⭐⭐
AutoGen (Microsoft) 多 Agent 协作 ⭐⭐⭐
CrewAI 角色化多 Agent ⭐⭐⭐
Pydantic AI 类型安全的 LLM 应用 ⭐⭐⭐⭐

调试技巧(10 条)

  1. 每轮 log 完整 prompt——别只看输出
  2. 可视化状态机——LangGraph Studio / LangSmith
  3. A/B 测试不同 prompt——loop 内的 prompt 微调可能差 30%
  4. 强制 JSON 输出——避免解析地狱
  5. Token 计数器必加——cost 是隐形炸弹
  6. 失败样本定期人工 review——loop 失败往往暴露系统设计缺陷
  7. 关键反思存数据库——积累成"反思语料"
  8. timeout 必设——LLM 慢响应不要无限等
  9. 先单 Agent,后多 Agent——复杂度慢慢加
  10. 生产前先 100 条 case 跑一遍——覆盖率决定稳定性

金句

  1. "LLM 应用不是写出来的,是'循环'出来的"
  2. "没有外部反馈的 loop = 给金鱼装跑步机"
  3. "Loop 的第 4 次,是天使也是魔鬼——它能起死回生,也能让成本起火"
  4. "真正的 Agent,99% 都是'ReAct + Reflect + Budget'"
  5. "别让 LLM 反思自己——给它一面外部的镜子"

三句话总结

  1. Loop 的本质是"反馈",不是"次数"
  2. 3-7 次是甜蜜点,超过边际收益陡降
  3. 4 道防线(max/cost/time/stagnation)必加,少一个都别上生产

数据源附录

  • Anthropic "Building Effective Agents" (2024-12)
  • LangChain Blog "Reflection Agents" (2024)
  • Lilian Weng "LLM Powered Autonomous Agents" (2023-06)
  • ReAct 论文 (Yao et al. 2022, ICLR 2023)
  • Reflexion 论文 (Shinn et al. 2023)
  • Self-Refine 论文 (Madaan et al. 2023)
  • ICLR 2024 "LLM Cannot Self-Correct Reasoning Yet"
  • 30+ 公开生产事故复盘(Anthropic/Google/Meta 2024-2025 内部分享)

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容