AgentEvalTool/tests/unit
sinohqb c4962ddadf fix(llm_score): 修复多轮用例 question 提取错位导致普遍打 0 分
## 现象
多轮/动态用例的 llm_score 规则几乎全部返回 0.0/10 失败,即便被测对象
回复质量很高(实测 400+ 字的专业医疗回复也是 0 分)。

## 根因
evaluate() 里 question 提取逻辑错误:
    if len(dialog) >= 2:
        question_text = extract_reply_text(dialog[-2].reply)  # BUG
dialog[-2].reply 是「上一轮智能体的回复」,被误当成「用户问题」。于是评分
LLM 收到的问答对是:
  - "用户问题" = 上一轮 AI 回复
  - "智能体回复" = 当前轮 AI 回复
两段都是 AI 说的话、互不相关,评分 LLM 判定牛头不对马嘴 → 打 0 分。

单轮用例因 len(dialog)<2 走 sent_message 提取(正确),故不受影响;
问题只在多轮/dynamic 用例爆发。

## 修复
- question 始终取当前轮 last_turn.sent_message(用户实际发送的问题),
  移除错误的 dialog[-2].reply 分支
- reason 增加评分 LLM 自己的理由(parsed["reason"]),便于未来诊断
- 新增回归测试:多轮场景验证 question 来自 last sent_message 而非 prev reply

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-17 16:15:07 +08:00
..
__init__.py v0.2.0-dev: 文件管理 + 页面布局统一 + 6 个 bug 修复 2026-07-16 15:25:22 +08:00
mock_channel.py v0.2.0-dev: 文件管理 + 页面布局统一 + 6 个 bug 修复 2026-07-16 15:25:22 +08:00
test_cascade.py v0.2.0-dev: 文件管理 + 页面布局统一 + 6 个 bug 修复 2026-07-16 15:25:22 +08:00
test_engine.py v0.2.0-dev: 文件管理 + 页面布局统一 + 6 个 bug 修复 2026-07-16 15:25:22 +08:00
test_file_repository.py v0.4-t1t2: 测试覆盖率 62%→77% + UTC 时区根本修复 2026-07-17 14:19:16 +08:00
test_http_channel_and_rules.py v0.4-t3t4: OpenClaw 通道 + 前端 bundle 优化 2026-07-17 15:37:14 +08:00
test_llm_score.py fix(llm_score): 修复多轮用例 question 提取错位导致普遍打 0 分 2026-07-17 16:15:07 +08:00
test_report.py v0.4-t1t2: 测试覆盖率 62%→77% + UTC 时区根本修复 2026-07-17 14:19:16 +08:00
test_s2_rules_and_logic.py v0.3-s2: 3 个新规则 + 组合逻辑 + 33 个测试 2026-07-17 11:23:22 +08:00
test_scenarios.py v0.4-t1t2: 测试覆盖率 62%→77% + UTC 时区根本修复 2026-07-17 14:19:16 +08:00
test_settings.py v0.2.0-dev: 文件管理 + 页面布局统一 + 6 个 bug 修复 2026-07-16 15:25:22 +08:00
test_utils_llm.py v0.4-t1t2: 测试覆盖率 62%→77% + UTC 时区根本修复 2026-07-17 14:19:16 +08:00
test_webhook.py v0.4-t1t2: 测试覆盖率 62%→77% + UTC 时区根本修复 2026-07-17 14:19:16 +08:00