Skip to content

evaluation: return an unevaluated ROUGE result when no turns are paired - #384

Open
yqia03 wants to merge 2 commits into
trpc-group:mainfrom
yqia03:fix/rouge-empty-invocations
Open

yqia03 wants to merge 2 commits into
trpc-group:mainfrom
yqia03:fix/rouge-empty-invocations

Conversation

@yqia03

@yqia03 yqia03 commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

ROUGE takes the mean of an empty score list when no invocations can be paired. Return the default unevaluated result only if both lists are empty. If exactly one list is empty, report a ValueError with both counts so the evaluation service retains the diagnostic. Pairing for nonempty inputs and existing aggregation behavior are unchanged.

The new public API test failed on main and passed with the change. Two additional regression cases failed on the initial patch and now pass, one for each empty side. All 38 tests across five related evaluation files passed locally on macOS arm64. An in-memory evaluation service smoke test against this checkout confirmed that an empty actual batch with a reference retains its error diagnostic.

The type for release triage is type/bug.

RELEASE NOTES: ROUGE reports an unevaluated result for two empty invocation lists and reports a diagnostic when one side is missing.

OpenAI Codex prepared the patch and regression test and ran the local checks.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-29T08:22:36.549474Z 2bc5003 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@codecov

codecov Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@1590e17). Learn more about missing BASE report.

Additional details and impacted files
@@            Coverage Diff             @@
##             main        #384   +/-   ##
==========================================
  Coverage        ?   87.62293%           
==========================================
  Files           ?         556           
  Lines           ?       54706           
  Branches        ?           0           
==========================================
  Hits            ?       47935           
  Misses          ?        6771           
  Partials        ?           0           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@helloopenworld

Copy link
Copy Markdown
Contributor

AI Code Review

审查结论

不通过

审查范围:2bc5003(base 1590e17),共 2 个文件、12 行新增:_rouge_evaluator.py 在配对循环后新增 if not per_invocation_results: return EvaluationResult() 空守卫;test_rouge_evaluator.py 新增 test_empty_invocations_are_not_evaluated。

计划符合性:变更确实按计划返回了"未评估的 ROUGE 结果"(EvaluationResult() 默认 overall_eval_status=NOT_EVALUATED、overall_score=None、per_invocation_results=[]),与兄弟评估器 _final_response_evaluator/_trajectory_evaluator 的既有模式一致,pydantic v2 对可变默认值逐实例深拷贝使测试断言安全。下游 _local_eval_service/_remote_eval_service 对空结果的处理(逐索引 fallback、_generate_final_eval_status)均兼容。

主要风险(均已验证证据链):(1) 诊断丢失——此前空列表会使 statistics.mean([]) 抛 StatisticsError,被服务层兜底捕获并写入 case_error_message + log_error;新守卫使"agent 推理产出 0 个 turn(非 trace 模式下 inference 内部异常仅设置 status=FAILURE 仍继续评估)"或"expected 侧为空"的场景返回干净的 NOT_EVALUATED 且 error_message=None,与"确实无数据"不可区分。(2) zip 长度截断依赖——守卫只覆盖 min(len)>=1 之外的边界,单侧为空/长度不等的数据不匹配被静默吞掉且无校验补充。(3) 门禁语义漂移——_utils.build_summary 对唯一 metric 为 NOT_EVALUATED 的 case 判定 case_overall="passed"(case_passed 不翻转),而 process_metrics_and_get_failures 在空时直接 skip、_optimize_evaluator_call.summarize_outcome 又把 NOT_EVALUATED 计为失败且不计分;同一空 turn 场景在终端报告、持久化结果、优化器三处语义互相矛盾。pass@k 计数同样将零 turn 计入失败 run,且删除的唯一区分信号就是本次变更移除的 error_message。

测试影响:新增测试只覆盖对称空输入 ([], []),未覆盖单侧空/长度不等这两类守卫真正生效且最易出错的输入;此外 skip_if_no_rouge 夹具与模块顶层导入 RougeEvaluator 的组合使 __init__ 中的 ImportError 在收集期即抛错,夹具实际无法按注释意图生效(rouge-score 缺失时是收集错误而非 skip)。

门禁结论:FAILED。变更本身正确消除了空输入崩溃,但将以"inference 无输出/数据不匹配"为代表的真实失败静默化为 NOT_EVALUATED,且在摘要、持久化与优化器门禁间产生 "passed/NOT_EVALUATED/failed" 三处不一致,属于高置信的可达正确性问题,建议修复后合入。

发现的问题

严重

trpc_agent_sdk/evaluation/_rouge_evaluator.py:142-143

问题: 新守卫把"实际无任何可配对 turn"(actual_invocations=[] 或 expected_invocations=[])从原先的 statistics.StatisticsError 崩溃(会被 _local_eval_service.py:379 / _remote_eval_service.py:377 的兜底捕获并写入 case_error_message + log_error)变成静默返回 EvaluationResult(),EvalCaseResult.error_message 保持 None。而服务层对推理失败的 case 并不短路:_perform_inference_single_eval_item 捕获异常后仅标记 InferenceStatus.FAILURE 仍继续评估(_local_eval_service.py:653-662),actual_invocations=inference_result.inferences or [] 即为空列表,直接命中新守卫。

触发条件: 非 trace 模式下 agent 推理内部抛异常(无任何输出 turn),或配置数据导致 expected 侧为空,用 response_match_score 评估。

实际影响: 结果从"记录 error_message + 日志报错"变为无任何诊断的 NOT_EVALUATED,与"本来就没有可评估数据"完全不可区分;依赖 error_message 排查"评估未真正执行"的运维与下游处理全部失效,推理故障被静默掩盖。

修正方向: 守卫前区分"两侧均为空"与"仅一侧为空/长度不等":后者应记录诊断(如向 EvaluationResult 携带 reason 或让服务层在 per_invocation 为空且 inferences 为空时写入 case_error_message),或至少对单侧空/长度不匹配抛出明确异常,避免静默吞掉数据不匹配。

中等

trpc_agent_sdk/evaluation/_rouge_evaluator.py:142-143

问题: zip(actual_invocations, expected_invocations) 对任意长度不等都静默截断到较短列表;新守卫只把"任一列表为空"转成静默 NOT_EVALUATED,却没有为"单侧为空"和"两侧均非空但长度不等"补充任何校验或诊断,使配对不匹配在除空列表外的所有边界上依旧无信号。

触发条件: actual 与 expected 长度不等(如 agent 多生成/少生成一个 turn,或 scenario-1 的 conversation 与 actual_conversation 长度不一致)。

实际影响: 多余 turn 被静默丢弃,_local_eval_service.py:418-422 按索引拼装 per-invocation 结果时产生伪造的 NOT_EVALUATED 占位行(score=None),数据不匹配与"真实未评估"无法区分;对比本次变更把空列表场景显式设为非失败语义,同一数据形状仅因长度差异得到"部分评分"或"失败"的不同待遇,行为不一致。

修正方向: 在守卫前显式校验 len(actual_invocations) == len(expected_invocations),两侧均非空但不相等时抛 ValueError(或记录明确原因),并为本场景补充单侧空与长度不等的测试。

中等

trpc_agent_sdk/evaluation/_rouge_evaluator.py:142-143

问题: 该守卫使零 turn 场景不再经过异常路径,但下游多个门禁并未把 NOT_EVALUATED 当失败处理却也不放过它,语义互相矛盾:_utils.build_summary 对唯一 metric 为 NOT_EVALUATED 的 case 保持 case_passed=True 并输出 case_overall="passed"(_utils.py:119-137);process_metrics_and_get_failures 因 per-invocation 记录为空直接 continue,不触发 _EvaluationCasesFailed;而 _optimize_evaluator_call.summarize_outcome 把 NOT_EVALUATED 计入 failed_case_ids 并拉低 pass_rate(_optimize_evaluator_call.py:59-62);_eval_set_results_manager_utils._summarize_overall_from_metric_summaries 则输出 NOT_EVALUATED。

触发条件: 任意 case 的 agent 产生 0 个可配对 turn(推理失败或空会话),且配置中包含 response_match_score。

实际影响: 同一运行在终端摘要显示 case "passed"、持久化 .evalset_result.json 显示 NOT_EVALUATED、优化器将其计为失败并对其优化——依赖这些门禁的 CI/优化循环(含 pass@k 计数在 _agent_evaluator._nc_from_set 中把 NOT_EVALUATED 计为失败 run)得到互相冲突的信号,静默破坏评估结论与优化决策。

修正方向: 在服务层或结果聚合层统一定义 NOT_EVALUATED 的处理:要么让 build_summary/_nc_from_set 将 NOT_EVALUATED 视为需报警状态(不判 passed、不计入 pass 统计并注明原因),要么在优化器与门禁中显式跳过/标注零数据 case,保证终端、持久化与优化器三处语义一致。

中等

tests/evaluation/test_rouge_evaluator.py:55-61

问题: 测试只覆盖对称空输入 evaluate_invocations([], []),未覆盖守卫真实生效且最易掩盖问题的两类输入:单侧为空(actual=[] 且有 expected turn,即推理失败场景)和长度不等(zip 截断)。这与提交意图"no turns are paired"的两种不对称边界相悖,且没有断言单侧空应报错、告警还是 NOT_EVALUATED,等于把"静默吞掉"固化为回归保护。

触发条件: 未来修复单侧空/长度不等语义时,现有测试无法发现行为回归(当前测试在两种情况发生时依然通过)。

实际影响: 数据不匹配被静默 NOT_EVALUATED 掩盖的行为成为唯一被测试锁定的预期,测试覆盖缺口使本次变更引入的诊断丢失问题无法在 CI 中被发现。

修正方向: 增加 ([inv], [])、([], [inv])、长度不等(如 3 vs 1)的用例,明确各场景期望的报错或带原因的 NOT_EVALUATED,并补充一条对 final_response=None 单侧缺响应的断言以对齐 0.0-fail 与 NOT_EVALUATED 的语义。

较低

tests/evaluation/test_rouge_evaluator.py:55-57

问题: skip_if_no_rouge 夹具的 skip 语义被模块顶层 from trpc_agent_sdk.evaluation import RougeEvaluator(第 15 行)破坏:RougeEvaluator.__init__ 在缺库时抛 ImportError,但夹具只能拦截测试函数体内的构造;rouge-score 缺失时模块导入本身即失败,整个测试文件变成收集期错误而非按注释意图 skip。

触发条件: 运行环境未安装 rouge-score(依赖为非强制安装)。

实际影响: 测试套件在该环境下报收集错误而不是可控跳过,且本应"跳过"的 test_empty_invocations_are_not_evaluated 事实上在缺库环境下根无法运行,夹具注释与实际行为不符;同时该测试即使没有 rouge 也确实不需要它(早退发生在评分之前),是一种误导性保护。

修正方向: 改用 pytest.importorskip("rouge_score") 置于模块级或夹具内,或移除夹具并让测试文件在缺库时显式 skip 模块,使"缺库时跳过"的意图真实生效。

Comment on lines +142 to +143
if not per_invocation_results:
return EvaluationResult()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

问题: 新守卫把"实际无任何可配对 turn"(actual_invocations=[] 或 expected_invocations=[])从原先的 statistics.StatisticsError 崩溃(会被 _local_eval_service.py:379 / _remote_eval_service.py:377 的兜底捕获并写入 case_error_message + log_error)变成静默返回 EvaluationResult(),EvalCaseResult.error_message 保持 None。而服务层对推理失败的 case 并不短路:_perform_inference_single_eval_item 捕获异常后仅标记 InferenceStatus.FAILURE 仍继续评估(_local_eval_service.py:653-662),actual_invocations=inference_result.inferences or [] 即为空列表,直接命中新守卫。

触发条件: 非 trace 模式下 agent 推理内部抛异常(无任何输出 turn),或配置数据导致 expected 侧为空,用 response_match_score 评估。

实际影响: 结果从"记录 error_message + 日志报错"变为无任何诊断的 NOT_EVALUATED,与"本来就没有可评估数据"完全不可区分;依赖 error_message 排查"评估未真正执行"的运维与下游处理全部失效,推理故障被静默掩盖。

修正方向: 守卫前区分"两侧均为空"与"仅一侧为空/长度不等":后者应记录诊断(如向 EvaluationResult 携带 reason 或让服务层在 per_invocation 为空且 inferences 为空时写入 case_error_message),或至少对单侧空/长度不匹配抛出明确异常,避免静默吞掉数据不匹配。

Comment on lines +142 to +143
if not per_invocation_results:
return EvaluationResult()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

问题: zip(actual_invocations, expected_invocations) 对任意长度不等都静默截断到较短列表;新守卫只把"任一列表为空"转成静默 NOT_EVALUATED,却没有为"单侧为空"和"两侧均非空但长度不等"补充任何校验或诊断,使配对不匹配在除空列表外的所有边界上依旧无信号。

触发条件: actual 与 expected 长度不等(如 agent 多生成/少生成一个 turn,或 scenario-1 的 conversation 与 actual_conversation 长度不一致)。

实际影响: 多余 turn 被静默丢弃,_local_eval_service.py:418-422 按索引拼装 per-invocation 结果时产生伪造的 NOT_EVALUATED 占位行(score=None),数据不匹配与"真实未评估"无法区分;对比本次变更把空列表场景显式设为非失败语义,同一数据形状仅因长度差异得到"部分评分"或"失败"的不同待遇,行为不一致。

修正方向: 在守卫前显式校验 len(actual_invocations) == len(expected_invocations),两侧均非空但不相等时抛 ValueError(或记录明确原因),并为本场景补充单侧空与长度不等的测试。

Comment on lines +142 to +143
if not per_invocation_results:
return EvaluationResult()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

问题: 该守卫使零 turn 场景不再经过异常路径,但下游多个门禁并未把 NOT_EVALUATED 当失败处理却也不放过它,语义互相矛盾:_utils.build_summary 对唯一 metric 为 NOT_EVALUATED 的 case 保持 case_passed=True 并输出 case_overall="passed"(_utils.py:119-137);process_metrics_and_get_failures 因 per-invocation 记录为空直接 continue,不触发 _EvaluationCasesFailed;而 _optimize_evaluator_call.summarize_outcome 把 NOT_EVALUATED 计入 failed_case_ids 并拉低 pass_rate(_optimize_evaluator_call.py:59-62);_eval_set_results_manager_utils._summarize_overall_from_metric_summaries 则输出 NOT_EVALUATED。

触发条件: 任意 case 的 agent 产生 0 个可配对 turn(推理失败或空会话),且配置中包含 response_match_score。

实际影响: 同一运行在终端摘要显示 case "passed"、持久化 .evalset_result.json 显示 NOT_EVALUATED、优化器将其计为失败并对其优化——依赖这些门禁的 CI/优化循环(含 pass@k 计数在 _agent_evaluator._nc_from_set 中把 NOT_EVALUATED 计为失败 run)得到互相冲突的信号,静默破坏评估结论与优化决策。

修正方向: 在服务层或结果聚合层统一定义 NOT_EVALUATED 的处理:要么让 build_summary/_nc_from_set 将 NOT_EVALUATED 视为需报警状态(不判 passed、不计入 pass 统计并注明原因),要么在优化器与门禁中显式跳过/标注零数据 case,保证终端、持久化与优化器三处语义一致。

Comment on lines +55 to +61
def test_empty_invocations_are_not_evaluated(self, skip_if_no_rouge):
metric = EvalMetric(metric_name=PrebuiltMetrics.RESPONSE_MATCH_SCORE.value, threshold=0.8)
result = RougeEvaluator(eval_metric=metric).evaluate_invocations([], [])

assert result.overall_eval_status == EvalStatus.NOT_EVALUATED
assert result.overall_score is None
assert result.per_invocation_results == []

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

问题: 测试只覆盖对称空输入 evaluate_invocations([], []),未覆盖守卫真实生效且最易掩盖问题的两类输入:单侧为空(actual=[] 且有 expected turn,即推理失败场景)和长度不等(zip 截断)。这与提交意图"no turns are paired"的两种不对称边界相悖,且没有断言单侧空应报错、告警还是 NOT_EVALUATED,等于把"静默吞掉"固化为回归保护。

触发条件: 未来修复单侧空/长度不等语义时,现有测试无法发现行为回归(当前测试在两种情况发生时依然通过)。

实际影响: 数据不匹配被静默 NOT_EVALUATED 掩盖的行为成为唯一被测试锁定的预期,测试覆盖缺口使本次变更引入的诊断丢失问题无法在 CI 中被发现。

修正方向: 增加 ([inv], [])、([], [inv])、长度不等(如 3 vs 1)的用例,明确各场景期望的报错或带原因的 NOT_EVALUATED,并补充一条对 final_response=None 单侧缺响应的断言以对齐 0.0-fail 与 NOT_EVALUATED 的语义。

Comment on lines +55 to +57
def test_empty_invocations_are_not_evaluated(self, skip_if_no_rouge):
metric = EvalMetric(metric_name=PrebuiltMetrics.RESPONSE_MATCH_SCORE.value, threshold=0.8)
result = RougeEvaluator(eval_metric=metric).evaluate_invocations([], [])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

问题: skip_if_no_rouge 夹具的 skip 语义被模块顶层 from trpc_agent_sdk.evaluation import RougeEvaluator(第 15 行)破坏:RougeEvaluator.__init__ 在缺库时抛 ImportError,但夹具只能拦截测试函数体内的构造;rouge-score 缺失时模块导入本身即失败,整个测试文件变成收集期错误而非按注释意图 skip。

触发条件: 运行环境未安装 rouge-score(依赖为非强制安装)。

实际影响: 测试套件在该环境下报收集错误而不是可控跳过,且本应"跳过"的 test_empty_invocations_are_not_evaluated 事实上在缺库环境下根无法运行,夹具注释与实际行为不符;同时该测试即使没有 rouge 也确实不需要它(早退发生在评分之前),是一种误导性保护。

修正方向: 改用 pytest.importorskip("rouge_score") 置于模块级或夹具内,或移除夹具并让测试文件在缺库时显式 skip 模块,使"缺库时跳过"的意图真实生效。

@helloopenworld

Copy link
Copy Markdown
Contributor

AI Code Review

审查结论

不通过

本次审查覆盖 base_commit 1590e17..head_commit d6889dc 的全部 2 个变更文件(trpc_agent_sdk/evaluation/_rouge_evaluator.py 与 tests/evaluation/test_rouge_evaluator.py),包括两个子提交(2bc5003 双空返回、d6889dc 单边空抛错)。计划要求:无轮次配对时返回未评估的 ROUGE 结果。实现已达成该目标,但存在三个由本次变更引入或使其变得显著的问题:一是双空返回 EvaluationResult() 而对"单边为空"抛 ValueError 与两个同系评估器(_final_response_evaluator.py、_trajectory_evaluator.py 对空输入均静默返回 NOT_EVALUATED)不一致,单边为空在本地/远程评估服务中会被 except Exception 捕获并写入 case.error_message,使 _summarize_overall_from_metric_summaries 把整个 case 判定为运行错误;二是新守卫只区分"空/非空",并未覆盖两侧均为非空但长度不等的输入,zip 静默截断导致 ROUGE 分数被高估且无任何告警;三是 ([], None) 形状(None 与 [] 语义等价于"无轮次配对")仍走 expected_invocations is required 报错分支,与提交标题宣称的"无轮次配对返回未评估"相矛盾,且本地与远程两个服务对该形状的处理自始就不一致。测试方面:新增测试覆盖了双空与 (0,1)/(1,0) 单边空场景,但未覆盖长度不等(1 vs 2 等)的非空截断场景,也未覆盖 expected=None 场景。测试断言 result.per_invocation_results == []。总体结论:核心意图已实现,测试对新增分支有基本覆盖,但单边空抛错导致的服务级 case 判定为错误、长度不等静默截断、[]/None 二义性三个问题需要修复,故门禁判定为 FAILED(存在 SEVERE 级问题)。

发现的问题

严重

trpc_agent_sdk/evaluation/_rouge_evaluator.py:125-129

问题: 新增守卫只处理了"双空"与"单边空"两个极端情形,对两侧均非空但长度不等(如 actual=2、expected=3)的输入不做任何检查,后续 for actual, expected in zip(actual_invocations, expected_invocations)(第 133 行)会静默截断到较短一侧,statistics.mean 只对截断后的配对求均值,长度差异被完全掩盖。

触发条件: trace 场景或会话长短不齐时,例如本地评估中 eval_case.conversation 有 3 个期望轮次、agent 实际只产出 2 轮(提前终止、工具超时等),或反向 actual 多于 expected;此时 _validate_metric_compat 只看"是否有参考答案",不会拦截这种情况。

实际影响: 第 3 轮期望答案从未参与评分,每个实际轮次仍与正确的前 2 轮比对,ROUGE 总分(对较短列表求均值)系统性偏高;被丢弃的轮次在 per_invocation_results、结果汇总中完全无痕,用户得到虚高的得分且无任何告警,评估门禁可能错误放行。

修正方向: 在 zip 前增加 if len(actual_invocations) != len(expected_invocations): raise ValueError(...)(或返回带 NOT_EVALUATED 状态的结果并在结果中记录长度差异),并补充 actual=2/expected=3 等非空长度不等的回归测试,使长度不匹配与"空输入"一样显式可见。

严重

trpc_agent_sdk/evaluation/_rouge_evaluator.py:127-129

问题: 对"单边为空"抛 ValueError 与同系内置评估器契约不一致:_final_response_evaluator.py(evaluate_invocations 空列表时返回空 EvaluationResult())与 _trajectory_evaluator.py 对空输入均静默返回 NOT_EVALUATED,只有 RougeEvaluator 抛异常;而本地/远程评估服务的 _evaluate_metric 调用外包裹 except Exception,会把该 ValueError 写入 case.error_message 并整 case 降级为 NOT_EVALUATED。

触发条件: 非 trace 模式下 eval_case.conversation 为空而配置了 response_match_score 指标,且 agent 实际产生 0 轮(inference_result.inferences or [] 为空);或 trace 场景-3 占位期望与空实际组合时。此前版本该输入以 StatisticsError 在服务层被同样兜底,属既有错误路径;本次变更将"双空"改为安静返回后,"单边空"成为新引入的显式异常分支,且与姊妹评估器在新输入下的行为直接对立。

实际影响: 同样的"无轮次可评"输入,用 final_response_avg_score/tool_trajectory_avg_score 是 NOT_EVALUATED,用 response_match_score 则整 case 带 error_message;_eval_set_results_manager_utils._summarize_overall_from_metric_summaries 在 has_run_error=True 时把 case 汇总为 FAILED,用户看到的是"评估失败"而非"未评估",语义反转且误导 CI 门禁。

修正方向: 与姊妹评估器对齐:单边为空时返回 EvaluationResult(overall_eval_status=EvalStatus.NOT_EVALUATED)(可在消息中通过日志保留诊断,而不是抛异常),或在 _validate_metric_compat 的 fail-fast 配置校验层处理该不兼容组合,使空输入在两类服务中表现一致。

中等

trpc_agent_sdk/evaluation/_rouge_evaluator.py:122-128

问题: expected_invocations 为 None 与为 [] 在语义上都表示"无期望轮次配对",但新守卫只对 [] 生效:([], None) 仍命中第 122-123 行 expected_invocations is required 分支,与提交意图("无轮次配对返回未评估结果")相矛盾。

触发条件: 两个内置评估服务均通过 eval_case.conversation 构造期望列表:_local_eval_service._build_expected_invocations_for_eval 和 _remote_eval_service._build_expected_invocations_for_eval 在 conversation 为空时返回 None 而非 [];因此空 conversation 且空 inferences 的 case,本地服务走 (actual=[], expected=None) 直接命中 expected_invocations is required 报错分支,远端服务同样如此。

实际影响: 提交标题承诺的"无轮次配对 → 未评估结果"在真实服务调用路径上无法实现——空 case 仍以 ValueError/error_message 形式呈现;且 [] 与 None 两种同等空输入产生完全不同(且自相矛盾)的结果,直接调用方和测试都极易踩到该分支差异。

修正方向: 将空判定统一为 if not expected_invocations:(None 与 [] 一并视为空),双空返回 EvaluationResult()、单边空按对齐后的策略处理;并补充 evaluate_invocations([], None) 的显式测试用例。

Comment on lines +125 to +129
if not actual_invocations and not expected_invocations:
return EvaluationResult()
if not actual_invocations or not expected_invocations:
raise ValueError("ROUGE requires invocations on both sides "
f"(actual={len(actual_invocations)}, expected={len(expected_invocations)})")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

问题: 新增守卫只处理了"双空"与"单边空"两个极端情形,对两侧均非空但长度不等(如 actual=2、expected=3)的输入不做任何检查,后续 for actual, expected in zip(actual_invocations, expected_invocations)(第 133 行)会静默截断到较短一侧,statistics.mean 只对截断后的配对求均值,长度差异被完全掩盖。

触发条件: trace 场景或会话长短不齐时,例如本地评估中 eval_case.conversation 有 3 个期望轮次、agent 实际只产出 2 轮(提前终止、工具超时等),或反向 actual 多于 expected;此时 _validate_metric_compat 只看"是否有参考答案",不会拦截这种情况。

实际影响: 第 3 轮期望答案从未参与评分,每个实际轮次仍与正确的前 2 轮比对,ROUGE 总分(对较短列表求均值)系统性偏高;被丢弃的轮次在 per_invocation_results、结果汇总中完全无痕,用户得到虚高的得分且无任何告警,评估门禁可能错误放行。

修正方向: 在 zip 前增加 if len(actual_invocations) != len(expected_invocations): raise ValueError(...)(或返回带 NOT_EVALUATED 状态的结果并在结果中记录长度差异),并补充 actual=2/expected=3 等非空长度不等的回归测试,使长度不匹配与"空输入"一样显式可见。

Comment on lines +127 to +129
if not actual_invocations or not expected_invocations:
raise ValueError("ROUGE requires invocations on both sides "
f"(actual={len(actual_invocations)}, expected={len(expected_invocations)})")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

问题: 对"单边为空"抛 ValueError 与同系内置评估器契约不一致:_final_response_evaluator.py(evaluate_invocations 空列表时返回空 EvaluationResult())与 _trajectory_evaluator.py 对空输入均静默返回 NOT_EVALUATED,只有 RougeEvaluator 抛异常;而本地/远程评估服务的 _evaluate_metric 调用外包裹 except Exception,会把该 ValueError 写入 case.error_message 并整 case 降级为 NOT_EVALUATED。

触发条件: 非 trace 模式下 eval_case.conversation 为空而配置了 response_match_score 指标,且 agent 实际产生 0 轮(inference_result.inferences or [] 为空);或 trace 场景-3 占位期望与空实际组合时。此前版本该输入以 StatisticsError 在服务层被同样兜底,属既有错误路径;本次变更将"双空"改为安静返回后,"单边空"成为新引入的显式异常分支,且与姊妹评估器在新输入下的行为直接对立。

实际影响: 同样的"无轮次可评"输入,用 final_response_avg_score/tool_trajectory_avg_score 是 NOT_EVALUATED,用 response_match_score 则整 case 带 error_message;_eval_set_results_manager_utils._summarize_overall_from_metric_summaries 在 has_run_error=True 时把 case 汇总为 FAILED,用户看到的是"评估失败"而非"未评估",语义反转且误导 CI 门禁。

修正方向: 与姊妹评估器对齐:单边为空时返回 EvaluationResult(overall_eval_status=EvalStatus.NOT_EVALUATED)(可在消息中通过日志保留诊断,而不是抛异常),或在 _validate_metric_compat 的 fail-fast 配置校验层处理该不兼容组合,使空输入在两类服务中表现一致。

Comment on lines 122 to +128
if expected_invocations is None:
raise ValueError("expected_invocations is required for Rouge evaluation")

if not actual_invocations and not expected_invocations:
return EvaluationResult()
if not actual_invocations or not expected_invocations:
raise ValueError("ROUGE requires invocations on both sides "

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

问题: expected_invocations 为 None 与为 [] 在语义上都表示"无期望轮次配对",但新守卫只对 [] 生效:([], None) 仍命中第 122-123 行 expected_invocations is required 分支,与提交意图("无轮次配对返回未评估结果")相矛盾。

触发条件: 两个内置评估服务均通过 eval_case.conversation 构造期望列表:_local_eval_service._build_expected_invocations_for_eval 和 _remote_eval_service._build_expected_invocations_for_eval 在 conversation 为空时返回 None 而非 [];因此空 conversation 且空 inferences 的 case,本地服务走 (actual=[], expected=None) 直接命中 expected_invocations is required 报错分支,远端服务同样如此。

实际影响: 提交标题承诺的"无轮次配对 → 未评估结果"在真实服务调用路径上无法实现——空 case 仍以 ValueError/error_message 形式呈现;且 [] 与 None 两种同等空输入产生完全不同(且自相矛盾)的结果,直接调用方和测试都极易踩到该分支差异。

修正方向: 将空判定统一为 if not expected_invocations:(None 与 [] 一并视为空),双空返回 EvaluationResult()、单边空按对齐后的策略处理;并补充 evaluate_invocations([], None) 的显式测试用例。

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants