python-yama 0.2.0__tar.gz → 0.3.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.
- {python_yama-0.2.0 → python_yama-0.3.0}/PKG-INFO +7 -1
- {python_yama-0.2.0 → python_yama-0.3.0}/README.md +6 -0
- {python_yama-0.2.0 → python_yama-0.3.0}/README.zh-CN.md +6 -0
- {python_yama-0.2.0 → python_yama-0.3.0}/docs/agent-skill-test-framework-design.md +114 -17
- {python_yama-0.2.0 → python_yama-0.3.0}/skills/eval-plugin-with-yama/SKILL.md +9 -1
- {python_yama-0.2.0 → python_yama-0.3.0}/skills/eval-plugin-with-yama/references/case-schema.md +2 -0
- python_yama-0.3.0/tests/test_cli.py +728 -0
- {python_yama-0.2.0 → python_yama-0.3.0}/tests/test_framework.py +153 -0
- {python_yama-0.2.0 → python_yama-0.3.0}/tests/test_report.py +48 -0
- python_yama-0.3.0/yama/cli.py +626 -0
- {python_yama-0.2.0 → python_yama-0.3.0}/yama/loaders/case.py +7 -0
- {python_yama-0.2.0 → python_yama-0.3.0}/yama/models.py +1 -0
- {python_yama-0.2.0 → python_yama-0.3.0}/yama/report.py +7 -0
- {python_yama-0.2.0 → python_yama-0.3.0}/yama/runner.py +55 -3
- python_yama-0.2.0/tests/test_cli.py +0 -291
- python_yama-0.2.0/yama/cli.py +0 -317
- {python_yama-0.2.0 → python_yama-0.3.0}/.github/workflows/publish.yml +0 -0
- {python_yama-0.2.0 → python_yama-0.3.0}/.gitignore +0 -0
- {python_yama-0.2.0 → python_yama-0.3.0}/CLAUDE.md +0 -0
- {python_yama-0.2.0 → python_yama-0.3.0}/LICENSE +0 -0
- {python_yama-0.2.0 → python_yama-0.3.0}/pyproject.toml +0 -0
- {python_yama-0.2.0 → python_yama-0.3.0}/skills/eval-plugin-with-yama/references/debugging.md +0 -0
- {python_yama-0.2.0 → python_yama-0.3.0}/tests/test_assertions.py +0 -0
- {python_yama-0.2.0 → python_yama-0.3.0}/tests/test_cli_shim.py +0 -0
- {python_yama-0.2.0 → python_yama-0.3.0}/tests/test_main_entrypoint.py +0 -0
- {python_yama-0.2.0 → python_yama-0.3.0}/tests/test_mocks.py +0 -0
- {python_yama-0.2.0 → python_yama-0.3.0}/tests/test_public_api.py +0 -0
- {python_yama-0.2.0 → python_yama-0.3.0}/tests/test_skill_tool.py +0 -0
- {python_yama-0.2.0 → python_yama-0.3.0}/tests/test_workspace.py +0 -0
- {python_yama-0.2.0 → python_yama-0.3.0}/uv.lock +0 -0
- {python_yama-0.2.0 → python_yama-0.3.0}/yama/__init__.py +0 -0
- {python_yama-0.2.0 → python_yama-0.3.0}/yama/__main__.py +0 -0
- {python_yama-0.2.0 → python_yama-0.3.0}/yama/assertions.py +0 -0
- {python_yama-0.2.0 → python_yama-0.3.0}/yama/llm.py +0 -0
- {python_yama-0.2.0 → python_yama-0.3.0}/yama/loaders/__init__.py +0 -0
- {python_yama-0.2.0 → python_yama-0.3.0}/yama/loaders/common.py +0 -0
- {python_yama-0.2.0 → python_yama-0.3.0}/yama/loaders/tool_loader.py +0 -0
- {python_yama-0.2.0 → python_yama-0.3.0}/yama/mocks.py +0 -0
- {python_yama-0.2.0 → python_yama-0.3.0}/yama/tools/__init__.py +0 -0
- {python_yama-0.2.0 → python_yama-0.3.0}/yama/tools/base.py +0 -0
- {python_yama-0.2.0 → python_yama-0.3.0}/yama/tools/bash/__init__.py +0 -0
- {python_yama-0.2.0 → python_yama-0.3.0}/yama/tools/bash/_cli_shim.py +0 -0
- {python_yama-0.2.0 → python_yama-0.3.0}/yama/tools/bash/bash.py +0 -0
- {python_yama-0.2.0 → python_yama-0.3.0}/yama/tools/bash/fs.py +0 -0
- {python_yama-0.2.0 → python_yama-0.3.0}/yama/tools/skill/__init__.py +0 -0
- {python_yama-0.2.0 → python_yama-0.3.0}/yama/tools/skill/skill.py +0 -0
- {python_yama-0.2.0 → python_yama-0.3.0}/yama/workspace.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-yama
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.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
|
|
@@ -45,6 +45,8 @@ OPENAI_API_KEY=... uv run --project yama yama --plugin dingding-simple
|
|
|
45
45
|
A Case is a YAML file organized as `context` (what the model sees) → `mocks` (how tool calls get executed) → `steps` (user turns sent in order, each with assertions) → `outcome` (the pass bar for the whole Case):
|
|
46
46
|
|
|
47
47
|
```yaml
|
|
48
|
+
description: The model reads the DSL before proposing creative directions
|
|
49
|
+
|
|
48
50
|
context:
|
|
49
51
|
system_prompt: { default: true } # use SYSTEM.md from the plugin root
|
|
50
52
|
|
|
@@ -71,6 +73,7 @@ outcome:
|
|
|
71
73
|
hard_checks: all_pass
|
|
72
74
|
```
|
|
73
75
|
|
|
76
|
+
- `description` (optional) is a one-line summary of what the Case tests; it is shown in the CLI output and the HTML report.
|
|
74
77
|
- `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.
|
|
75
78
|
- 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?)`.
|
|
76
79
|
- To simulate command-line tools, declare `{builtin: bash}` and configure per-command output under `mocks.cli`.
|
|
@@ -91,9 +94,12 @@ uv run --project yama yama --plugin dingding-simple --report
|
|
|
91
94
|
| `--plugin NAME` (repeatable) | Select plugins by name from `yama.toml` |
|
|
92
95
|
| `--all-plugins` | Run every plugin configured in `yama.toml` |
|
|
93
96
|
| `--result-dir PATH` | Override the artifact root (default `<plugin_root>/.yama/runs`) |
|
|
97
|
+
| `--concurrency N` | Maximum number of cases running in parallel (default 10; `1` runs cases one at a time) |
|
|
94
98
|
| `--report [PATH]` | Also generate a single-file HTML report (default `.yama/reports/latest.html`) |
|
|
95
99
|
| `--list` | Only print the collected Cases, without running them |
|
|
96
100
|
| `--no-artifacts` | Write no artifact files at all |
|
|
97
101
|
| `--json` | Emit machine-readable JSON instead of Rich tables |
|
|
98
102
|
|
|
99
103
|
`--plugin`, `--all-plugins`, and `--plugin-root` are mutually exclusive. When none of them is given, yama walks up from the current directory to the nearest directory containing `yama.toml` and uses it as the workspace root (falling back to the cwd), running it as a single plugin root.
|
|
104
|
+
|
|
105
|
+
Cases run in parallel, up to 10 at a time by default (`--concurrency` changes the cap); runs within one case stay sequential, and results keep collection order regardless of completion order. While several cases run concurrently, a transient dashboard at the bottom of the terminal shows one row per case, updated in place — waiting, then a spinner with the run/step currently executing, then its ✓/✗ verdict — and each case's full run/step detail is printed above the dashboard as one block the moment it finishes, so blocks of different cases never interleave. With `--concurrency 1` (or a single collected case) it streams instead — a spinner marks the step currently executing (on a terminal), and each case, run, and assertion result is printed the moment it completes. Either way a per-case summary table closes the output, and with `--json` the progress stream goes to stderr so stdout stays valid JSON.
|
|
@@ -20,6 +20,8 @@ OPENAI_API_KEY=... uv run --project yama yama --plugin dingding-simple
|
|
|
20
20
|
A Case is a YAML file organized as `context` (what the model sees) → `mocks` (how tool calls get executed) → `steps` (user turns sent in order, each with assertions) → `outcome` (the pass bar for the whole Case):
|
|
21
21
|
|
|
22
22
|
```yaml
|
|
23
|
+
description: The model reads the DSL before proposing creative directions
|
|
24
|
+
|
|
23
25
|
context:
|
|
24
26
|
system_prompt: { default: true } # use SYSTEM.md from the plugin root
|
|
25
27
|
|
|
@@ -46,6 +48,7 @@ outcome:
|
|
|
46
48
|
hard_checks: all_pass
|
|
47
49
|
```
|
|
48
50
|
|
|
51
|
+
- `description` (optional) is a one-line summary of what the Case tests; it is shown in the CLI output and the HTML report.
|
|
49
52
|
- `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.
|
|
50
53
|
- 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?)`.
|
|
51
54
|
- To simulate command-line tools, declare `{builtin: bash}` and configure per-command output under `mocks.cli`.
|
|
@@ -66,9 +69,12 @@ uv run --project yama yama --plugin dingding-simple --report
|
|
|
66
69
|
| `--plugin NAME` (repeatable) | Select plugins by name from `yama.toml` |
|
|
67
70
|
| `--all-plugins` | Run every plugin configured in `yama.toml` |
|
|
68
71
|
| `--result-dir PATH` | Override the artifact root (default `<plugin_root>/.yama/runs`) |
|
|
72
|
+
| `--concurrency N` | Maximum number of cases running in parallel (default 10; `1` runs cases one at a time) |
|
|
69
73
|
| `--report [PATH]` | Also generate a single-file HTML report (default `.yama/reports/latest.html`) |
|
|
70
74
|
| `--list` | Only print the collected Cases, without running them |
|
|
71
75
|
| `--no-artifacts` | Write no artifact files at all |
|
|
72
76
|
| `--json` | Emit machine-readable JSON instead of Rich tables |
|
|
73
77
|
|
|
74
78
|
`--plugin`, `--all-plugins`, and `--plugin-root` are mutually exclusive. When none of them is given, yama walks up from the current directory to the nearest directory containing `yama.toml` and uses it as the workspace root (falling back to the cwd), running it as a single plugin root.
|
|
79
|
+
|
|
80
|
+
Cases run in parallel, up to 10 at a time by default (`--concurrency` changes the cap); runs within one case stay sequential, and results keep collection order regardless of completion order. While several cases run concurrently, a transient dashboard at the bottom of the terminal shows one row per case, updated in place — waiting, then a spinner with the run/step currently executing, then its ✓/✗ verdict — and each case's full run/step detail is printed above the dashboard as one block the moment it finishes, so blocks of different cases never interleave. With `--concurrency 1` (or a single collected case) it streams instead — a spinner marks the step currently executing (on a terminal), and each case, run, and assertion result is printed the moment it completes. Either way a per-case summary table closes the output, and with `--json` the progress stream goes to stderr so stdout stays valid JSON.
|
|
@@ -20,6 +20,8 @@ OPENAI_API_KEY=... uv run --project yama yama --plugin dingding-simple
|
|
|
20
20
|
一个 Case 是一份 YAML 文件,按 `context`(模型看到什么)→ `mocks`(Tool 怎么被执行)→ `steps`(依次发送的用户回合与断言)→ `outcome`(整个 Case 的通过门槛)的结构组织:
|
|
21
21
|
|
|
22
22
|
```yaml
|
|
23
|
+
description: 模型应先读取 DSL 再给出创意方向
|
|
24
|
+
|
|
23
25
|
context:
|
|
24
26
|
system_prompt: { default: true } # 使用 Plugin 根目录下的 SYSTEM.md
|
|
25
27
|
|
|
@@ -46,6 +48,7 @@ outcome:
|
|
|
46
48
|
hard_checks: all_pass
|
|
47
49
|
```
|
|
48
50
|
|
|
51
|
+
- `description`(可选)是一句话说明当前 Case 测试什么;会展示在 CLI 输出和 HTML 报告中。
|
|
49
52
|
- `context.tools` 是发给模型的 Tool Schema,`mocks.tools` 是 Runner 收到 Tool Call 后如何返回结果;两者的 Tool 名字集合必须完全一致。
|
|
50
53
|
- 需要 Skill 时在 `context.skills` 中按名字声明,并在 `context.tools` 中同时声明 `{builtin: skill}`;模型通过 `skill(name, file?)` 读取正文。
|
|
51
54
|
- 需要模拟命令行工具时声明 `{builtin: bash}`,在 `mocks.cli` 中按命令配置输出。
|
|
@@ -66,9 +69,12 @@ uv run --project yama yama --plugin dingding-simple --report
|
|
|
66
69
|
| `--plugin NAME`(可重复) | 按 `yama.toml` 中的 Plugin 名字选择 |
|
|
67
70
|
| `--all-plugins` | 运行 `yama.toml` 中配置的全部 Plugin |
|
|
68
71
|
| `--result-dir PATH` | 覆盖产物根目录(默认 `<plugin_root>/.yama/runs`) |
|
|
72
|
+
| `--concurrency N` | 同时运行的 Case 数上限(默认 10;`1` 表示逐个顺序执行) |
|
|
69
73
|
| `--report [PATH]` | 额外生成单文件 HTML 报告(默认 `.yama/reports/latest.html`) |
|
|
70
74
|
| `--list` | 只打印匹配到的 Case,不运行 |
|
|
71
75
|
| `--no-artifacts` | 不写任何产物文件 |
|
|
72
76
|
| `--json` | 输出机器可读 JSON 而不是 Rich 表格 |
|
|
73
77
|
|
|
74
78
|
`--plugin`/`--all-plugins`/`--plugin-root` 三者互斥;都不提供时默认用当前目录向上搜索到的 `yama.toml` 所在目录作为 Workspace Root(找不到则用 cwd),把该目录当作单一 Plugin Root 运行。
|
|
79
|
+
|
|
80
|
+
Case 之间并行执行,默认最多同时 10 个(用 `--concurrency` 调整上限);同一 Case 内的多个 run 仍顺序执行,结果始终保持收集顺序,与完成先后无关。多个 Case 并发运行时,终端底部会有一张原地刷新的状态面板,每个 Case 固定占一行——排队等待、转圈显示当前执行到的 Run/Step、完成后原地翻成 ✓/✗——任何一个 Case 一完成,它的完整 Run/Step 明细就作为一个整块打印到面板上方,不同 Case 的块不会交错。使用 `--concurrency 1`(或只收集到一个 Case)时则实时流式输出——正在执行的 Step 会显示转圈的 loading 状态(终端下),每个 Case、Run、断言一完成就立即打印结果。两种模式最后都以逐 Case 的汇总表格收尾;使用 `--json` 时进度流打印到 stderr,stdout 保持为纯 JSON。
|
|
@@ -82,10 +82,10 @@ SYSTEM.md Skill Catalog Extra Messages
|
|
|
82
82
|
| `tools/bash/_cli_shim.py` | 独立子进程入口,被编译出的 `.mockbin/<cmd>` 脚本调用,复用 `mocks.py` 的 `_matches` 语义在规则树里做匹配 | `main`、`_resolve` |
|
|
83
83
|
| `tools/skill/skill.py` | `{builtin: skill}` 默认 Handler:按 Skill 目录 + 文件名读取 Skill 正文/子文件 | `SkillTool`、`read_skill`(`= SkillTool().run`) |
|
|
84
84
|
| `llm.py` | LLM Provider 适配层,把统一消息格式转换成 LiteLLM 调用参数;提供可脚本化的确定性 Client 供测试/回放用 | `LLMClient`(抽象)、`LiteLLMClient`、`ScriptedLLMClient` |
|
|
85
|
-
| `runner.py` | 核心编排:按 run/step/request 三层驱动一次 Case
|
|
85
|
+
| `runner.py` | 核心编排:按 run/step/request 三层驱动一次 Case 执行,并通过 `on_event` 回调对外发布进度事件(见第 13 节) | `YamaRunner`、`RunResult`、`CaseResult`、`RunnerEventCallback`、`MaxToolRoundsExceeded` |
|
|
86
86
|
| `assertions.py` | 硬断言(tool_called / assistant_matches / jsonpath 等)与 LLM-as-Judge 的实现 | `run_hard_assertions`、`run_judge` |
|
|
87
87
|
| `report.py` | 把执行结果渲染成单个自包含 HTML 报告 | `write_html_report` |
|
|
88
|
-
| `cli.py` | 命令行入口:串联 config → loaders → runner → report
|
|
88
|
+
| `cli.py` | 命令行入口:串联 config → loaders → runner → report;按 `--concurrency` 并行调度多个 Case(asyncio),执行中流式打印进度,收尾打印汇总表格 | `main`、`ProgressPrinter`、`ParallelProgressPrinter`、`build_case_tree`、`build_summary_table`、`build_results_renderable` |
|
|
89
89
|
|
|
90
90
|
### 3.2 一次 Case 执行的数据流
|
|
91
91
|
|
|
@@ -218,15 +218,37 @@ yama --plugin-root ./dingding-simple
|
|
|
218
218
|
| `--plugin NAME`(可重复) | 按 `yama.toml` 中的 Plugin 名字选择,一次可传多次 |
|
|
219
219
|
| `--all-plugins` | 运行 `yama.toml` 中配置的全部 Plugin |
|
|
220
220
|
| `--result-dir PATH` | 覆盖产物根目录(默认每个 Case 写到其所属 `plugin_root/.yama/runs`) |
|
|
221
|
+
| `--concurrency N` | 同时运行的 Case 数上限(必须 ≥ 1,默认 10);`1` 表示按收集顺序逐个执行 |
|
|
221
222
|
| `--report [PATH]` | 额外写一份单文件 HTML 报告;省略路径时默认写到 `<第一个 result_root 的上级>/reports/latest.html` |
|
|
222
223
|
| `--list` | 只收集并打印 `case_key` 列表,不运行 |
|
|
223
224
|
| `--no-artifacts` | 不写任何产物文件 |
|
|
224
|
-
| `--json` | 以机器可读 JSON
|
|
225
|
+
| `--json` | 以机器可读 JSON 数组打印结果(进度流转到 stderr,stdout 保持纯 JSON) |
|
|
225
226
|
|
|
226
227
|
`--plugin`/`--all-plugins`/`--plugin-root` 三者互斥,都不提供时默认用 cwd 向上搜索到的
|
|
227
228
|
Workspace Root(或 cwd 本身)作为单一 Plugin Root——这正是 `cd dingding-simple && yama`
|
|
228
229
|
可行的原因。
|
|
229
230
|
|
|
231
|
+
**Case 级并发调度(`--concurrency`,`cli.py:_run`)。** 收集到的多个 Case 用
|
|
232
|
+
`asyncio.Semaphore(concurrency)` + `asyncio.gather` 在同一事件循环里并发执行
|
|
233
|
+
(执行链路本就是全异步:LiteLLM `acompletion`、bash 沙箱的 asyncio 子进程——
|
|
234
|
+
不是 OS 线程,工作负载是 I/O 密集的 LLM 请求,事件循环并发即可拿到全部吞吐)。
|
|
235
|
+
语义边界:
|
|
236
|
+
|
|
237
|
+
- 并发单位是 **Case**;同一 Case 内 `execution.repeat` 的多个 run 仍严格顺序执行。
|
|
238
|
+
- 每个 Case 用独立的 `YamaRunner` + 独立的 `LiteLLMClient`——runner 在每次
|
|
239
|
+
`complete()` 后回读 client 的 `last_request`/`last_provider` 写入请求记录,
|
|
240
|
+
共享 client 会被并发 Case 互相覆盖。
|
|
241
|
+
- 结果数组保持**收集顺序**(`gather` 保序),与完成先后无关;汇总表格、`--json`
|
|
242
|
+
输出、HTML 报告的 Case 顺序因此在任何并发度下都稳定。
|
|
243
|
+
- 某个 Case 抛出异常(罕见:run 内的错误都会被 `_run_once` 捕获进
|
|
244
|
+
`RunResult.error`)时,其余 Case 仍会跑完并写完产物(`gather`
|
|
245
|
+
`return_exceptions=True`),随后第一个异常按原有 `main()` 错误出口重新抛出。
|
|
246
|
+
- Case 间的隔离不依赖新机制:bash 沙箱工作目录/产物目录本就按 `case_key` 分目录,
|
|
247
|
+
持久 shell 会话按每 run 的 `state` 身份键控(见 8.4.3 与第 12 节)。
|
|
248
|
+
- 进度输出按并发模式切换(见第 13 节):并发 >1 且收集到多个 Case 时使用
|
|
249
|
+
`ParallelProgressPrinter`(终端底部一张原地刷新的逐 Case 状态面板 + 完成时
|
|
250
|
+
整 Case 成块打印),否则保持逐 Step 流式的 `ProgressPrinter`。
|
|
251
|
+
|
|
230
252
|
## 5. 全局配置
|
|
231
253
|
|
|
232
254
|
Workspace 根目录使用 `yama.toml`。**实际支持的字段只有以下这些**(`workspace.py:WorkspaceConfig`):
|
|
@@ -280,8 +302,9 @@ timeout_seconds_per_step = 60
|
|
|
280
302
|
< Case 自己顶层的 model: / execution: 字段
|
|
281
303
|
```
|
|
282
304
|
|
|
283
|
-
**不存在** CLI 对 `model`/`execution`/超时参数的覆盖层——CLI
|
|
284
|
-
`--result-dir
|
|
305
|
+
**不存在** CLI 对 `model`/`execution`/超时参数的覆盖层——CLI 能覆盖的运行期配置只有
|
|
306
|
+
`--result-dir`(产物根目录)和 `--concurrency`(Case 级并发上限,纯调度参数,
|
|
307
|
+
不影响任何 Case 语义)。也**不存在** `[conventions]`、`[templates]` 两个配置表,
|
|
285
308
|
也没有 `baseline_dir` 字段:
|
|
286
309
|
|
|
287
310
|
- `[conventions]`:System Prompt/Skill 目录/入口文件名等约定只能在 **Plugin 级别**
|
|
@@ -903,10 +926,11 @@ transcript,不提供"只影响这一次请求"的临时选项,也不支持 `
|
|
|
903
926
|
|
|
904
927
|
## 8. Case Schema
|
|
905
928
|
|
|
906
|
-
Case Schema 按"模型与 Context → Tool 执行 → 对话 Step → Step 断言 → Case 结果门槛"的层级组织。Case 相对 Plugin Root 的文件路径就是唯一身份(`case_key`),不再重复声明 `id
|
|
929
|
+
Case Schema 按"模型与 Context → Tool 执行 → 对话 Step → Step 断言 → Case 结果门槛"的层级组织。Case 相对 Plugin Root 的文件路径就是唯一身份(`case_key`),不再重复声明 `id` 或 `tags`;可选的顶层 `description` 只是给人看的一句话说明(这个 Case 测试什么),不参与身份判定,会展示在 CLI 进度/汇总输出与 HTML 报告的 Case 头部(`loaders/case.py` 解析时校验必须是字符串并 strip 首尾空白)。
|
|
907
930
|
|
|
908
931
|
```text
|
|
909
932
|
Case
|
|
933
|
+
├── description 可选:一句话描述本 Case 测试什么
|
|
910
934
|
├── model 本 Case 的模型覆盖
|
|
911
935
|
├── context 模型实际看见的输入
|
|
912
936
|
│ ├── system_prompt
|
|
@@ -936,6 +960,7 @@ Case
|
|
|
936
960
|
|
|
937
961
|
| 字段 | 必填 | 含义 |
|
|
938
962
|
| --- | --- | --- |
|
|
963
|
+
| `description` | 否 | 一句话说明当前 Case 测试什么;展示在 CLI 与 HTML 报告中,并写入 `case.resolved.yaml` 与 `CaseResult`。 |
|
|
939
964
|
| `model` | 否 | 覆盖 Workspace / Plugin 默认模型。 |
|
|
940
965
|
| `context` | 是 | 当前 Case 发给模型的全部显式输入。 |
|
|
941
966
|
| `mocks` | 按需 | Tool Handler、参数匹配、初始 state 和有状态 Python Tool Mock。 |
|
|
@@ -2074,6 +2099,7 @@ class CaseResult:
|
|
|
2074
2099
|
passed: bool
|
|
2075
2100
|
runs: list[RunResult]
|
|
2076
2101
|
pass_rate: float
|
|
2102
|
+
description: str = "" # Case 顶层 description 的透传,供 CLI/JSON 输出展示
|
|
2077
2103
|
```
|
|
2078
2104
|
|
|
2079
2105
|
```python
|
|
@@ -2391,21 +2417,91 @@ Step——不是按 Plugin 拆开的多个文件,也没有 JSON 版的 `summar
|
|
|
2391
2417
|
<result_root 的上级>/reports/latest.html # --report 省略路径时的默认位置
|
|
2392
2418
|
```
|
|
2393
2419
|
|
|
2394
|
-
终端输出(不用 `--json`
|
|
2420
|
+
终端输出(不用 `--json` 时)在执行过程中**实时流式打印进度**,形态取决于并发模式
|
|
2421
|
+
(见 4.3 节的 `--concurrency`);两种模式最后都以逐 Case 的汇总表格收尾。
|
|
2422
|
+
|
|
2423
|
+
**顺序模式**(`--concurrency 1`,或只收集到一个 Case):每个 Case、Run、Step
|
|
2424
|
+
一完成就立即打印结果(含每条 hard check 的通过情况与失败详情、Judge 结论):
|
|
2395
2425
|
|
|
2396
2426
|
```text
|
|
2427
|
+
[1/2] <case_key>
|
|
2428
|
+
<description,若有>
|
|
2429
|
+
Run 1/2
|
|
2430
|
+
✓ <step_id> hard checks 3/3 judge passed 92%
|
|
2431
|
+
├── ✓ 01 <hard check label>
|
|
2432
|
+
└── ✗ 02 <hard check label>
|
|
2433
|
+
├── Expected ...
|
|
2434
|
+
├── Actual ...
|
|
2435
|
+
└── Reason ...
|
|
2436
|
+
✓ <case_key> 2/2 runs passed 100%
|
|
2437
|
+
|
|
2397
2438
|
Yama Eval Results
|
|
2398
|
-
Result | Case | Runs | Pass rate
|
|
2439
|
+
Result | Case(含 description 副行) | Runs | Pass rate
|
|
2399
2440
|
...
|
|
2400
|
-
Details
|
|
2401
|
-
✓ <case_key> 100%
|
|
2402
|
-
✓ Run 1
|
|
2403
|
-
✓ <step_id> hard checks 3/3 judge passed 92%
|
|
2404
|
-
✓ 01 <hard check label>
|
|
2405
2441
|
```
|
|
2406
2442
|
|
|
2407
|
-
|
|
2408
|
-
|
|
2443
|
+
**并发模式**(并发 >1 且收集到多个 Case,默认即是):不同 Case 的 Step 结果会
|
|
2444
|
+
乱序到达,逐 Step 流式打印会把不相关 Case 的行交错在错误的 Case 标题下,因此改为
|
|
2445
|
+
在终端底部维护一张**原地刷新的逐 Case 状态面板**(transient `rich Live`):每个
|
|
2446
|
+
收集到的 Case 固定占一行、按收集顺序排列,状态原地更新——`waiting`(排队等并发
|
|
2447
|
+
槽位)→ spinner + 当前 `Run k/n · <step_id>` → `✓/✗` 加简要结果。任何一个 Case
|
|
2448
|
+
一完成,它的完整 Run/Step/断言明细就作为**一个整块**打印到面板上方(块内结构与
|
|
2449
|
+
顺序模式相同),块与块绝不交错;全部结束后面板消失,汇总表格收尾。面板只在 TTY
|
|
2450
|
+
上渲染,管道/CI 输出只得到按完成顺序追加的 Case 块;结果数组与汇总表格仍按收集
|
|
2451
|
+
顺序:
|
|
2452
|
+
|
|
2453
|
+
```text
|
|
2454
|
+
(面板上方,按完成顺序逐块追加)
|
|
2455
|
+
✓ <case_key B> 100%
|
|
2456
|
+
├── ✓ Run 1
|
|
2457
|
+
│ └── ✓ <step_id> hard checks 3/3
|
|
2458
|
+
...
|
|
2459
|
+
|
|
2460
|
+
(终端底部的临时面板,逐行原地刷新)
|
|
2461
|
+
⠧ <case_key A> Run 1/2 · <step_id>
|
|
2462
|
+
✓ <case_key B> 1/1 runs 100%
|
|
2463
|
+
· <case_key C> waiting
|
|
2464
|
+
```
|
|
2465
|
+
|
|
2466
|
+
流式进度由 `YamaRunner` 的进度回调驱动(`runner.py:RunnerEventCallback`,
|
|
2467
|
+
构造参数 `on_event`)。每个 Case 的事件顺序固定为:`case_start`
|
|
2468
|
+
`{case_key, description, repeat}` → 每个 run:`run_start` `{case_key, run_index,
|
|
2469
|
+
repeat}` → 每个 Step:`step_start` `{case_key, run_index, step_id}`、`step_end`
|
|
2470
|
+
`{case_key, run_index, step: StepResult}` → `run_end` `{case_key, run:
|
|
2471
|
+
RunResult}` → `case_end` `{result: CaseResult}`。`step_end` 在该 Step 的 hard
|
|
2472
|
+
check 与 Judge 都结算完之后才触发(含 max-tool-rounds 失败的 Step),payload
|
|
2473
|
+
携带的是最终判定;run 在 Step 中途死掉(超时、Handler 异常)时该 Step 没有
|
|
2474
|
+
`step_end`,但 `run_end` 仍会触发(在产物写盘之后)。并发执行时多个 Case 的事件
|
|
2475
|
+
流会在时间上交错,但单个 Case 内部的事件顺序不变(每个事件 payload 都带
|
|
2476
|
+
`case_key` 可供归属)。
|
|
2477
|
+
|
|
2478
|
+
CLI 侧按并发模式挑选回调实现,两者的**已完成结果**都只做顺序追加打印(不回改
|
|
2479
|
+
已输出内容),管道/CI 日志中同样可读;动态元素(spinner/面板)都是 transient
|
|
2480
|
+
的、仅 TTY 可见:
|
|
2481
|
+
|
|
2482
|
+
- `cli.py:ProgressPrinter`(顺序模式):逐事件流式打印;唯一的动态元素是
|
|
2483
|
+
`step_start` 到下一个事件之间显示的临时 spinner(`rich Status`,标出正在执行的
|
|
2484
|
+
Step),任何后续事件到来都会先停掉它再打印。
|
|
2485
|
+
- `cli.py:ParallelProgressPrinter`(并发模式):构造时接收全部收集到的 Case,
|
|
2486
|
+
为每个 Case 预建一行 `waiting` 状态;`case_start`/`run_start`/`step_start`
|
|
2487
|
+
只原地更新对应行的状态(首个事件时惰性启动 transient `rich Live` 面板,
|
|
2488
|
+
`get_renderable` 每个刷新帧重建全部行——事件处理只整体替换行 dict、从不原地
|
|
2489
|
+
改写,避免与 Live 的刷新线程读写竞争);`case_end` 用 `build_case_tree` 从最终
|
|
2490
|
+
`CaseResult` 渲染整 Case 块打印到面板上方,并把该行翻成 `✓/✗`;最后一个
|
|
2491
|
+
`case_end` 后自动停掉面板。某个 Case 在 `case_end` 之前异常退出时面板不会自行
|
|
2492
|
+
停止,由 `cli.py:_run` 在 `gather` 结束后统一调用 `progress.close()` 兜底
|
|
2493
|
+
(两个 printer 都实现了 `close()`)。两个容易回归的实现约束:
|
|
2494
|
+
- 所有 running 行共用**构造期创建的单个 `rich Spinner` 实例**(行内容每帧
|
|
2495
|
+
重建,但 spinner 不能跟着重建——`Spinner.start_time` 会被每帧重置,动画
|
|
2496
|
+
永远冻结在第 0 帧)。
|
|
2497
|
+
- 面板在 TTY 上启动时用 termios 关闭 stdin 回显(`ECHO|ECHONL`),`close()`
|
|
2498
|
+
恢复。否则用户随手按下的回车会被终端回显成换行、顶移光标,Live 依赖
|
|
2499
|
+
"自己画了几行"回退光标重绘,起点一失位就把面板首行残留进滚动区(表现为
|
|
2500
|
+
某一行被不断重复)。stdin 不是 TTY 或 termios 失败时静默跳过。
|
|
2501
|
+
|
|
2502
|
+
`--json` 输出机器可读的 `[CaseResult.to_dict(), ...]` 数组(此时进度流打印到
|
|
2503
|
+
stderr,保证 stdout 是纯 JSON);`--list` 只打印 `case_key` 列表,不运行任何
|
|
2504
|
+
Case。
|
|
2409
2505
|
|
|
2410
2506
|
`cli.py:main` 的错误出口按层归类(退出码都是 2):`ConfigurationError`/
|
|
2411
2507
|
`CollectionError`/`ValueError` 打印 `Collection error: ...`(Case 还没跑起来,
|
|
@@ -2495,9 +2591,10 @@ Details
|
|
|
2495
2591
|
`ScriptedLLMClient` 能回放 **LLM 响应**,没有对应的 Tool Call 录制/回放机制。
|
|
2496
2592
|
- **参数矩阵**:对同一 Case 用多组参数矩阵批量展开执行——当前 `execution.repeat`
|
|
2497
2593
|
只是一个单纯的重复次数整数,不是参数矩阵。
|
|
2498
|
-
- **HTML Transcript Viewer 的进一步能力**、**人工评分与 Judge
|
|
2594
|
+
- **HTML Transcript Viewer 的进一步能力**、**人工评分与 Judge 校准**、**远程
|
|
2499
2595
|
执行**:`report.py` 目前只产出一个静态汇总 HTML,没有专门的单 Case 交互式
|
|
2500
|
-
Transcript Viewer;Case
|
|
2596
|
+
Transcript Viewer;Case 级的本地并发调度已实现(CLI `--concurrency`,默认 10,
|
|
2597
|
+
见 4.3 节),但仍没有把执行分发到远程机器的能力。
|
|
2501
2598
|
|
|
2502
2599
|
已经完成、且与原设计基本对齐或已按上文修正描述的能力(供快速核对现状):
|
|
2503
2600
|
|
|
@@ -31,7 +31,8 @@ Context(System Prompt / Skill / Tool Schema / 历史消息)、Tool 如何被
|
|
|
31
31
|
|
|
32
32
|
Case 内所有相对路径(`context.tools` 的 `file:`、`mocks.cli`/`mocks.fs` 的文件引用、
|
|
33
33
|
Python Handler/Checker 路径、fixture 路径)一律相对 `__evals__` 目录解析。
|
|
34
|
-
Case 文件相对 Plugin Root 的路径就是它的唯一身份 `case_key`,不需要在文件里声明 id
|
|
34
|
+
Case 文件相对 Plugin Root 的路径就是它的唯一身份 `case_key`,不需要在文件里声明 id;
|
|
35
|
+
可选的顶层 `description` 用一句话说明该 Case 测试什么,会展示在 CLI 输出和 HTML 报告中。
|
|
35
36
|
|
|
36
37
|
## 编写用例
|
|
37
38
|
|
|
@@ -39,6 +40,8 @@ Case 文件相对 Plugin Root 的路径就是它的唯一身份 `case_key`,不
|
|
|
39
40
|
`steps`(依次发送的用户回合与断言)→ `outcome`(Case 级通过门槛):
|
|
40
41
|
|
|
41
42
|
```yaml
|
|
43
|
+
description: 模型应先读 DSL 再给出差异化的创意方向 # 可省略,展示在 CLI 与报告中
|
|
44
|
+
|
|
42
45
|
model: { name: gpt-5, temperature: 0 } # 可省略,继承 yama.toml 默认
|
|
43
46
|
|
|
44
47
|
context:
|
|
@@ -134,6 +137,11 @@ yama __evals__/cases/foo.yaml
|
|
|
134
137
|
yama --list
|
|
135
138
|
```
|
|
136
139
|
|
|
140
|
+
多个 Case 默认并行执行(最多同时 10 个,`--concurrency N` 调整;Case 内的多个
|
|
141
|
+
run 仍顺序执行)。并行时终端底部有一张原地刷新的逐 Case 状态面板(等待/执行中的
|
|
142
|
+
Run·Step/✓✗),每个 Case 的 Run/Step 明细在该 Case 完成后整块打印到面板上方;
|
|
143
|
+
需要逐 Step 实时流式输出来盯一个用例时,用 `--concurrency 1` 或只跑那一个 Case。
|
|
144
|
+
|
|
137
145
|
退出码:`0` 全部通过;`1` 有 Case 失败;`2` Collection error、LLM error
|
|
138
146
|
(stderr 分别打印 `Collection error: ...` / `LLM error: ...`)或没收集到任何
|
|
139
147
|
Case;`130` 手动中断。
|