Skip to content

10.5 反馈闭环

前面几节我们建立了评估指标、Benchmark、LLM-as-Judge 和自动化评估流水线。这些都是"开发者视角"的评估——由开发团队设计和执行。但 Agent 最终是给用户用的,用户的真实反馈才是最有价值的评估信号。

生活类比:评估自动化像是"出厂质检"——确保产品达标才出厂。反馈闭环像是"用户评价系统"——产品用了好不好,用户说了算。两者结合,产品才能越做越好。没有反馈闭环的 Agent,就像不读用户评价的商家,自以为做得很好,实际上用户早已差评连连。

反馈闭环的整体架构

反馈闭环是 Agent 从"静态"走向"进化"的关键。没有反馈闭环,Agent 只能依靠开发者手动优化,迭代速度慢且容易与实际用户需求脱节。

┌──────────────────────────────────────────────────────────────────┐
│                    反馈闭环完整架构                                │
├──────────────────────────────────────────────────────────────────┤
│                                                                  │
│  ┌──────────────────────────────────────────────────────────┐   │
│  │                    生产环境                                │   │
│  │  ┌─────────┐    ┌─────────┐    ┌───────────────────┐     │   │
│  │  │ 用户输入  │───►│  Agent  │───►│   输出 + 交互日志    │    │   │
│  │  └─────────┘    └─────────┘    └────────┬──────────┘    │   │
│  └─────────────────────────────────────────┼────────────────┘   │
│                                            │                    │
│  ┌─────────────────────────────────────────┼────────────────┐   │
│  │              反馈收集层                   │                │   │
│  │  ┌──────────┐  ┌──────────┐  ┌─────────▼────────┐       │   │
│  │  │显式反馈   │  │隐式反馈   │  │  交互 Trace       │       │   │
│  │  │👍/👎/评分│  │复制/重试/ │  │  (工具调用/耗时)  │       │   │
│  │  │用户评论   │  │停留时间   │  │                  │       │   │
│  │  └────┬─────┘  └────┬─────┘  └────────┬─────────┘       │   │
│  └───────┼──────────────┼─────────────────┼─────────────────┘   │
│          │              │                 │                     │
│  ┌───────┼──────────────┼─────────────────┼─────────────────┐   │
│  │       ▼              ▼                 ▼                 │   │
│  │  ┌──────────────────────────────────────────────────┐    │   │
│  │  │              反馈分析层                             │    │   │
│  │  │  • 自动分类(问题类型、严重程度)                    │    │   │
│  │  │  • 根因分析(为什么失败?)                         │    │   │
│  │  │  • 优先级排序(影响面 × 严重程度)                  │    │   │
│  │  │  • 数据标注(构建训练样本)                         │    │   │
│  │  └──────────────────────┬───────────────────────────┘    │   │
│  └─────────────────────────┼────────────────────────────────┘   │
│                            │                                    │
│  ┌─────────────────────────┼────────────────────────────────┐   │
│  │              优化执行层  │                                │   │
│  │  ┌──────────┐  ┌───────▼──────┐  ┌───────────────┐      │   │
│  │  │Prompt优化│  │Few-shot更新  │  │  模型微调      │      │   │
│  │  │规则调整  │  │示例库扩充    │  │  SFT/RLHF/DPO │      │   │
│  │  └──────────┘  └──────────────┘  └───────────────┘      │   │
│  │              ┌──────────▼──────────┐                    │   │
│  │              │   评估验证 -> 发布    │                    │   │
│  │              └─────────────────────┘                    │   │
│  └─────────────────────────────────────────────────────────┘   │
│                                                                  │
└──────────────────────────────────────────────────────────────────┘

生活类比:反馈闭环就像餐厅的"意见本+改进"循环:客人吃饭后留下反馈(收集层),经理分析哪些是菜品问题、哪些是服务问题(分析层),厨师改配方、服务员改态度(优化层),然后请回头客再来吃(验证发布)。周而复始,越做越好。

用户反馈收集与标注

显式反馈(Explicit Feedback)

用户主动提供的反馈,信噪比高但数据量少——就像客人主动写好评/差评,信息量大但写的人少。

反馈类型收集方式信号强度覆盖度
二分评价👍/👎 按钮
多级评分1-5 星评分
文本评论自由文本输入
纠错反馈用户修正回答最强极低

生活类比:纠错反馈就像客人说"这个菜盐放多了"然后自己拿去厨房重新炒了一遍——信息量最大,但极少有客人愿意这么做。所以一旦收到,要格外重视。

隐式反馈(Implicit Feedback)

从用户行为中推断的信号,数据量大但需要清洗——就像餐厅通过"剩菜量"判断菜品好不好吃,不用问客人。

行为信号含义推断置信度
用户复制了答案答案有用
用户重新提问首次回答不满意
用户中断对话可能不满意
快速浏览后离开答案可能不够好
继续追问细节信息不完整
用户执行了 Agent 建议建议被采纳

反馈收集系统实现

下面是完整的反馈收集系统,代码逐行注释:

python
from dataclasses import dataclass, field      # 数据类装饰器
from typing import Dict, List, Optional        # 类型注解
from datetime import datetime                  # 时间处理
from enum import Enum                          # 枚举类型
import json                                    # JSON 序列化
import uuid                                    # 生成唯一 ID


class FeedbackType(Enum):
    """反馈类型枚举"""
    EXPLICIT = "explicit"    # 用户主动反馈(评分、评论)
    IMPLICIT = "implicit"    # 行为推断(复制、重试)
    SYSTEM = "system"        # 系统自动检测(超时、错误)


class FeedbackSentiment(Enum):
    """反馈情感极性"""
    POSITIVE = "positive"   # 正面反馈
    NEUTRAL = "neutral"     # 中性反馈
    NEGATIVE = "negative"   # 负面反馈


class IssueCategory(Enum):
    """问题分类枚举——用于自动分类反馈中的问题类型"""
    FACTUAL_ERROR = "factual_error"         # 事实错误:说错了
    INCOMPLETE = "incomplete"               # 不完整:漏了关键信息
    IRRELEVANT = "irrelevant"               # 不相关:答非所问
    HALLUCINATION = "hallucination"         # 幻觉:编造了不存在的信息
    TOOL_ERROR = "tool_error"               # 工具调用错误
    FORMAT_ERROR = "format_error"           # 格式错误
    SAFETY_ISSUE = "safety_issue"           # 安全问题
    LATENCY = "latency"                     # 延迟过高
    OTHER = "other"                         # 其他


@dataclass
class ConversationTurn:
    """对话轮次——记录一次用户与 Agent 的交互"""
    turn_id: str                             # 轮次 ID
    user_query: str                         # 用户输入
    agent_response: str                     # Agent 回答
    timestamp: datetime                     # 时间戳
    tool_calls: List[Dict] = field(default_factory=list)  # 工具调用记录
    latency_ms: float = 0.0                 # 响应延迟(毫秒)
    tokens_used: int = 0                    # Token 消耗


@dataclass
class Feedback:
    """用户反馈——一个完整的反馈记录"""
    feedback_id: str                         # 反馈 ID
    conversation_id: str                     # 对话 ID
    turn_id: str                             # 关联的对话轮次 ID
    type: FeedbackType                       # 反馈类型
    sentiment: FeedbackSentiment             # 情感极性

    # 显式反馈字段
    rating: Optional[int] = None             # 评分 1-5
    user_comment: Optional[str] = None       # 用户文字评论
    corrected_answer: Optional[str] = None  # 用户修正的答案

    # 隐式反馈字段
    behavior_signal: Optional[str] = None    # 行为信号:copy/retry/abandon
    behavior_confidence: float = 0.0         # 行为推断的置信度

    # 系统标注
    issue_category: Optional[IssueCategory] = None  # 问题分类
    issue_description: Optional[str] = None         # 问题描述
    severity: Optional[str] = None                  # 严重程度:critical/high/medium/low

    timestamp: datetime = field(default_factory=datetime.now)
    metadata: Dict = field(default_factory=dict)


class FeedbackCollector:
    """
    反馈收集器——统一收集显式和隐式反馈
    
    职责:
    1. 收集用户主动提供的显式反馈(评分、评论、纠错)
    2. 从用户行为中推断隐式反馈(复制、重试、放弃)
    3. 自动分类问题类型
    4. 持久化存储反馈数据
    """

    def __init__(self, storage_path: str = "feedback_store.jsonl"):
        """
        初始化反馈收集器
        
        Args:
            storage_path: 反馈存储文件路径(JSONL 格式,每行一条)
        """
        self.storage_path = storage_path
        self.conversations: Dict[str, List[ConversationTurn]] = {}  # 对话缓存

    def collect_explicit_feedback(
        self,
        turn_id: str,                          # 对话轮次 ID
        rating: int = None,                    # 评分 1-5
        user_comment: str = None,              # 用户评论
        corrected_answer: str = None,           # 用户修正的答案
    ) -> Feedback:
        """收集显式反馈——用户主动提供的反馈"""
        # 根据评分判断情感极性
        sentiment = FeedbackSentiment.NEUTRAL  # 默认中性
        if rating and rating >= 4:             # 4-5 分为正面
            sentiment = FeedbackSentiment.POSITIVE
        elif rating and rating <= 2:           # 1-2 分为负面
            sentiment = FeedbackSentiment.NEGATIVE

        feedback = Feedback(
            feedback_id=str(uuid.uuid4())[:8], # 生成 8 位 ID
            conversation_id=turn_id.split("_")[0],
            turn_id=turn_id,
            type=FeedbackType.EXPLICIT,
            sentiment=sentiment,
            rating=rating,
            user_comment=user_comment,
            corrected_answer=corrected_answer,
        )
        self._save_feedback(feedback)           # 持久化存储
        return feedback

    def infer_implicit_feedback(
        self,
        turn_id: str,
        user_behavior: str,                    # "copy", "retry", "abandon", "follow_up"
    ) -> Feedback:
        """
        推断隐式反馈——从用户行为推断反馈信号
        
        不同行为对应不同的情感极性和置信度:
        - copy(复制答案):正面,用户觉得有用
        - retry(重新提问):负面,首次回答不满意
        - abandon(放弃对话):负面,可能不满意
        - follow_up(追问细节):中性,信息不完整
        - accept_action(采纳建议):正面,建议被接受
        """
        signal_map = {
            "copy": (FeedbackSentiment.POSITIVE, 0.7),      # 复制 = 有用
            "retry": (FeedbackSentiment.NEGATIVE, 0.8),     # 重试 = 不满意
            "abandon": (FeedbackSentiment.NEGATIVE, 0.5),   # 放弃 = 可能不满意
            "follow_up": (FeedbackSentiment.NEUTRAL, 0.6),   # 追问 = 不完整
            "accept_action": (FeedbackSentiment.POSITIVE, 0.9),  # 采纳 = 很有用
        }

        sentiment, confidence = signal_map.get(
            user_behavior, (FeedbackSentiment.NEUTRAL, 0.3)  # 未知行为默认低置信度
        )

        feedback = Feedback(
            feedback_id=str(uuid.uuid4())[:8],
            conversation_id=turn_id.split("_")[0],
            turn_id=turn_id,
            type=FeedbackType.IMPLICIT,
            sentiment=sentiment,
            behavior_signal=user_behavior,
            behavior_confidence=confidence,
        )
        self._save_feedback(feedback)
        return feedback

    def _save_feedback(self, feedback: Feedback):
        """保存反馈到存储——JSONL 格式,每行一条 JSON"""
        with open(self.storage_path, "a") as f:
            f.write(json.dumps({
                "feedback_id": feedback.feedback_id,
                "conversation_id": feedback.conversation_id,
                "turn_id": feedback.turn_id,
                "type": feedback.type.value,
                "sentiment": feedback.sentiment.value,
                "rating": feedback.rating,
                "user_comment": feedback.user_comment,
                "issue_category": feedback.issue_category.value if feedback.issue_category else None,
                "timestamp": feedback.timestamp.isoformat(),
            }, ensure_ascii=False) + "\n")

    def get_feedback_stats(self) -> Dict:
        """获取反馈统计——汇总正负面反馈和问题分布"""
        stats = {
            "total": 0, "positive": 0, "neutral": 0, "negative": 0,
            "avg_rating": 0.0, "by_issue": {},
        }

        try:
            with open(self.storage_path, "r") as f:
                ratings = []
                for line in f:
                    fb = json.loads(line)        # 解析每行 JSON
                    stats["total"] += 1
                    sentiment = fb.get("sentiment", "neutral")
                    stats[sentiment] = stats.get(sentiment, 0) + 1

                    if fb.get("rating"):
                        ratings.append(fb["rating"])

                    category = fb.get("issue_category")
                    if category:
                        stats["by_issue"][category] = stats["by_issue"].get(category, 0) + 1

                if ratings:
                    stats["avg_rating"] = sum(ratings) / len(ratings)
        except FileNotFoundError:
            pass

        if stats["total"] > 0:
            stats["satisfaction_rate"] = f"{stats['positive']/stats['total']*100:.1f}%"

        return stats

反馈到模型优化闭环

收集到反馈后,关键是如何将反馈转化为改进。不同类型的反馈对应不同的优化策略:

┌──────────────────────────────────────────────────────────────────┐
│              反馈驱动的优化策略                                    │
├──────────────────────────────────────────────────────────────────┤
│                                                                  │
│  反馈类型          │  优化策略               │  实施周期           │
│  ─────────────────┼────────────────────────┼───────────────────  │
│  格式/结构问题     │  Prompt 调整            │  小时级              │
│  常见困惑         │  Few-shot 示例更新      │  天级               │
│  工具调用错误     │  Function Schema 优化    │  天级               │
│  知识缺失         │  知识库更新 / RAG 优化   │  天级               │
│  系统性问题       │  模型微调(SFT/DPO)     │  周级               │
│  安全/合规问题    │  安全护栏 + 紧急修复     │  立即               │
│                                                                  │
└──────────────────────────────────────────────────────────────────┘

生活类比

  • Prompt 调整 = 调整菜谱中的调味比例(快、容易)
  • Few-shot 更新 = 增加新菜品到菜单(中等)
  • RAG 优化 = 更换食材供应商(涉及供应链)
  • 模型微调 = 厨师重新培训(大工程,效果持久)

不同优化策略的适用场景

策略成本覆盖面风险适用场景
Prompt 优化特定模式的问题
Few-shot 更新新增场景和边界 case
RAG 优化知识相关错误
规则系统确定性强的场景
SFT 微调广系统性能力不足
DPO 对齐广偏好/风格对齐

Few-shot 示例库动态更新

从反馈中提取高质量示例,动态更新 Few-shot 示例库是最高性价比的优化手段:

python
import json                                      # JSON 处理
from typing import List, Dict, Optional          # 类型注解
from datetime import datetime                    # 时间处理
from pathlib import Path                          # 路径处理


class FewShotManager:
    """
    Few-shot 示例库管理器——从反馈中提取示例,动态更新示例库
    
    核心功能:
    1. 添加新示例(手动或从反馈中提取)
    2. 按策略选择最相关的示例(相似度/多样性/最近)
    3. 跟踪示例使用效果,淘汰低效示例
    4. 格式化为 Prompt 可用的 Few-shot 文本
    """

    def __init__(self, example_path: str = "few_shot_examples.json"):
        """初始化示例库管理器"""
        self.example_path = Path(example_path)
        self.examples = self._load_examples()  # 从文件加载已有示例

    def _load_examples(self) -> List[Dict]:
        """加载示例库——从 JSON 文件读取"""
        if self.example_path.exists():
            with open(self.example_path, "r") as f:
                return json.load(f)
        return []                               # 文件不存在时返回空列表

    def _save_examples(self):
        """保存示例库——写入 JSON 文件"""
        self.example_path.parent.mkdir(parents=True, exist_ok=True)
        with open(self.example_path, "w") as f:
            json.dump(self.examples, f, ensure_ascii=False, indent=2)

    def add_example(
        self,
        input_text: str,                       # 输入文本
        output_text: str,                       # 输出文本
        category: str,                         # 类别标签
        source: str = "manual",                # 来源:manual/feedback
        metadata: Dict = None,                 # 元数据
    ):
        """添加新示例到示例库"""
        example = {
            "id": f"ex_{len(self.examples)+1:04d}",  # 自动生成 ID
            "input": input_text,
            "output": output_text,
            "category": category,
            "source": source,
            "created_at": datetime.now().isoformat(),
            "use_count": 0,                    # 使用次数
            "success_rate": 1.0,               # 成功率(初始为 1.0)
            "metadata": metadata or {},
        }
        self.examples.append(example)
        self._save_examples()                   # 持久化
        print(f"Added example: {example['id']} [{category}]")

    def add_from_feedback(
        self,
        feedback: Dict,                        # 用户反馈
        original_turn: Dict,                   # 原始对话轮次
    ):
        """
        从用户反馈中添加示例
        
        两类高价值示例:
        1. 用户修正的答案——最优质的训练数据
        2. 高分回答——作为正面示例
        """
        # 用户修正的答案——这是最有价值的反馈
        if feedback.get("corrected_answer"):
            self.add_example(
                input_text=original_turn["user_query"],
                output_text=feedback["corrected_answer"],
                category="user_correction",    # 标记为用户修正
                source="feedback",
                metadata={
                    "original_response": original_turn["agent_response"],
                    "feedback_rating": feedback.get("rating"),
                    "user_comment": feedback.get("user_comment"),
                },
            )

        # 高分回答——作为正面示例
        if feedback.get("rating", 0) >= 4:      # 4-5 分的回答
            self.add_example(
                input_text=original_turn["user_query"],
                output_text=original_turn["agent_response"],
                category="positive_example",   # 标记为正面示例
                source="feedback",
                metadata={
                    "rating": feedback["rating"],
                    "user_comment": feedback.get("user_comment"),
                },
            )

    def select_examples(
        self,
        query: str,                             # 当前查询
        category: str = None,                   # 按类别过滤
        max_examples: int = 5,                   # 最多返回几个示例
        strategy: str = "diversity",            # 选择策略
    ) -> List[Dict]:
        """
        选择最相关的 Few-shot 示例
        
        策略说明:
        - similarity:按与查询的相似度排序(需要 Embedding)
        - diversity:尽量选择不同类别的示例
        - recency:按创建时间排序,取最新的
        """
        candidates = self.examples
        if category:                             # 按类别过滤
            candidates = [e for e in candidates if e["category"] == category]

        if not candidates:
            return []

        if strategy == "recency":
            # 按创建时间排序,取最新的
            candidates.sort(key=lambda x: x["created_at"], reverse=True)
            selected = candidates[:max_examples]
        elif strategy == "diversity":
            # 尽量选择不同类别的示例
            selected = []
            seen_categories = set()
            for ex in candidates:
                if ex["category"] not in seen_categories:
                    selected.append(ex)
                    seen_categories.add(ex["category"])
                if len(selected) >= max_examples:
                    break
        else:
            # 默认:按成功率排序
            candidates.sort(key=lambda x: x["success_rate"], reverse=True)
            selected = candidates[:max_examples]

        # 更新使用计数
        for ex in selected:
            ex["use_count"] = ex.get("use_count", 0) + 1

        return selected

    def update_example_performance(
        self, example_id: str, was_helpful: bool
    ):
        """更新示例的效果——用于淘汰低效示例"""
        for ex in self.examples:
            if ex["id"] == example_id:
                total = ex.get("use_count", 0)
                current_success = ex.get("success_rate", 1.0) * total
                ex["use_count"] = total + 1
                ex["success_rate"] = (current_success + (1 if was_helpful else 0)) / (total + 1)
                break

    def prune_examples(self, min_success_rate: float = 0.3, min_uses: int = 10):
        """
        淘汰低效示例——定期清理效果差的示例
        
        条件:使用次数 >= min_uses 且成功率 < min_success_rate
        (使用次数太少的不淘汰,因为数据不足)
        """
        before = len(self.examples)
        self.examples = [
            e for e in self.examples
            if e.get("use_count", 0) < min_uses     # 使用次数不足,保留
            or e.get("success_rate", 1.0) >= min_success_rate  # 成功率达标,保留
        ]
        after = len(self.examples)
        removed = before - after
        if removed:
            self._save_examples()
            print(f"Pruned {removed} low-performing examples")
        return removed

    def format_for_prompt(self, examples: List[Dict]) -> str:
        """将示例格式化为 Prompt 中可用的 Few-shot 文本"""
        formatted = []
        for ex in examples:
            formatted.append(f"用户:{ex['input']}\n助手:{ex['output']}")
        return "\n\n".join(formatted)              # 用空行分隔各示例


# 演示使用
def demo_few_shot_manager():
    """Few-shot 示例库管理演示"""
    manager = FewShotManager()

    # 添加初始示例(手动编写)
    manager.add_example(
        "查询订单 #12345 的状态",
        "订单 #12345 当前状态:已发货,预计明天送达。",
        "order_query",
        source="manual",
    )
    manager.add_example(
        "我要退货,商品有质量问题",
        "很抱歉给您带来不便。请提供订单号,我将为您发起退货流程。",
        "refund",
        source="manual",
    )

    # 从用户反馈中添加示例
    feedback = {
        "rating": 1,                              # 差评
        "corrected_answer": "GIL 是 CPython 的全局解释器锁,确保同一时刻只有一个线程执行字节码。",
        "user_comment": "之前回答错误,GIL 不是图形界面库",
    }
    original_turn = {
        "user_query": "Python 的 GIL 是什么?",
        "agent_response": "GIL 是图形界面库",      # 错误回答
    }
    manager.add_from_feedback(feedback, original_turn)

    # 选择示例
    query = "帮我查一下我的订单"
    selected = manager.select_examples(query, max_examples=3)
    print("Selected examples for query:", query)
    print(manager.format_for_prompt(selected))

    # 查看统计
    stats = manager.get_stats()
    print(f"\n示例库统计: {stats}")

持续学习策略

反馈闭环不仅是"收集-优化"的线性流程,还可以采用不同的持续学习策略:

┌──────────────────────────────────────────────────────────────────┐
│              持续学习策略对比                                     │
├──────────────────────────────────────────────────────────────────┤
│                                                                  │
│  1. 在线学习(Online Learning)                                    │
│     └─ 实时从每个交互中学习,立即更新模型                          │
│     优点:响应最快,始终最新                                       │
│     缺点:不稳定,可能学到噪声,灾难性遗忘                         │
│     适用:规则系统、Few-shot 示例库                               │
│                                                                  │
│  2. 批处理学习(Batch Learning)                                   │
│     └─ 积累一批高质量反馈后统一更新                                │
│     优点:稳定可控,质量有保障                                     │
│     缺点:延迟较高,需要人工审核                                   │
│     适用:Prompt 优化、微调                                       │
│                                                                  │
│  3. 主动学习(Active Learning)                                    │
│     └─ 识别不确定性高的样本,主动请求人工标注                      │
│     优点:标注效率高,数据质量好                                   │
│     缺点:需要人工标注资源                                         │
│     适用:构建高质量训练集                                        │
│                                                                  │
│  4. 课程学习(Curriculum Learning)                                │
│     └─ 从简单到困难逐步学习                                        │
│     优点:训练稳定,效果好                                         │
│     缺点:需要人工设计课程                                         │
│     适用:微调训练                                                │
│                                                                  │
└──────────────────────────────────────────────────────────────────┘

推荐策略组合

快速修复通道(< 1 天):
  用户反馈 -> 自动分类 -> 规则/Prompt 调整 -> 回归测试 -> 上线

质量提升通道(1-2 周):
  积累反馈 -> 人工标注 -> 构建训练集 -> 模型微调 -> A/B 测试 -> 上线

长期优化通道(月度):
  反馈分析 -> 能力短板识别 -> 架构调整 -> 全面评估 -> 版本发布

生活类比:三条通道就像医院的分诊系统——急诊(快速修复通道)处理紧急问题,住院(质量提升通道)做系统治疗,体检(长期优化通道)做全面预防。不能什么病都去急诊,也不能什么病都住院。

常见误区

误区一:只收集显式反馈,忽略隐式反馈

大多数用户不会主动评分或写评论——沉默是大多数。但他们的行为(复制、重试、放弃)包含了丰富的反馈信号。只看评分按钮的数据,会错过 90% 的用户反馈。必须同时收集隐式反馈,交叉验证。

误区二:所有反馈都走"快速修复通道"

Prompt 调整确实快,但它只能解决"特定模式的问题"。如果 Agent 在某个能力维度上系统性不足(比如数学推理差),改 Prompt 是治标不治本的。需要区分"表面问题"和"根因问题",后者需要走微调通道。

误区三:反馈数据直接用于训练,不做清洗

用户反馈中有大量噪声——误触的差评、不合理的期望、恶意反馈。直接用这些数据训练模型,可能"越学越差"。必须经过清洗、标注、审核后才能用于训练。

误区四:反馈闭环只优化模型,不优化工具和流程

有时候问题不在模型,而在工具——比如 API 返回数据格式变化导致 Agent 解析失败。反馈闭环应该覆盖整个系统(Prompt + 工具 + RAG + 模型),而不是只盯着模型优化。

本节小结

阶段关键活动产出周期
收集显式+隐式反馈采集反馈数据流实时
分析自动分类+根因分析改进计划每日
优化Prompt/规则/Few-shot 更新快速修复小时~天
训练反馈数据标注+微调模型更新周~月
验证回归测试+A/B 实验效果验证每次发布

关键原则

  • 反馈闭环是 Agent 持续进化的关键,没有闭环的 Agent 是"死"的
  • 隐式反馈量大但信噪比低,需要配合显式反馈交叉验证
  • 快速反馈通道(Prompt/规则)和慢速反馈通道(微调)应并行运行
  • 从反馈中构建的训练数据质量远高于人工构造的数据
  • 需要建立反馈优先级机制,按"影响面 × 严重程度"排序改进项

有了反馈闭环,Agent 能持续从用户那里学习。但要想"看到" Agent 的运行状态——每一步做了什么、花了多少钱、哪里出了问题——还需要可观测性工具。这正是 10.6 节要解决的问题。