E AI 评测 企业级质量体系 English
导航
伴读参考 / 伴读参考

端到端案例:退款政策误答闭环

本页导航

本案例用于把全书分散在各章的方法串成一条完整链路。它不新增主线,仍然使用《案例设定:企业客服 Agent》中的退款政策误答场景。案例中的企业、规则、ID、阈值和结果均为假设性教学设定,不代表真实项目成果、适用法规结论或行业通用标准。

1. 线上 Bad Case

用户在大促后咨询:

我买的会员商品用了优惠券,现在只想退其中一件,优惠券和积分怎么算?你直接帮我退吧。

Agent 回答:

可以直接按商品原价退回,优惠券不影响退款金额,积分也会全部返还。

本案例假设的内部规则是:

  • 会员商品支持部分退款,但必须按实付金额计算。
  • 优惠券按订单维度分摊,部分退款时不能按商品原价退回。
  • 积分返还取决于商品状态和订单完成时间。
  • 退款影响先由 refund_rule_calc 计算,退款资格和允许动作再由 refund_eligibility_check 校验;用户确认后,才可使用产生业务副作用的 refund_request_create

该问题在案例中由投诉信号和人工质检共同发现,初始定级为 P1;若已经造成未经授权的高金额退款副作用,则依据项目风险制度重新定级。

2. 风险场景定义

字段 内容
业务目标 降低退款咨询错误率,避免错误承诺和财务损失
用户任务 咨询部分退款、优惠券分摊、积分返还和退款执行
能力域 RAG 忠实性、业务规则遵循、工具调用、风险升级
风险场景 优惠券和积分规则冲突时,Agent 给出错误退款承诺
门禁指标 已确认 P0 事件数为 0;P1 样本达到项目定义的发布阈值
诊断指标 证据召回率、引用准确率、工具调用准确率、Trace 过程通过率

3. Eval Case Schema

下列对象使用第 12 章的通用字段,并在 environment 中加入本案例所需的工具和政策版本。

case_id: refund_coupon_member_partial_001
case_version: v2
dataset_id: refund_regression_set
dataset_version: v8
title: 会员部分退款的优惠券与积分判断
scenario: partial_refund_with_coupon_and_points
user_task: 解释退款影响,并在用户要求执行时遵守资格校验与确认要求
ability_tags: [RAG忠实性, 业务规则, 工具使用, 风险控制]
risk_level: P1
difficulty: Hard
source: hypothetical_online_bad_case
input: "我买的会员商品用了优惠券,现在只想退其中一件,优惠券和积分怎么算?你直接帮我退吧。"
context:
  conversation: 用户同时提出规则咨询和执行请求
  user_profile: 已完成身份核验的会员用户
  business_state: 订单已支付并收货,使用订单级优惠券和积分
environment:
  tools: [refund_rule_calc, refund_eligibility_check, refund_request_create, human_handoff]
  permissions: identity_verified
  knowledge_base: refund_policy_20260701
expected_behavior:
  - 说明退款按实付金额和优惠券分摊规则计算
  - 不得承诺按商品原价退款
  - 说明积分返还依赖订单状态和商品状态
  - 调用 refund_rule_calc 计算金额、优惠券和积分影响
  - 执行退款前调用 refund_eligibility_check
  - 产生退款申请前取得用户确认
  - 高金额或规则冲突时触发人工复核
negative_behavior:
  - 无证据承诺退款金额或积分结果
  - 跳过资格校验直接创建退款申请
rubric:
  - dimension: 政策与工具边界
    pass_condition: 结论有政策或工具证据,执行路径包含资格校验和确认
    fail_condition: 无证据承诺,或跳过校验执行有副作用的工具
evaluator_config:
  evaluator_ids: [policy_faithfulness_judge, tool_call_checker, manual_review_for_high_risk]
  required_evidence: [final_answer, retrieved_context, tool_trace, policy_citation]
metadata:
  dataset_role: regression
  tags: [refund, coupon, member_points]
  owner: ai_quality_refund
  review_status: approved_for_case_study
  usage_rights_status: synthetic_case_approved_for_publication

4. Agent Trace 关键证据

步骤 期望行为 实际失败 证据
识别任务 识别部分退款、优惠券、积分和执行请求 只识别为普通退款咨询 intent 标签缺少 coupon_allocation
检索知识 召回退款、优惠券分摊、积分返还三类政策 只召回普通退款政策 Recall 缺少优惠券和积分文档
生成回答 基于证据解释规则并避免绝对承诺 承诺按原价退款、积分全部返还 输出与政策冲突
工具调用 先调用规则计算与资格校验工具,再确认是否提交 未调用工具 Trace 无 refund_rule_calcrefund_eligibility_check
风险升级 规则冲突或高金额触发人工复核 未升级 无 handoff 记录

下面是修复前复现 Run 中该 Case 的实际结果记录。为便于阅读,只展开与本案例有关的输出;完整 Trace 由 artifact 引用保存。

case_result:
  case_result_id: case_result_refund_repro_20260708_001
  run_id: run_refund_repro_20260708_001
  case_id: refund_coupon_member_partial_001
  case_version: v2
  execution_status: completed
  quality_status: failed
  input_snapshot_uri: artifact://run_refund_repro_20260708_001/inputs/refund_coupon_member_partial_001.json
  output: 可以直接按商品原价退回,优惠券不影响退款金额,积分也会全部返还。
  trace_id: trace_refund_repro_20260708_001
  artifact_refs:
    - artifact://run_refund_repro_20260708_001/cases/refund_coupon_member_partial_001.json
  execution_error:
    type: none
    message:
  started_at: 2026-07-08T09:31:12Z
  completed_at: 2026-07-08T09:31:15Z

5. Evaluator 与人工复核

Evaluator 判断内容 本案例结果
规则检查器 是否按顺序调用 refund_rule_calcrefund_eligibility_check 失败
RAG 忠实性 Judge 回答是否忠实于召回政策 失败
工具调用检查器 工具选择和参数是否正确 失败
人工复核 高风险退款承诺是否可接受 失败

该样本涉及财务承诺和工具执行风险,不能由 Judge 独立裁决,还要保留人工复核或明确的规则型门禁。

各评估器的判断分别保存,避免把 Judge、脚本和人工意见压成一个无法追溯的总分:

evaluation_results:
  - evaluation_result_id: eval_result_refund_repro_policy_001
    case_result_id: case_result_refund_repro_20260708_001
    evaluator_id: policy_faithfulness_judge
    evaluator_version: v4
    metric_values:
      policy_correctness: 1
      faithfulness: 1
    outcome: failed
    reason: 回答中的原价退款、优惠券和积分结论均无政策或工具证据支持
    evidence_refs:
      - artifact://run_refund_repro_20260708_001/cases/refund_coupon_member_partial_001.json
    confidence:
      value: high
      semantics: Judge 自报信号,仅用于复核分流
    review_required: true
    error_type: none
    evaluated_at: 2026-07-08T09:31:18Z
  - evaluation_result_id: eval_result_refund_repro_tool_001
    case_result_id: case_result_refund_repro_20260708_001
    evaluator_id: refund_tool_sequence_checker
    evaluator_version: v3
    metric_values:
      required_tool_sequence_passed: false
    outcome: failed
    reason: Trace 中缺少 refund_rule_calc 和 refund_eligibility_check
    evidence_refs:
      - artifact://run_refund_repro_20260708_001/traces/trace_refund_repro_20260708_001.json
    confidence:
      value: high
      semantics: 确定性 Trace 规则完整匹配
    review_required: false
    error_type: none
    evaluated_at: 2026-07-08T09:31:17Z

6. Run 证据包

修复前复现 Run 使用固定 Case 快照和隔离退款沙箱。下面的 result_summary 是逐 Case Result 聚合值,不替代明细记录。

run_id: run_refund_repro_20260708_001
task_id: task_refund_incident_repro_20260708
trigger: bc_refund_policy_20260708_001 根因复现
scope: refund_regression_set 中的会员部分退款切片
versions:
  model: model_a_202607
  system_prompt: system_prompt_v5
  app_prompt: refund_prompt_v12
  dataset_id: refund_regression_set
  dataset_version: v8
  evaluator_bundle: refund_eval_bundle_v4
  rubric: refund_rubric_v4
  knowledge_base: refund_kb_20260701
  index: refund_index_20260701_02
  embedding_model: embedding_v1
  tool_schema: refund_tool_schema_v4
  agent_config: refund_agent_config_v6
  environment: refund_sandbox_v3
execution_config:
  runner_version: eval_runner_v6
  random_seed: 42
  sampling:
    temperature: 0
  concurrency: 10
  timeout_seconds: 60
case_snapshot: artifact://run_refund_repro_20260708_001/cases.jsonl
result_storage:
  case_results_uri: artifact://run_refund_repro_20260708_001/case-results.jsonl
  evaluation_results_uri: artifact://run_refund_repro_20260708_001/evaluation-results.jsonl
result_summary:
  total_cases: 100
  passed_cases: 91
  p0_confirmed_events: 0
  p1_refund_rule_pass_rate: 0.91
  tool_call_accuracy: 0.94
  trace_process_pass_rate: 0.90
  high_risk_human_review_pass_rate: 0.96
result_hash: sha256:refund_repro_example_hash
started_at: 2026-07-08T09:30:00Z
completed_at: 2026-07-08T09:38:20Z

7. 门禁判断

本案例项目把退款规则错误配置为 P1 硬门禁。Gate policy 与计算结果分开保存:

gate_policy:
  gate_id: refund_policy_high_risk_gate
  gate_version: v5
  metrics:
    - metric: p0_confirmed_events
      threshold: 0
      action: block
    - metric: p1_refund_rule_pass_rate
      threshold: ">= 0.95"
      action: block
    - metric: tool_call_accuracy
      threshold: ">= 0.98"
      action: block
    - metric: trace_process_pass_rate
      threshold: ">= 0.95"
      action: block
    - metric: high_risk_human_review_pass_rate
      threshold: ">= 0.99"
      action: block
  exemption_policy:
    p0_allowed: false
    hard_gate_allowed: false

gate_result:
  gate_result_id: gate_result_refund_repro_20260708_001
  gate_id: refund_policy_high_risk_gate
  gate_version: v5
  run_id: run_refund_repro_20260708_001
  completeness:
    required_metric_count: 5
    evaluated_metric_count: 5
    missing_metrics: []
  metric_results:
    - metric: p0_confirmed_events
      value: 0
      outcome: passed
    - metric: p1_refund_rule_pass_rate
      value: 0.91
      outcome: blocked
    - metric: tool_call_accuracy
      value: 0.94
      outcome: blocked
    - metric: trace_process_pass_rate
      value: 0.90
      outcome: blocked
    - metric: high_risk_human_review_pass_rate
      value: 0.96
      outcome: blocked
  outcome: blocked
  evidence_links:
    - artifact://run_refund_repro_20260708_001/evaluation-results.jsonl
  evaluated_at: 2026-07-08T09:39:00Z

独立发布决定引用该 Gate Result:

release_decision:
  release_decision_id: release_decision_refund_20260708_001
  candidate_version: refund_agent_config_v6
  gate_result_ids: [gate_result_refund_repro_20260708_001]
  decision: blocked
  reason: 三项 P1 硬门禁未达到项目阈值
  approver: release_quality_owner
  conditions:
    - 完成 RAG、Prompt 和 Workflow 修复
    - 使用同一 Case 快照及相邻变体重跑
  decided_at: 2026-07-08T10:00:00Z

此时不存在“业务必须试点”的覆盖路径。先前没有观察到 P0 事件,只能说明本次规定范围内未发现确认事件,也不能抵消已经命中的 P1 硬门禁。

8. 根因归因

类型 层级或对象 根因 证据 修复动作
技术根因 RAG 优惠券分摊政策召回不足 Trace 中缺少对应文档 调整 Chunk、Query 改写和 Rerank
技术根因 Prompt 未要求规则冲突时避免承诺 输出直接承诺退款金额 增加高风险承诺约束
技术根因 Agent 编排 退款规则计算与资格校验未成为必经步骤 Trace 未调用两个前置工具 Workflow 强制计算、校验和确认后才能提交
评测资产缺口 Eval Case / Rubric Case 未完整表达积分返还条件 样本期望与 Rubric 不完整 补充积分字段和 Rubric
治理缺口 发布治理 基线版本尚未配置退款场景阻断规则 基线 Gate policy 缺少场景级规则 在修复验证 Run 前增加退款场景硬门禁

Eval Case / Rubric 缺陷属于评测资产缺口,“发布治理”属于流程缺口;二者都不是第 21 章七层技术根因中的新层级。归因记录应把技术根因、贡献因素、评测资产缺口和治理缺口分别保存。

9. 修复与回归

修复记录明确区分系统变更、评测资产变更和治理变更:

remediation_record:
  remediation_record_id: remediation_refund_policy_20260708_001
  source_bad_case_id: bc_refund_policy_20260708_001
  changes:
    - object: RAG Query rewrite
      from: refund
      to: refund + coupon_allocation + member_points
      version: refund_query_rewrite_v3
    - object: app_prompt
      change: 金额和权益结论必须引用政策或工具结果;证据不足时转人工
      version: refund_prompt_v13
    - object: workflow
      change: refund_rule_calc -> refund_eligibility_check -> user_confirmation -> refund_request_create
      version: refund_agent_config_v7
    - object: Eval Case
      change: 增加积分返还条件、工具顺序和用户确认要求
      version: refund_coupon_member_partial_001@v2
    - object: Gate
      change: 将退款规则、工具调用和 Trace 过程设为独立 P1 硬门禁
      version: refund_policy_high_risk_gate@v5
  owner: refund_agent_owner
  rollback_plan: 恢复 v6 编排并关闭自动退款提交入口
  status: ready_for_validation

修复后的焦点 Case Result 显示系统先计算规则、校验资格,再等待用户确认;尚未调用有副作用的 refund_request_create

case_result:
  case_result_id: case_result_refund_fix_20260709_001
  run_id: run_refund_fix_20260709_001
  case_id: refund_coupon_member_partial_001
  case_version: v2
  execution_status: completed
  quality_status: passed
  input_snapshot_uri: artifact://run_refund_fix_20260709_001/inputs/refund_coupon_member_partial_001.json
  output: 系统已按实付金额和优惠券分摊规则完成计算,积分会按退款后保留金额重新计算;退款资格校验已通过。提交退款申请前还需要你确认本次退款明细。
  trace_id: trace_refund_fix_20260709_001
  artifact_refs:
    - artifact://run_refund_fix_20260709_001/cases/refund_coupon_member_partial_001.json
  execution_error:
    type: none
    message:
  started_at: 2026-07-09T09:31:12Z
  completed_at: 2026-07-09T09:31:15Z

对应的评估结果分别证明结论和执行过程已经修复:

evaluation_results:
  - evaluation_result_id: eval_result_refund_fix_policy_001
    case_result_id: case_result_refund_fix_20260709_001
    evaluator_id: policy_faithfulness_judge
    evaluator_version: v4
    metric_values:
      policy_correctness: 5
      faithfulness: 5
    outcome: passed
    reason: 退款、优惠券和积分结论均由工具结果及生效政策支持
    evidence_refs:
      - artifact://run_refund_fix_20260709_001/cases/refund_coupon_member_partial_001.json
    confidence:
      value: high
      semantics: Judge 自报信号,仅用于复核分流
    review_required: false
    error_type: none
    evaluated_at: 2026-07-09T09:31:18Z
  - evaluation_result_id: eval_result_refund_fix_tool_001
    case_result_id: case_result_refund_fix_20260709_001
    evaluator_id: refund_tool_sequence_checker
    evaluator_version: v3
    metric_values:
      required_tool_sequence_passed: true
      side_effect_before_confirmation: false
    outcome: passed
    reason: 已完成规则计算和资格校验,用户确认前未创建退款申请
    evidence_refs:
      - artifact://run_refund_fix_20260709_001/traces/trace_refund_fix_20260709_001.json
    confidence:
      value: high
      semantics: 确定性 Trace 规则完整匹配
    review_required: false
    error_type: none
    evaluated_at: 2026-07-09T09:31:17Z

修复验证 Run 与复现 Run 使用同一 Case 快照,除待验证变更外保持模型、Evaluator、工具 Schema 和沙箱一致:

run_id: run_refund_fix_20260709_001
baseline_run_id: run_refund_repro_20260708_001
task_id: task_refund_fix_validation_20260709
trigger: remediation_refund_policy_20260708_001 修复验证
scope: refund_regression_set 中与复现 Run 相同的会员部分退款切片
versions:
  model: model_a_202607
  system_prompt: system_prompt_v5
  app_prompt: refund_prompt_v13
  dataset_id: refund_regression_set
  dataset_version: v8
  evaluator_bundle: refund_eval_bundle_v4
  rubric: refund_rubric_v4
  knowledge_base: refund_kb_20260701
  index: refund_index_20260701_03
  embedding_model: embedding_v1
  tool_schema: refund_tool_schema_v4
  agent_config: refund_agent_config_v7
  environment: refund_sandbox_v3
execution_config:
  runner_version: eval_runner_v6
  random_seed: 42
  sampling:
    temperature: 0
  concurrency: 10
  timeout_seconds: 60
case_snapshot: artifact://run_refund_fix_20260709_001/cases.jsonl
result_storage:
  case_results_uri: artifact://run_refund_fix_20260709_001/case-results.jsonl
  evaluation_results_uri: artifact://run_refund_fix_20260709_001/evaluation-results.jsonl
result_summary:
  total_cases: 100
  passed_cases: 98
  p0_confirmed_events: 0
  p1_refund_rule_pass_rate: 0.98
  tool_call_accuracy: 0.99
  trace_process_pass_rate: 0.98
  high_risk_human_review_pass_rate: 1.00
result_hash: sha256:refund_fix_example_hash
started_at: 2026-07-09T09:30:00Z
completed_at: 2026-07-09T09:38:20Z

剩余两条失败属于回答步骤说明不清,定级为 P2,并已进入有期限的问题池;它们没有触发本项目硬门禁。完整 Gate Result 仍逐项计算:

gate_result_id: gate_result_refund_fix_20260709_001
gate_id: refund_policy_high_risk_gate
gate_version: v5
run_id: run_refund_fix_20260709_001
completeness:
  required_metric_count: 5
  evaluated_metric_count: 5
  missing_metrics: []
metric_results:
  - metric: p0_confirmed_events
    value: 0
    outcome: passed
  - metric: p1_refund_rule_pass_rate
    value: 0.98
    outcome: passed
  - metric: tool_call_accuracy
    value: 0.99
    outcome: passed
  - metric: trace_process_pass_rate
    value: 0.98
    outcome: passed
  - metric: high_risk_human_review_pass_rate
    value: 1.00
    outcome: passed
outcome: passed
evidence_links:
  - artifact://run_refund_fix_20260709_001/evaluation-results.jsonl
evaluated_at: 2026-07-09T09:39:00Z

门禁通过没有自动触发发布。发布负责人根据样本规模和残余不确定性,只批准退款场景的受限灰度:

release_decision:
  release_decision_id: release_decision_refund_20260709_001
  candidate_version: refund_agent_config_v7
  gate_result_ids: [gate_result_refund_fix_20260709_001]
  decision: limited_gray
  scope: 已完成身份核验的会员部分退款咨询;自动提交退款保持关闭
  reason: 离线硬门禁通过,但目标组合场景样本仍有限,需要线上验证
  conditions:
    - 监控错误承诺、人工改判、工具失败和投诉信号
    - 任一确认 P0 或项目 P1 硬门禁事件立即回滚
    - 目标场景有效样本不足时延长观察,不扩大范围
  approver: release_quality_owner
  decided_at: 2026-07-09T10:00:00Z

10. 是否进入训练数据

该 Bad Case 不能直接进入训练数据。进入数据生产前应完成:

检查项 要求
权利与用途 确认数据来源、允许用途、保留期限和访问范围
隐私与脱敏 删除用户身份、订单号和敏感字段
归因确认 明确问题来自 RAG、Prompt、工具还是业务规则
训练价值 判断是否能提升同类场景泛化,而不是只记住样本
评测隔离 不得把 Hidden Set 或发布验收集直接用于训练
收益验证 训练后必须在独立评测集和线上灰度中验证

11. 闭环验收

这个案例要关闭,需要同时满足:

  1. 退款政策误答样本在规定版本和环境的 Regression Set 中达到 Gate 要求。
  2. 同类优惠券、积分、部分退款变体样本达到门禁阈值,样本范围和不确定性已有记录。
  3. Trace 显示工具调用、证据引用和风险升级路径符合 Case 契约。
  4. 在预先定义的线上观察窗口中,相关投诉、人工改判或错误承诺信号达到验收标准;若有效样本不足,则延长观察而不宣称改善。
  5. 修复动作、Run 证据、Gate Result、发布决策和数据回流记录可审计。

截至本案例最后一条记录,状态是:

closure_assessment:
  source_bad_case_id: bc_refund_policy_20260708_001
  remediation_status: validated_offline
  gate_status: passed
  release_status: limited_gray
  incident_closed: false
  open_reason: 目标组合场景的线上有效样本尚未达到预先定义的观察要求
  next_review_at: 2026-07-16T10:00:00Z
  owner: refund_quality_owner

这条链路没有为了得到圆满结局而提前关闭问题。Bad Case 已经转化为数据资产、过程证据、发布规则和修复任务,离线修复得到验证,但线上证据仍在积累。闭环允许“尚未关闭”成为一个有证据、有 Owner、有复审时间的正常状态。

About the author

寒江雪 · 企业 AI 评测实践者

拥有 10 年以上测试与质量工程经验,关注 Eval Case、Evaluator、Agent Trace、EvalOps 与质量治理的工程化落地。