python-yama 0.6.0__tar.gz → 0.7.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. {python_yama-0.6.0 → python_yama-0.7.0}/PKG-INFO +3 -4
  2. {python_yama-0.6.0 → python_yama-0.7.0}/README.md +2 -3
  3. {python_yama-0.6.0 → python_yama-0.7.0}/README.zh-CN.md +2 -3
  4. {python_yama-0.6.0 → python_yama-0.7.0}/docs/agent-skill-test-framework-design.md +116 -57
  5. {python_yama-0.6.0 → python_yama-0.7.0}/docs/case-schema-reference.md +34 -24
  6. {python_yama-0.6.0 → python_yama-0.7.0}/skills/eval-plugin-with-yama/SKILL.md +66 -87
  7. {python_yama-0.6.0 → python_yama-0.7.0}/skills/eval-plugin-with-yama/references/case-schema.md +46 -15
  8. {python_yama-0.6.0 → python_yama-0.7.0}/skills/eval-plugin-with-yama/references/debugging.md +50 -23
  9. python_yama-0.7.0/skills/eval-plugin-with-yama/references/install-upgrade.md +84 -0
  10. {python_yama-0.6.0 → python_yama-0.7.0}/tests/test_cli.py +116 -0
  11. {python_yama-0.6.0 → python_yama-0.7.0}/tests/test_preview.py +1 -1
  12. {python_yama-0.6.0 → python_yama-0.7.0}/tests/test_report.py +226 -28
  13. python_yama-0.7.0/tests/test_runner.py +618 -0
  14. {python_yama-0.6.0 → python_yama-0.7.0}/tests/test_thread_case.py +1 -1
  15. {python_yama-0.6.0 → python_yama-0.7.0}/yama/cli.py +115 -21
  16. {python_yama-0.6.0 → python_yama-0.7.0}/yama/models.py +2 -0
  17. {python_yama-0.6.0 → python_yama-0.7.0}/yama/report.py +192 -62
  18. {python_yama-0.6.0 → python_yama-0.7.0}/yama/runner.py +159 -18
  19. {python_yama-0.6.0 → python_yama-0.7.0}/yama/thread_case.py +3 -1
  20. python_yama-0.6.0/tests/test_runner.py +0 -325
  21. {python_yama-0.6.0 → python_yama-0.7.0}/.github/workflows/publish.yml +0 -0
  22. {python_yama-0.6.0 → python_yama-0.7.0}/.gitignore +0 -0
  23. {python_yama-0.6.0 → python_yama-0.7.0}/CLAUDE.md +0 -0
  24. {python_yama-0.6.0 → python_yama-0.7.0}/LICENSE +0 -0
  25. {python_yama-0.6.0 → python_yama-0.7.0}/docs/yama-intro.html +0 -0
  26. {python_yama-0.6.0 → python_yama-0.7.0}/pyproject.toml +0 -0
  27. {python_yama-0.6.0 → python_yama-0.7.0}/tests/test_assertions.py +0 -0
  28. {python_yama-0.6.0 → python_yama-0.7.0}/tests/test_cli_shim.py +0 -0
  29. {python_yama-0.6.0 → python_yama-0.7.0}/tests/test_dashboard.py +0 -0
  30. {python_yama-0.6.0 → python_yama-0.7.0}/tests/test_framework.py +0 -0
  31. {python_yama-0.6.0 → python_yama-0.7.0}/tests/test_llm.py +0 -0
  32. {python_yama-0.6.0 → python_yama-0.7.0}/tests/test_main_entrypoint.py +0 -0
  33. {python_yama-0.6.0 → python_yama-0.7.0}/tests/test_mocks.py +0 -0
  34. {python_yama-0.6.0 → python_yama-0.7.0}/tests/test_public_api.py +0 -0
  35. {python_yama-0.6.0 → python_yama-0.7.0}/tests/test_run_plan.py +0 -0
  36. {python_yama-0.6.0 → python_yama-0.7.0}/tests/test_skill_tool.py +0 -0
  37. {python_yama-0.6.0 → python_yama-0.7.0}/tests/test_tool_loader.py +0 -0
  38. {python_yama-0.6.0 → python_yama-0.7.0}/tests/test_usage.py +0 -0
  39. {python_yama-0.6.0 → python_yama-0.7.0}/tests/test_workspace.py +0 -0
  40. {python_yama-0.6.0 → python_yama-0.7.0}/uv.lock +0 -0
  41. {python_yama-0.6.0 → python_yama-0.7.0}/yama/__init__.py +0 -0
  42. {python_yama-0.6.0 → python_yama-0.7.0}/yama/__main__.py +0 -0
  43. {python_yama-0.6.0 → python_yama-0.7.0}/yama/assertions.py +0 -0
  44. {python_yama-0.6.0 → python_yama-0.7.0}/yama/dashboard.py +0 -0
  45. {python_yama-0.6.0 → python_yama-0.7.0}/yama/llm.py +0 -0
  46. {python_yama-0.6.0 → python_yama-0.7.0}/yama/loaders/__init__.py +0 -0
  47. {python_yama-0.6.0 → python_yama-0.7.0}/yama/loaders/case.py +0 -0
  48. {python_yama-0.6.0 → python_yama-0.7.0}/yama/loaders/common.py +0 -0
  49. {python_yama-0.6.0 → python_yama-0.7.0}/yama/loaders/tool_loader.py +0 -0
  50. {python_yama-0.6.0 → python_yama-0.7.0}/yama/mocks.py +0 -0
  51. {python_yama-0.6.0 → python_yama-0.7.0}/yama/preview.py +0 -0
  52. {python_yama-0.6.0 → python_yama-0.7.0}/yama/tools/__init__.py +0 -0
  53. {python_yama-0.6.0 → python_yama-0.7.0}/yama/tools/base.py +0 -0
  54. {python_yama-0.6.0 → python_yama-0.7.0}/yama/tools/bash/__init__.py +0 -0
  55. {python_yama-0.6.0 → python_yama-0.7.0}/yama/tools/bash/_cli_shim.py +0 -0
  56. {python_yama-0.6.0 → python_yama-0.7.0}/yama/tools/bash/bash.py +0 -0
  57. {python_yama-0.6.0 → python_yama-0.7.0}/yama/tools/bash/fs.py +0 -0
  58. {python_yama-0.6.0 → python_yama-0.7.0}/yama/tools/skill/__init__.py +0 -0
  59. {python_yama-0.6.0 → python_yama-0.7.0}/yama/tools/skill/skill.py +0 -0
  60. {python_yama-0.6.0 → python_yama-0.7.0}/yama/workspace.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-yama
3
- Version: 0.6.0
3
+ Version: 0.7.0
4
4
  Summary: A reproducible evaluation runner for tool-using Agent skills
5
5
  Project-URL: Repository, https://github.com/world-sim-dev/yama
6
6
  Project-URL: Issues, https://github.com/world-sim-dev/yama/issues
@@ -72,15 +72,14 @@ steps:
72
72
  - assistant_contains: creative direction
73
73
 
74
74
  outcome:
75
- require:
76
- hard_checks: all_pass
75
+ require: {}
77
76
  ```
78
77
 
79
78
  - `description` (optional) is a one-line summary of what the Case tests; it is shown in the CLI output and the HTML report.
80
79
  - `context.tools` is the tool schema sent to the model; `mocks.tools` is how the runner responds when a tool call arrives. The two sets of tool names must match exactly.
81
80
  - To use a Skill, declare it by name under `context.skills` and also declare `{builtin: skill}` under `context.tools`; the model reads the Skill body via `skill(name, file?, call_reason?)`.
82
81
  - To simulate command-line tools, declare `{builtin: bash}` and configure per-command output under `mocks.cli`.
83
- - `steps[].assert.hard` are deterministic checks (nine types, including `tool_called`, `tool_arguments`, and `assistant_contains`); add `assert.judge` for LLM scoring.
82
+ - `steps[].assert.hard` are deterministic checks (nine types, including `tool_called`, `tool_arguments`, and `assistant_contains`); untagged hard checks must all pass by default. Add `assert.judge` for LLM scoring.
84
83
 
85
84
  For the full schema (every Skill/tool/mock form, the `bash` sandbox, message injection, judge configuration, and more), see the [design doc](https://github.com/world-sim-dev/yama/blob/main/docs/agent-skill-test-framework-design.md) (Chinese).
86
85
 
@@ -46,15 +46,14 @@ steps:
46
46
  - assistant_contains: creative direction
47
47
 
48
48
  outcome:
49
- require:
50
- hard_checks: all_pass
49
+ require: {}
51
50
  ```
52
51
 
53
52
  - `description` (optional) is a one-line summary of what the Case tests; it is shown in the CLI output and the HTML report.
54
53
  - `context.tools` is the tool schema sent to the model; `mocks.tools` is how the runner responds when a tool call arrives. The two sets of tool names must match exactly.
55
54
  - To use a Skill, declare it by name under `context.skills` and also declare `{builtin: skill}` under `context.tools`; the model reads the Skill body via `skill(name, file?, call_reason?)`.
56
55
  - To simulate command-line tools, declare `{builtin: bash}` and configure per-command output under `mocks.cli`.
57
- - `steps[].assert.hard` are deterministic checks (nine types, including `tool_called`, `tool_arguments`, and `assistant_contains`); add `assert.judge` for LLM scoring.
56
+ - `steps[].assert.hard` are deterministic checks (nine types, including `tool_called`, `tool_arguments`, and `assistant_contains`); untagged hard checks must all pass by default. Add `assert.judge` for LLM scoring.
58
57
 
59
58
  For the full schema (every Skill/tool/mock form, the `bash` sandbox, message injection, judge configuration, and more), see the [design doc](https://github.com/world-sim-dev/yama/blob/main/docs/agent-skill-test-framework-design.md) (Chinese).
60
59
 
@@ -46,15 +46,14 @@ steps:
46
46
  - assistant_contains: 创意方向
47
47
 
48
48
  outcome:
49
- require:
50
- hard_checks: all_pass
49
+ require: {}
51
50
  ```
52
51
 
53
52
  - `description`(可选)是一句话说明当前 Case 测试什么;会展示在 CLI 输出和 HTML 报告中。
54
53
  - `context.tools` 是发给模型的 Tool Schema,`mocks.tools` 是 Runner 收到 Tool Call 后如何返回结果;两者的 Tool 名字集合必须完全一致。
55
54
  - 需要 Skill 时在 `context.skills` 中按名字声明,并在 `context.tools` 中同时声明 `{builtin: skill}`;模型通过 `skill(name, file?, call_reason?)` 读取正文。
56
55
  - 需要模拟命令行工具时声明 `{builtin: bash}`,在 `mocks.cli` 中按命令配置输出。
57
- - `steps[].assert.hard` 是确定性检查(`tool_called`、`tool_arguments`、`assistant_contains` 等九种类型);还可以加 `assert.judge` 做 LLM 打分。
56
+ - `steps[].assert.hard` 是确定性检查(`tool_called`、`tool_arguments`、`assistant_contains` 等九种类型);未打 tag 的 hard check 默认必须全部通过。还可以加 `assert.judge` 做 LLM 打分。
58
57
 
59
58
  完整 Schema(Skill/Tool/Mock 的全部写法、`bash` 沙箱、Message Injection、Judge 配置等)见[设计文档](docs/agent-skill-test-framework-design.md)。
60
59
 
@@ -1160,7 +1160,7 @@ Provider 凭据由 LiteLLM 从其标准环境变量或运行环境读取,不
1160
1160
  }
1161
1161
  ```
1162
1162
 
1163
- `resolved_provider` 是原设计未提及的额外字段(来自 `LLMClient.last_provider`);请求失败时该记录会多一个 `"error": "<ExceptionType>: <message>"` 字段,而不是 `response`。`duration_ms` 由 `runner.py:_run_step` 用 `time.perf_counter()` 环绕 `self.llm.complete` 调用测得(四舍五入到 3 位小数),记录这一轮从发起调用到拿到返回(或抛出异常)的耗时,成功、失败都会写入。执行时间线里每次 assistant 响应的摘要行、以及 run 底部 `LLM requests (N)` 里每条 Request 的摘要行,都会在 token 用量后追加这个耗时(`N ms`,`report.py:_duration_inline`)。时间线里嵌套的 `LLM request` 折叠卡仍然只渲染 `invocation.method` 和 `invocation.arguments`(响应已经在上方的 Assistant text content 里展示,不重复);run 底部 `LLM requests (N)` 列表里的每条 Request 除了同样的 Method / Arguments,还会追加一个 Response 区块——成功时是这一轮模型返回的完整 assistant message(含 `tool_calls`),失败时是报错文本(`report.py:_render_llm_response_details`)。`step_id`、`request_index`、`resolved_provider` 均不伪装成模型调用参数。
1163
+ `resolved_provider` 是原设计未提及的额外字段(来自 `LLMClient.last_provider`);请求失败时该记录会多一个 `"error": "<ExceptionType>: <message>"` 字段,而不是 `response`。`duration_ms` 由 `runner.py:_run_step` 用 `time.perf_counter()` 环绕 `self.llm.complete` 调用测得(四舍五入到 3 位小数),记录这一轮从发起调用到拿到返回(或抛出异常)的耗时,成功、失败都会写入。执行时间线里每次 assistant 响应的摘要行、以及 run 底部 `LLM requests (N)` 里每条 Request 的摘要行,都会展示这个耗时(`N ms`,`report.py:_duration_inline`)。每个 `LLM request` 折叠卡统一渲染 `invocation.method`、单轮 `duration_ms`、`invocation.arguments` 和 `response`;成功时 `response` 是这一轮模型返回的完整 assistant message(含 `tool_calls`),请求失败时该记录改由 `error` 字段说明失败。Run/Case/报告顶部会把全部 tool-loop 请求的 `duration_ms` 相加,作为 LLM Request 总耗时展示;`step_id`、`request_index`、`resolved_provider` 均不伪装成模型调用参数。
1164
1164
 
1165
1165
  Judge 使用的模型写在 `steps[].assert.judge.model` 或全局 Judge 配置中(省略时回退到当前 Case 的 `model`,见 12.2 节)。
1166
1166
 
@@ -1595,8 +1595,11 @@ execution:
1595
1595
  - `timeout_seconds_per_step`:单个 Step 的总时限,默认 **120**。通过
1596
1596
  `asyncio.wait_for` 真实生效(`runner.py:_run_once`),但需要注意:超时触发的是
1597
1597
  `asyncio.TimeoutError`,**没有**被单独捕获转换成"仅本 Step 失败、run 继续"——它
1598
- 会被 `_run_once` 外层的 `except Exception` 当成整条 run 异常失败处理(`RunResult.passed
1599
- = False`,`RunResult.error` 记录异常信息),run 直接终止,不会再跑后续 Step。
1598
+ 会被 `_run_once` 外层的 `except Exception` 当成整条 run 的基础设施异常处理
1599
+ (`RunResult.status = "error"`,`RunResult.passed = False`,`RunResult.error`
1600
+ 记录异常信息),run 直接终止,不会再跑后续 Step。`LLMError`(Provider
1601
+ 请求失败、接口异常、脚本回放耗尽等)同样归为 run/case 的 `error` 状态,而不是
1602
+ hard check/Judge 失败。
1600
1603
  这与下面 `max_tool_rounds_per_step` 超限的处理方式(仅本 Step 记为失败、run 继续
1601
1604
  跑完剩余 Step)不同。
1602
1605
  - `max_tool_rounds_per_step`:一个 Step 内允许的最大 Tool Call 循环轮数,默认 **10**。
@@ -1613,9 +1616,11 @@ execution:
1613
1616
  原样继承,跨供应商切换时如需避免继承需在条目里显式覆盖。
1614
1617
  - `label` 缺省取合并后的模型名;label 是报告/CLI 的分组维度,条目之间必须
1615
1618
  唯一(两个条目共用同一模型名时必须显式给 `label`),否则报错。
1616
- - 总 run 数 = Σ times,`run_index` 跨条目连续递增;`passed`/`pass_rate`
1617
- 语义不变(所有 run 都通过 Case 才算过)。每个 `RunResult` 记录本 run 的
1618
- `label` 与生效 `model`(进 `result.json` 与 `--json` 输出)。
1619
+ - 总 run 数 = Σ times,`run_index` 跨条目连续递增。`status="error"` 的 run
1620
+ 不进入 pass/fail 分母;只要存在非 error 的失败 run,Case 为 `fail`;没有失败
1621
+ 但存在 error run 时,Case 为 `error`;只有所有非 error run 都通过且没有 error
1622
+ 时,Case 才为 `pass`。`pass_rate` 只按非 error run 计算。每个 `RunResult`
1623
+ 记录本 run 的 `label` 与生效 `model`(进 `result.json` 与 `--json` 输出)。
1619
1624
  - 变体模型只作用于被测 Agent 的 Tool Loop;**Judge 的 `default_model`
1620
1625
  固定为 Case 级 `model`**(`judge.model` 仍可显式覆盖),保证不同变体的
1621
1626
  评分口径一致、可对比。
@@ -1704,20 +1709,22 @@ assert:
1704
1709
  断言默认只作用于当前 Step;需要检查最终跨 Step 状态时,使用 Python Checker 或 `outcome` 中的 Case 级要求。`assistant_semantic_count` 的实际语义见 12.1 节——它并非真正的语义理解,而是大小写不敏感的字面子串计数,命名有历史包袱。
1705
1710
 
1706
1711
  `assert.hard` 每条断言还可以带一个可选的 `tag` 平级字段(断言类型 key 之外的
1707
- 另一个 key,同一条断言最多一个 tag),用于在 8.8 节的 `outcome.require.tags`
1708
- 里按 tag 设置不同的通过率容忍度;不打 tag 的断言默认归入 `must_pass`。允许的 tag
1709
- 固定为 `must_pass` / `high_confidence` / `tolerant` / `informational` 四种,写其它
1710
- 值会在运行时报 `AssertionConfigurationError`。
1712
+ 另一个 key,同一条断言最多一个 tag),用于在 8.8 节的
1713
+ `outcome.require.hard_checks.tags` 里按 tag 设置不同的通过率容忍度;不打 tag 的断言
1714
+ 默认归入 `must_pass`。tag 只属于 `assert.hard`,不属于 `assert.judge` 或 Judge 维度。
1715
+ 允许的 tag 固定为 `must_pass` / `high_confidence` / `tolerant` / `informational`
1716
+ 四种,写其它值会在运行时报 `AssertionConfigurationError`。
1711
1717
 
1712
1718
  ### 8.8 `outcome`:整个 Case 的最终门槛
1713
1719
 
1714
1720
  ```yaml
1715
1721
  outcome:
1716
1722
  require:
1717
- tags:
1718
- high_confidence: 0.9
1719
- tolerant: 0.8
1720
- informational: 0.0
1723
+ hard_checks:
1724
+ tags:
1725
+ high_confidence: 0.9
1726
+ tolerant: 0.8
1727
+ informational: 0.0
1721
1728
  judge:
1722
1729
  overall_gte: 0.8
1723
1730
  each_dimension_gte: 0.6
@@ -1725,8 +1732,9 @@ outcome:
1725
1732
 
1726
1733
  判定逻辑由 `runner.py` 里的共享函数 `tag_pass_summary(steps, outcome)` 计算:按每条
1727
1734
  hard check 的固定 tag 分组(未打 tag 的默认归入 `must_pass`),每组算
1728
- `rate = passed / total`,阈值取 `outcome.require.tags` 里对应 tag 的配置值或固定默认
1729
- 值。默认阈值为:`must_pass: 1.0`(固定,不可降低)、`high_confidence: 0.9`、
1735
+ `rate = passed / total`,阈值取 `outcome.require.hard_checks.tags` 里对应 tag 的
1736
+ 配置值或固定默认值(旧版 `outcome.require.tags` 仍兼容读取,但新 Case 不再推荐)。
1737
+ 默认阈值为:`must_pass: 1.0`(固定,不可降低)、`high_confidence: 0.9`、
1730
1738
  `tolerant: 0.8`、`informational: 0.0`。这就是"所有未标注断言都必须通过"这条旧规则
1731
1739
  的等价表述(详见 12.3 节)。`judge.overall_gte`/`judge.each_dimension_gte` 仍是真实
1732
1740
  读取的配置键。Judge 门槛只决定质量是否达标,不会把协议错误变成通过。
@@ -1945,7 +1953,8 @@ class MockToolRegistry:
1945
1953
 
1946
1954
  1. 未声明的工具名(不在构造期传入的 `mocks.tools` 里)直接抛出
1947
1955
  `MockInvocationError("tool has no mock handler: <name>")`——这是一个**未捕获**
1948
- 异常,会让整条 run 立刻失败终止(`RunResult.passed=False`),而不是仅让当前
1956
+ 异常,会让整条 run 立刻终止并标为 Framework ERROR(`RunResult.status="error"`,
1957
+ `RunResult.error_kind="framework"`,`RunResult.passed=False`),而不是仅让当前
1949
1958
  Step 记一条硬失败、run 继续跑完剩余 Step。
1950
1959
  2. 校验 `match.arguments`(若声明了的话);不匹配时 `match_failed=True`,但**不会**
1951
1960
  抛异常中断执行——继续走到第 4 步,返回一个统一的 Tool Error。
@@ -1996,8 +2005,9 @@ respond:
1996
2005
  `sequence` 必须是非空列表,按调用次数从第一条开始依次消费(`sequence_indexes`
1997
2006
  按 tool 名字独立计数)。**序列被消费完之后如果还有下一次调用,是一次硬失败**:
1998
2007
  `MockInvocationError("mock response sequence exhausted: <name>")`,未捕获,导致
1999
- 整条 run 立即失败——不是"重复最后一条",也不是给模型返回一个可见的错误结果,这是
2000
- 原设计未明确的一处行为空白。
2008
+ 整条 run 立即变成 Framework ERROR(`status="error"`,`error_kind="framework"`)
2009
+ ——不是"重复最后一条",也不是给模型返回一个可见的错误结果,这是原设计未明确的一处
2010
+ 行为空白。
2001
2011
 
2002
2012
  ### 9.4 Python Handler 契约
2003
2013
 
@@ -2094,8 +2104,8 @@ Python Handler 有三类结果,不能混为一谈:
2094
2104
  - `MockImplementationError`:Handler 自身抛出的未预期异常、或返回值/state 不可 JSON 序列化时的包装异常。
2095
2105
 
2096
2106
  只有显式 `raise ToolMockError(...)` 才会变成模型可见的结构化 Tool Error;以上三种
2097
- 框架内部异常都属于"Mock 实现或配置有问题",视为测试基础设施故障而非被测 Agent
2098
- 应该看到的业务错误。
2107
+ 框架内部异常都属于"Mock 实现或配置有问题",视为 Framework ERROR(`status="error"`,
2108
+ `error_kind="framework"`)而非被测 Agent 应该看到的业务错误。
2099
2109
 
2100
2110
  示例:
2101
2111
 
@@ -2142,8 +2152,8 @@ Checker 从同一个最终 state 读取业务结果。Handler 源码本身不复
2142
2152
 
2143
2153
  未声明工具与参数不匹配的处理策略固定如下(无配置开关):
2144
2154
 
2145
- - Agent 调用未声明工具时,整条 run 立即硬失败(`MockInvocationError`,未捕获异常
2146
- 终止 run,而不是仅让当前 Step 记一条失败、run 继续)。
2155
+ - Agent 调用未声明工具时,整条 run 立即变成 Framework ERROR(`MockInvocationError`,
2156
+ 未捕获异常终止 run,而不是仅让当前 Step 记一条失败、run 继续)。
2147
2157
  - Tool arguments 无法匹配 `match.arguments` 时不中断执行:Runner 向模型返回统一的
2148
2158
  Tool Error `{"error": {"code": "UNKNOWN_ERROR", "message": "unknown error",
2149
2159
  "details": null, "retryable": false}}`,同时在 Mock Event 中以 `match_failed: true`
@@ -2231,7 +2241,7 @@ async def run_step(case, step, messages, registry, run_index, requests):
2231
2241
  终止**:`_run_once` 会捕获这个异常,把 Transcript 回滚到该 Step 开始前的快照,
2232
2242
  生成一条人工构造的失败 `StepResult`(`hard_checks` 里有一条
2233
2243
  `type: max_tool_rounds_exceeded` 的失败记录),然后**继续执行后续 Step**——这与
2234
- `execution.timeout_seconds_per_step` 超时(会让整条 run 直接失败终止,见 8.5 节)
2244
+ `execution.timeout_seconds_per_step` 超时(会让整条 run 标为 `status="error"` 并终止,见 8.5 节)
2235
2245
  的处理方式不同,容易混淆,需要分别记住。
2236
2246
  - `context.builders`(case scope,第 7.3 节)与 `steps[].message_inject`(Step
2237
2247
  scope,第 7.6 节)是两套独立的插入机制:前者只在第一个 Step 开始前跑一次,后者
@@ -2260,6 +2270,8 @@ execution:
2260
2270
  class RunResult:
2261
2271
  run_index: int
2262
2272
  passed: bool
2273
+ status: Literal["pass", "fail", "error"] # 旧调用未传时由 passed 推导
2274
+ error_kind: Literal["llm", "framework"] | None = None
2263
2275
  steps: list[StepResult] = field(default_factory=list)
2264
2276
  error: str | None = None
2265
2277
  traceback: str | None = None
@@ -2269,6 +2281,7 @@ class RunResult:
2269
2281
  artifact_dir: Path | None = None
2270
2282
 
2271
2283
  def usage(self) -> dict[str, int] | None: ... # 见下方 token 用量说明
2284
+ def request_duration_ms(self) -> float | None: ... # 全部 tool-loop LLM Request 耗时之和
2272
2285
 
2273
2286
  @dataclass
2274
2287
  class CaseResult:
@@ -2277,8 +2290,10 @@ class CaseResult:
2277
2290
  runs: list[RunResult]
2278
2291
  pass_rate: float
2279
2292
  description: str = "" # Case 顶层 description 的透传,供 CLI/JSON 输出展示
2293
+ status: Literal["pass", "fail", "error"] # 旧调用未传时由 passed 推导
2280
2294
 
2281
2295
  def usage(self) -> dict[str, int] | None: ... # 各 run usage() 之和
2296
+ def request_duration_ms(self) -> float | None: ... # 各 run request_duration_ms() 之和
2282
2297
  ```
2283
2298
 
2284
2299
  **Token 用量统计**没有独立的 `Usage` 类,而是一条贯穿各层的普通字典字段
@@ -2298,6 +2313,11 @@ class CaseResult:
2298
2313
  成 0)。`RunResult.usage()` = 该 run 全部 `requests[].usage` + 各 Step
2299
2314
  `judge_result["usage"]` 之和;`CaseResult.usage()` = 各 run 之和。两者的
2300
2315
  `to_dict()` 都带 `usage` 字段,因此 `result.json` 与 `--json` 输出天然携带。
2316
+ - **耗时**:tool-loop 的每次请求都会在 `requests[].duration_ms` 记录本轮
2317
+ `llm.complete()` 耗时。`runner.py:combine_duration_ms` 对这些毫秒数求和,
2318
+ 全部无数据时返回 `None`。`RunResult.request_duration_ms()` =
2319
+ 该 run 全部 `requests[].duration_ms` 之和;`CaseResult.request_duration_ms()` =
2320
+ 各 run 之和。两者的 `to_dict()` 都带 `request_duration_ms` 字段。
2301
2321
 
2302
2322
  ```python
2303
2323
  # models.py
@@ -2336,14 +2356,14 @@ class ToolCallRecord:
2336
2356
  ├── fixtures/
2337
2357
  │ └── <sha256前12位>-<原始文件名> # 用到的 fixture 文件本身的拷贝
2338
2358
  ├── requests/
2339
- │ ├── request-001.json # run 内全局递增编号,不按 Step 分段;Provider 报了用量时带 usage
2359
+ │ ├── request-001.json # run 内全局递增编号,不按 Step 分段;带 duration_ms,Provider 报了用量时带 usage
2340
2360
  │ └── request-002.json
2341
2361
  ├── transcript.json # [StepResult.to_dict(), ...]
2342
2362
  ├── mock-events.json
2343
2363
  ├── mock-state.json
2344
2364
  ├── hard-checks.json # {step_id: hard_checks}
2345
2365
  ├── judge-result.json # {step_id: judge_result}(只含有 Judge 结果的 Step;含 Judge 调用的 usage)
2346
- └── result.json # RunResult.to_dict()(含 run 级 usage 汇总、本 run 的 label 与生效 model)+ generated_at + traceback?
2366
+ └── result.json # RunResult.to_dict()(含 run 级 usage/request_duration_ms 汇总、本 run 的 label 与生效 model)+ generated_at + traceback?
2347
2367
  ```
2348
2368
 
2349
2369
  写产物前,`YamaRunner.run_case` 会先整体删除该 Case 的产物目录
@@ -2478,7 +2498,7 @@ Judge 只评价无法可靠写成确定性规则的质量维度。执行逻辑
2478
2498
  `evidence` 是**单个字符串**(不是证据数组),且**不存在 `confidence` 字段**——
2479
2499
  系统提示词只要求这四个 key,代码里也不解析/输出 `confidence`。
2480
2500
  5. 每个维度先规范化为 `(score - 1) / 4`,再按 `weight` 计算加权平均,得到 `overall`(`0..1`)。未写 `weight` 时按代码里的默认值 `1.0` 处理(等价于等权);显式权重按各自权重值直接加权平均(不需要额外归一化步骤,`weighted / total_weight` 已经等价于归一化)。
2481
- 6. 维度低于自身 `min_score`(未写时默认 `1`,即事实上不设下限)时 Judge 该 Step 失败;Case 级 `outcome.require.judge` 还可以增加 overall 和所有维度的统一门槛。
2501
+ 6. 维度低于自身 `min_score`(未写时默认 `1`,即事实上不设下限)时 Judge 该 Step 失败;Case 级 `outcome.require.judge.overall_gte` 还会并入该 Step 的 Judge 总状态:只有维度门槛和 Step `overall >= overall_gte` 同时满足,报告里的 Judge 才显示通过。
2482
2502
  7. Judge 分数不能抵消任何 Hard Assert 失败——`_case_passed` 会在检查 Judge 结果之前先判断所有 Step 的 `hard_pass`,一旦有失败就直接返回 `False`,Judge 逻辑根本不会被求值。
2483
2503
 
2484
2504
  ```yaml
@@ -2515,9 +2535,10 @@ judge:
2515
2535
  | `dimensions[].min_score` | 否 | 该维度 `1..5` 的最低原始分;省略时默认 `1`(不设下限)。 |
2516
2536
 
2517
2537
  Judge 实际返回的结构化结果(`run_judge` 在 Judge LLM 的原始输出上原地补充
2518
- `overall`/`passed` 两个字段后整体返回;Judge Provider 报了 token 用量时再补一个
2519
- `usage`——Judge 调用不进 run 的 `requests` 记录,其用量靠这个字段进入 run 级
2520
- 聚合,见第 11 节):
2538
+ `overall`/`passed` 两个字段;如果 Case 配了 `outcome.require.judge.overall_gte`,
2539
+ Runner 再把 `dimensions_passed`、`overall_required`、`overall_passed` 合入结果并
2540
+ 用二者的 AND 更新 `passed`;Judge Provider 报了 token 用量时再补一个 `usage`——
2541
+ Judge 调用不进 run 的 `requests` 记录,其用量靠这个字段进入 run 级聚合,见第 11 节):
2521
2542
 
2522
2543
  ```json
2523
2544
  {
@@ -2543,49 +2564,67 @@ Judge 实际返回的结构化结果(`run_judge` 在 Judge LLM 的原始输出
2543
2564
  ```yaml
2544
2565
  outcome:
2545
2566
  require:
2546
- tags:
2547
- high_confidence: 0.9
2548
- tolerant: 0.8
2549
- informational: 0.0
2567
+ hard_checks:
2568
+ tags:
2569
+ high_confidence: 0.9
2570
+ tolerant: 0.8
2571
+ informational: 0.0
2550
2572
  judge:
2551
2573
  overall_gte: 0.8
2552
2574
  each_dimension_gte: 0.6
2553
2575
  ```
2554
2576
 
2555
2577
  `judge.overall_gte`/`judge.each_dimension_gte` 是真实生效的配置键(对所有跑过 Judge
2556
- 的 Step 的 `overall`/各维度分别取阈值)。`outcome.require.tags` 按固定 tag 设置
2557
- hard check 的通过率阈值(`[0, 1]` 区间的数字):`runner.py:tag_pass_summary`
2578
+ 的 Step 的 `overall`/各维度分别取阈值,不对多个 Step 取平均)。`outcome.require.hard_checks.tags` 按固定
2579
+ tag 设置 hard check 的通过率阈值(`[0, 1]` 区间的数字):`runner.py:tag_pass_summary`
2558
2580
  按这次 run 里每条 hard check 的 tag 分组,算出 `rate = passed / total`,与该 tag
2559
2581
  的阈值比较。允许的 tag 固定为 `must_pass` / `high_confidence` / `tolerant` /
2560
2582
  `informational` 四种;断言未写 tag 时归入 `must_pass`。默认阈值分别是
2561
- `1.0` / `0.9` / `0.8` / `0.0`,其中 `must_pass` 固定为 `1.0` 不可降低。完全不使用
2583
+ `1.0` / `0.9` / `0.8` / `0.0`,其中 `must_pass` 固定为 `1.0` 不可降低。旧版
2584
+ `outcome.require.tags` 仍兼容读取,但新 Case 应写在 `hard_checks.tags` 下。完全不使用
2562
2585
  这个字段的 Case 行为不变:所有断言都落进 `must_pass`,等价于旧版"所有 Step 必须
2563
2586
  hard_pass"这条规则。未知 tag/key、阈值不是 `[0, 1]` 区间内的数字、或试图降低
2564
2587
  `must_pass`,都会在运行时抛 `AssertionConfigurationError`,体现为这次 run 的
2565
- `error`。`_case_passed` 的判定顺序是:先看 `tag_pass_summary` 的每个分组是否都
2588
+ `RunResult.error` 字段且 `status="error"` / `error_kind="framework"`。`_case_passed` 的判定顺序是:先看 `tag_pass_summary` 的每个分组是否都
2566
2589
  `ok`,任一不 `ok` 直接判失败;再走 Judge 门槛。
2567
2590
 
2568
2591
  实际的最终结果结构是 `CaseResult`(`runner.py`),**不存在**原设计设想的
2569
2592
  `{"passed", "hard_pass", "judge_pass", "quality_score", "reason"}` 这种顶层扁平
2570
2593
  结构——`hard_pass`/`judge_result` 这类判定分散在每个 Step 上,run 级别和 Case 级别
2571
- 只各自有一个整体 `passed` 布尔:
2594
+ 各自有一个三态 `status`(`pass`/`fail`/`error`)和一个兼容旧调用的 `passed`
2595
+ 布尔:`passed` 只在 `status == "pass"` 时为 `true`。LLM 请求异常或
2596
+ `timeout_seconds_per_step` 超时会把 run/case 标成 `error`,不进入 pass/fail 分母;
2597
+ 断言/Judge 的行为性不达标是 `fail`;断言配置错误、Mock/Builder/Checker 代码异常等
2598
+ 未捕获框架异常也是 `error`,但 `error_kind="framework"`,与
2599
+ `error_kind="llm"` 的大模型异常分开统计。
2572
2600
 
2573
2601
  ```json
2574
2602
  {
2575
2603
  "case_key": "__evals__/cases/image-led-mv.yaml",
2576
2604
  "passed": true,
2605
+ "status": "pass",
2577
2606
  "pass_rate": 1.0,
2578
2607
  "usage": { "prompt_tokens": 2000, "completion_tokens": 460, "total_tokens": 2460 },
2579
- "tag_summary": {
2580
- "must_pass": { "passed": 4, "total": 4, "rate": 1.0, "threshold": 1.0, "ok": true }
2581
- },
2608
+ "request_duration_ms": 842.317,
2582
2609
  "runs": [
2583
2610
  {
2584
2611
  "run_index": 1,
2585
2612
  "passed": true,
2586
- "steps": [ { "step_id": "...", "hard_pass": true, "judge_result": { "...": "..." } } ],
2613
+ "status": "pass",
2614
+ "error_kind": null,
2615
+ "steps": [
2616
+ {
2617
+ "step_id": "...",
2618
+ "hard_pass": true,
2619
+ "tag_summary": {
2620
+ "must_pass": { "passed": 4, "total": 4, "rate": 1.0, "threshold": 1.0, "ok": true }
2621
+ },
2622
+ "judge_result": { "...": "..." }
2623
+ }
2624
+ ],
2587
2625
  "error": null,
2588
2626
  "usage": { "prompt_tokens": 2000, "completion_tokens": 460, "total_tokens": 2460 },
2627
+ "request_duration_ms": 842.317,
2589
2628
  "mock_events": [ "..." ],
2590
2629
  "mock_state": { "...": "..." },
2591
2630
  "requests": [ "..." ],
@@ -2598,7 +2637,7 @@ hard_pass"这条规则。未知 tag/key、阈值不是 `[0, 1]` 区间内的数
2598
2637
  }
2599
2638
  ```
2600
2639
 
2601
- (Case/run 级的 `usage` 是第 11 节所述的聚合结果;无任何用量数据时为 `null`。)
2640
+ (Case/run 级的 `usage` 与 `request_duration_ms` 是第 11 节所述的聚合结果;无任何对应数据时为 `null`。)
2602
2641
 
2603
2642
  质量分不能抵消硬检查失败:`_case_passed` 先算 `tag_pass_summary`(见 12.3 节),
2604
2643
  任一分组不达标就直接返回 `False`,Judge 相关逻辑不会再被求值。
@@ -2638,10 +2677,21 @@ Step——不是按 Plugin 拆开的多个文件,也没有 JSON 版的 `summar
2638
2677
  用量(第 11 节的聚合链)在报告的每一层都有展示:顶部摘要多一张「LLM tokens」
2639
2678
  卡片(总量 + in/out 拆分),Case 头部 metadata 多一格逐 Case 汇总,Run/Step 的
2640
2679
  summary 行、执行时间线里的每次 assistant 响应、LLM requests 诊断列表和 Judge
2641
- 小节各自带本层级的 token 数;没有用量数据的层级显示 `–` 或不显示。Case 头部还会
2642
- 展示 **Case tag summary**:如果只跑一次,它等于唯一 run 的 tag 结果;如果跑多次,
2643
- 按同名 tag 汇总所有 run 的 `passed/total` 后重新计算整体 `rate` 和 `ok`。每个 run
2644
- 明细内部仍保留 **Pass rate by tag** 折叠表,展示该 run 自己的 tag 通过率。
2680
+ 小节各自带本层级的 token 数;没有用量数据的层级显示 `–` 或不显示。每轮 LLM
2681
+ Request 的详情会展示 Method、Duration、Arguments、Response,Response
2682
+ 是完整 assistant message(含 tool_calls),不只是文本内容;Case metadata
2683
+ 和 Run/Step summary 会展示 tool-loop LLM Request 耗时总和。报告不展示
2684
+ **Case tag summary**;每个 Step 的 **Hard checks** 区域会展示该 Step 自己的
2685
+ **Pass rate by tag** 折叠表,run 级 JSON 里仍保留 `tag_summary` 用于最终判定诊断。
2686
+ 顶部摘要只展示三张可见卡片:**CASES PASSED**、**CASES ERRORS**、
2687
+ **LLM TOKENS**。`CASES PASSED` 是通过 Case 数 / 总 Case 数;`CASES ERRORS`
2688
+ 是 error Case 数 / 总 Case 数;错误 Case 的具体 `error_kind` 与错误文本展示在对应
2689
+ Case header 里(如 **LLM error** / **Framework error**),而不是在顶部摘要里再拆
2690
+ 全局错误分类。整体 verdict 的优先级是 fail > error > pass(有断言/Judge 失败时为
2691
+ FAIL;没有失败但有 LLM/超时错误时为 ERROR;全部非 error 项通过且无 error 时为
2692
+ PASS)。`error_kind="llm"` 对应 LLM 请求异常和 Step 超时;`error_kind="framework"`
2693
+ 对应断言配置、Mock/Builder/Checker 代码、Mock sequence、未声明 Tool 等框架/Case
2694
+ 代码异常。
2645
2695
 
2646
2696
  跑了多个 run 的 Case(`len(runs) > 1`)在 metadata 与 Planned runs 折叠卡之间
2647
2697
  多一节 **Run comparison**(`report.py:_render_run_comparison`):
@@ -2682,8 +2732,10 @@ summary 行、执行时间线里的每次 assistant 响应、LLM requests 诊断
2682
2732
 
2683
2733
  报告 `<head>` 里内嵌一段惰性的 meta JSON(`render_page` 的 `meta` 参数,
2684
2734
  `<script type="application/json" id="yama-report-meta">`),携带 `kind`/
2685
- `generated_at`/`passed`/Case-Run-check 通过数/总 tokens——dashboard 索引页靠它
2686
- 列出每份历史报告的统计,而不必解析报告正文标记。
2735
+ `generated_at`/`passed`/`status`/Case-Run-check 通过数/Case-Run error 数/
2736
+ `llm_errors`/`framework_errors`/总 tokens——dashboard 索引页靠它列出每份历史报告的
2737
+ 统计,而不必解析报告正文标记。这里保留机器可读的 run/error 细分统计;报告正文顶部
2738
+ 只保留上面三张人工浏览用汇总卡片。
2687
2739
 
2688
2740
  **用例预览页(`preview.py`,`--preview` 与 dashboard `/preview` 共用)。**
2689
2741
  `render_preview_html` 复用报告的页面外壳与版式(`report.py:render_page` +
@@ -2757,24 +2809,26 @@ static snapshot 措辞)。
2757
2809
  [1/2] <case_key>
2758
2810
  <description,若有>
2759
2811
  Run 1/2
2760
- ✓ <step_id> hard checks 3/3 judge passed 92%
2812
+ ✗ <step_id> hard checks 3/3 judge failed 55% (required >= 70%)
2761
2813
  ├── ✓ 01 <hard check label>
2762
2814
  └── ✗ 02 <hard check label>
2763
2815
  ├── Expected ...
2764
2816
  ├── Actual ...
2765
2817
  └── Reason ...
2766
2818
  ✓ <case_key> 2/2 runs passed 100% tokens 2,460
2819
+ ! <case_key> 0/0 runs passed 0% 1 error
2767
2820
 
2768
2821
  Yama Eval Results
2769
2822
  Result | Case(含 description 副行) | Runs | Pass rate | Tokens
2770
2823
  ...
2771
- <caption:m/n cases passed • j/k runs passed • tokens 2,460 (in 2,000 / out 460)>
2824
+ <caption:m/n cases passed • j/k runs passed • [x case errors] • [y run errors] • [a llm errors] • [b framework errors] • tokens 2,460 (in 2,000 / out 460)>
2772
2825
  ```
2773
2826
 
2774
2827
  `tokens ...` 片段与表格 `Tokens` 列来自 `CaseResult.usage()`/`RunResult.usage()`
2775
2828
  (case 完成行与表格 caption 里是总量,caption 另带 in/out 拆分;明细树里 Case 行
2776
2829
  带拆分、Run 行只带总量);聚合为 `None`(Provider 没报用量)时不打印该片段,
2777
- 表格单元格显示 `–`,caption 也不带 tokens 段。
2830
+ 表格单元格显示 `–`,caption 也不带 tokens 段。`✓`/`✗`/`!` 分别对应
2831
+ `status=pass`/`fail`/`error`;ERROR 行不会计入 cases/runs passed 的分母。
2778
2832
 
2779
2833
  **并发模式**(并发 >1 且收集到多个 Case,默认即是):不同 Case 的 Step 结果会
2780
2834
  乱序到达,逐 Step 流式打印会把不相关 Case 的行交错在错误的 Case 标题下,因此改为
@@ -2826,7 +2880,7 @@ CLI 侧按并发模式挑选回调实现,两者的**已完成结果**都只做
2826
2880
  只原地更新对应行的状态(首个事件时惰性启动 transient `rich Live` 面板,
2827
2881
  `get_renderable` 每个刷新帧重建全部行——事件处理只整体替换行 dict、从不原地
2828
2882
  改写,避免与 Live 的刷新线程读写竞争);`case_end` 用 `build_case_tree` 从最终
2829
- `CaseResult` 渲染整 Case 块打印到面板上方,并把该行翻成 `✓/✗`;最后一个
2883
+ `CaseResult` 渲染整 Case 块打印到面板上方,并把该行翻成 `✓/✗/!`;最后一个
2830
2884
  `case_end` 后自动停掉面板。某个 Case 在 `case_end` 之前异常退出时面板不会自行
2831
2885
  停止,由 `cli.py:_run` 在 `gather` 结束后统一调用 `progress.close()` 兜底
2832
2886
  (两个 printer 都实现了 `close()`)。两个容易回归的实现约束:
@@ -2864,15 +2918,18 @@ record 的 request 生成 `context.skills`/`context.tools`/`context.messages`;
2864
2918
 
2865
2919
  自动 step 只表达“复现这一轮输入并期待相同 Tool 类型被调用”。它不生成 `mocks.tools`、
2866
2920
  更精细的参数断言或 Judge;这些仍由 Case 作者按评测目标补齐。生成的 Case 会固定写入
2867
- `outcome.require.hard_checks: all_pass`。若无法推导当前 workflow step 或真实用户输入,
2868
- 则保留 `steps: []`,stdout 仍只输出 YAML,stderr 只输出 record/response/DSL 抓取诊断信息。
2921
+ `outcome.require.hard_checks.tags.must_pass: 1.0`,让 `must_pass` 组的 100% 通过门槛在
2922
+ 骨架里显式可见。若无法推导当前 workflow step 或真实用户输入,则保留 `steps: []`,
2923
+ stdout 仍只输出 YAML,stderr 只输出 record/response/DSL 抓取诊断信息。
2869
2924
 
2870
2925
  `cli.py:main` 的错误出口按层归类(退出码都是 2):`ConfigurationError`/
2871
2926
  `CollectionError`/`ValueError` 打印 `Collection error: ...`(Case 还没跑起来,
2872
2927
  问题出在工作区配置或 Case 收集/解析);`LLMError` 单独打印 `LLM error: ...`——
2873
2928
  此时 Case 往往已经收集甚至执行过(例如脚本回放响应未被消费、Provider 配置缺失),
2874
2929
  把它标成 Collection error 会把排查引到错误的层级。run 内部的 LLM 异常仍由
2875
- `YamaRunner._run_once` 捕获进 `RunResult.error`,不走这个出口。
2930
+ `YamaRunner._run_once` 捕获进 `RunResult.error` 且标为 `status="error"`,不走这个
2931
+ 顶层出口;CLI 汇总完所有 Case 后,如果没有 `fail` 但存在 `error`,也返回退出码 2。
2932
+ 如果同时存在 `fail` 和 `error`,退出码仍为 1,报告/JSON 里会分别显示失败和错误。
2876
2933
 
2877
2934
  一个 Plugin 的 Skill、Tool、Case、产物目录不会泄漏到另一个 Plugin——这一点由
2878
2935
  "每个 Case 归属唯一 Plugin Root、产物写在该 Plugin 自己的 `.yama/` 下"这一实现
@@ -2981,6 +3038,8 @@ record 的 request 生成 `context.skills`/`context.tools`/`context.messages`;
2981
3038
  - JSON 产物(逐 Case/逐 run)与单文件 HTML 汇总报告。
2982
3039
  - LLM token 用量统计:逐请求采集、run/Case 级聚合、CLI 与 HTML 报告展示
2983
3040
  (见第 11 节与第 13 节)。
3041
+ - LLM Request 耗时统计:逐请求采集 `duration_ms`、run/Case/报告级聚合并在
3042
+ HTML 报告展示(见第 11 节与第 13 节)。
2984
3043
 
2985
3044
  ## 17. 最终边界
2986
3045
 
@@ -398,9 +398,10 @@ mocks:
398
398
  错误(不是测试基础设施异常)。
399
399
  - `sequence: [<result 或 error 项>, ...]`:一个非空列表,**按调用次数依次消费**——
400
400
  第 1 次调用消费第 0 项,第 2 次消费第 1 项,以此类推。序列消费完后若再被调用,
401
- **不会重复最后一项**,而是让整条 run 立即失败(这是故意设计的:"配置的序列比
402
- 实际调用次数短"通常意味着 Case 假设的调用节奏和模型实际行为不一致,静默复用最后
403
- 一项会掩盖这种偏差)。
401
+ **不会重复最后一项**,而是让整条 run 立即变成 Framework ERROR
402
+ (`status=error` / `error_kind=framework`;这是故意设计的:"配置的序列比实际
403
+ 调用次数短"通常意味着 Case 假设的调用节奏和模型实际行为不一致,静默复用最后一项
404
+ 会掩盖这种偏差)。
404
405
  - **`handler`**:自定义 Python 逻辑,`{python: "<模块引用或相对 .py 路径>:<函数名>",
405
406
  with?: <任意 config>}`。用于 YAML 固定返回表达不了的逻辑:按参数动态计算返回值、
406
407
  读写 `mocks.state`、跨 Step 维护业务不变量。签名约定见下文
@@ -432,7 +433,8 @@ mocks:
432
433
  ```
433
434
 
434
435
  **模型调用了未声明的工具**:即 Tool 名不在 `mocks.tools` 里(等价于不在
435
- `context.tools` 里,因为二者名字集合相等),整条 run 立即硬失败——这是刻意设计的"零
436
+ `context.tools` 里,因为二者名字集合相等),整条 run 立即变成 Framework ERROR
437
+ (`status=error` / `error_kind=framework`)——这是刻意设计的"零
436
438
  容忍":一个 Case 声明的 Tool 集合就是它对模型能力边界的完整假设,模型跳出这个边界
437
439
  调用了 Case 完全没预料到的工具,不应该被静默忍受成一次普通的失败断言,而应该直接暴露成
438
440
  基础设施层面的异常,逼着 Case 作者去检查——到底是 Prompt/Skill 诱导模型产生了幻觉
@@ -502,7 +504,8 @@ mocks:
502
504
  结构化业务错误,Tool Loop 正常继续(模型可以据此重试或改变策略),等价于
503
505
  `respond.error`。
504
506
  3. **抛出其它任何异常** → 视为**测试基础设施故障**而不是"模型触发的业务错误",
505
- 整条 run 立即失败,异常堆栈只写进产物供排查(模型永远看不到 Python Traceback)。
507
+ 整条 run 立即变成 Framework ERROR(`status=error` / `error_kind=framework`),
508
+ 异常堆栈只写进产物供排查(模型永远看不到 Python Traceback)。
506
509
  这个区分很重要:`ToolMockError` 是 Case 作者刻意设计的、模型应该学会处理的失败
507
510
  场景;其它异常几乎总是 Mock 代码本身写错了(比如 `KeyError`),继续把 Tool Loop
508
511
  跑下去只会产生误导性的失败诊断。
@@ -660,8 +663,8 @@ mocks:
660
663
  |---|---|---|---|
661
664
  | `timeout_seconds_per_step` | number | `120` | 单个 Step(从发出 User Message 到
662
665
  拿到无 Tool Call 的最终 Assistant Message)允许的最长耗时。**超时的后果是整条 run
663
- 异常终止**(不只是当前 Step 失败),因为超时通常意味着模型陷入了某种不会自然收敛的
664
- 循环,继续跑后续 Step 意义不大,不如整条 run 直接失败并如实反映"这条 run 卡死了"。 |
666
+ 标为 ERROR 并终止**(`status=error`,不只是当前 Step 失败),因为超时通常意味着模型陷入了某种不会自然收敛的
667
+ 循环,继续跑后续 Step 意义不大,应在报告中单独反映"这条 run 卡死了"。 |
665
668
  | `max_tool_rounds_per_step` | integer | `10` | 单个 Step 内允许的最大"发一次请求给
666
669
  模型"轮数(每轮可能包含多个并发 Tool Call)。**超限的后果只影响当前 Step**:这个
667
670
  Step 被记为 `max_tool_rounds_exceeded` 硬失败,transcript 回滚到这个 Step 开始前的
@@ -880,7 +883,8 @@ assert:
880
883
  - 每条 `assert.hard` 断言可以带一个可选的平级字段 `tag`(不是某个具体断言类型的
881
884
  key),最多一个;不打 `tag` 的断言默认归入 `must_pass`。允许的 tag 固定为
882
885
  `must_pass` / `high_confidence` / `tolerant` / `informational` 四种,写其它值会在
883
- 运行时报 `AssertionConfigurationError`。`tag` 只影响下面 `outcome.require.tags`
886
+ 运行时报 `AssertionConfigurationError`。`tag` 只属于 hard check,不属于
887
+ `assert.judge` 或 Judge 维度;它只影响下面 `outcome.require.hard_checks.tags`
884
888
  的分组通过率计算,不改变断言本身的匹配逻辑。
885
889
 
886
890
  ### steps[].assert.judge:LLM 评分
@@ -929,7 +933,8 @@ Checker 源码都不会给 Judge 看**,保证 Judge 是纯粹基于"模型这
929
933
  `weight` 加权平均得到这个 Step 的 `overall`。Judge 分数**永远不能抵消 hard check
930
934
  失败**——这是整个断言体系里唯一被反复强调的不变式:`outcome` 判定 Case 是否通过时,
931
935
  hard check 是硬性前提,Judge 只在 hard check 全过(或 `run_if_hard_failed: true`)
932
- 的基础上再加一层质量门槛。
936
+ 的基础上再加一层质量门槛。配置了 `outcome.require.judge.overall_gte` 时,报告里的
937
+ Judge 总状态会同时要求维度 `min_score` 和这个 Step 的 `overall` 达标。
933
938
 
934
939
  ---
935
940
 
@@ -938,19 +943,22 @@ hard check 是硬性前提,Judge 只在 hard check 全过(或 `run_if_hard_f
938
943
  ```yaml
939
944
  outcome:
940
945
  require:
941
- tags:
942
- high_confidence: 0.9 # 默认 0.9,可显式声明
943
- tolerant: 0.8 # 默认 0.8,可按 Case 调整
944
- informational: 0.0 # 默认 0.0,只统计不阻断
946
+ hard_checks:
947
+ tags:
948
+ high_confidence: 0.9 # 默认 0.9,可显式声明
949
+ tolerant: 0.8 # 默认 0.8,可按 Case 调整
950
+ informational: 0.0 # 默认 0.0,只统计不阻断
945
951
  judge:
946
- overall_gte: 0.8 # 所有跑过 Judge 的 Step 的 overall 下限
952
+ overall_gte: 0.8 # 每个跑过 Judge 的 Step 的 overall 下限
947
953
  each_dimension_gte: 0.6 # 所有维度规范化分下限
948
954
  ```
949
955
 
950
- `outcome.require.tags` 是一个 `{ <tag 名>: <阈值> }` 映射,阈值是 `[0.0, 1.0]` 区间
951
- 内的数字,表示"这个 tag 下所有断言的通过率必须 `>= 阈值`"。允许的 key 同样只有
952
- `must_pass` / `high_confidence` / `tolerant` / `informational` 四种,写其它 key 会在
953
- 运行时报 `AssertionConfigurationError`。默认阈值分别是:
956
+ `outcome.require.hard_checks.tags` 是一个 `{ <tag 名>: <阈值> }` 映射,阈值是
957
+ `[0.0, 1.0]` 区间内的数字,表示"这个 tag 下所有 hard check 的通过率必须
958
+ `>= 阈值`"。允许的 key 同样只有 `must_pass` / `high_confidence` / `tolerant` /
959
+ `informational` 四种,写其它 key 会在运行时报 `AssertionConfigurationError`。
960
+ 旧版 `outcome.require.tags` 仍会被兼容读取,但新 Case 应写在 `hard_checks.tags`
961
+ 下,避免和 Judge 门槛混在同一层。默认阈值分别是:
954
962
 
955
963
  | tag | 默认阈值 | 语义 |
956
964
  | --- | --- | --- |
@@ -959,10 +967,10 @@ outcome:
959
967
  | `tolerant` | `0.8` | 容忍型 hard check,可按 Case 调整阈值。 |
960
968
  | `informational` | `0.0` | 只统计展示,不阻断 Case。 |
961
969
 
962
- 完全不使用 `tag`/`outcome.require.tags` 的 Case,所有断言都默认落进 `must_pass`,
963
- 效果和"所有 hard check 必须全部通过"一致。阈值不是数字,或不在 `[0, 1]` 区间内,
964
- 运行时会抛错并体现为这次 run 的 `error`;`must_pass` 的阈值固定为 `1.0`,不能在
965
- `outcome.require.tags` 里降低。
970
+ 完全不使用 `tag`/`outcome.require.hard_checks.tags` 的 Case,所有 hard check 都默认
971
+ 落进 `must_pass`,效果和"所有 hard check 必须全部通过"一致。阈值不是数字,或不在
972
+ `[0, 1]` 区间内,运行时会抛错并体现为这次 run 的 `error`;`must_pass` 的阈值固定为
973
+ `1.0`,不能在 `outcome.require.hard_checks.tags` 里降低。
966
974
 
967
975
  容忍某个 tag 下的 hard check 失败,不等于跳过它对 Judge 的影响:单条 hard check 是否
968
976
  `passed` 和它所在 Step 是否触发 Judge 是两件独立的事——一个 Step 只要有 hard check
@@ -972,5 +980,7 @@ Judge 分数也会因为该 Step 从未跑过 Judge 而缺失,导致 `judge.ov
972
980
  `each_dimension_gte` 判定失败。同一个 Step 上既要用 tag 容忍 hard check 失败、又要
973
981
  强制跑 Judge 打分时,记得把该 Step 设为 `run_if_hard_failed: true`。
974
982
 
975
- `repeat > 1`(含运行矩阵展开出多个 run)时,Case `passed` 要求每次 run 都
976
- 通过;`pass_rate` 记录通过比例。
983
+ `repeat > 1`(含运行矩阵展开出多个 run)时,`status=error` 的 run 不进入
984
+ pass/fail 分母;存在非 error 失败 run 时 Case 为 FAIL,没有失败但存在 error run
985
+ 时 Case 为 ERROR,全部非 error run 通过且没有 error 时才是 PASS。`pass_rate` 只按
986
+ 非 error run 记录通过比例。