python-yama 0.2.0__py3-none-any.whl → 0.3.0__py3-none-any.whl

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-yama
3
- Version: 0.2.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.
@@ -1,15 +1,15 @@
1
1
  yama/__init__.py,sha256=UYhoZTSu1HiMT54LOZCdvLKMQ_L0qec8RT8jDfde_cY,1156
2
2
  yama/__main__.py,sha256=k1ocEWawweo1qCJWNFAAvyxz3tcY13dzvCenHszij30,48
3
3
  yama/assertions.py,sha256=0x1r82W2dtAY1mTk4LC86VulD5Q9blS7QeRCTysb4kE,21736
4
- yama/cli.py,sha256=RJcffqSX2DTUU8i6PB2ZyPMXuACCpBuj_Ifm-uQ4j9g,11736
4
+ yama/cli.py,sha256=Fsl-GROEQJx9hHs5qSlAtZTkEaeCU2TY6S8IhmJmmzM,23203
5
5
  yama/llm.py,sha256=XqGE4aKPOimy9n3oNF5rUvqWdJlpi0EVzMlD-FBim6A,13570
6
6
  yama/mocks.py,sha256=YyiU6Y7NgttxHYJBsqGPILKYlTsM4IMTIilMNRkUuzs,14973
7
- yama/models.py,sha256=-ry0QUI2e0ialL6A9NUEAM0QpwCQg8oXEfPBXn3CvNI,3964
8
- yama/report.py,sha256=bjp_aev2KHx3i2pqYRGE1VHTuBmiakXgbqYjN3RAGEg,37558
9
- yama/runner.py,sha256=dJi-hxXxpUawZ3g14Hk9NFZy7HQNvcGpxpxvj8QKbX8,21694
7
+ yama/models.py,sha256=FeKOYS4MAQhDPyhAyd4pPvQH015w5hOJqhNzTZHYRgI,3990
8
+ yama/report.py,sha256=csceNtljXd--palHhvdVIXsPYs7uF_C1xUkLfoWPZbc,37824
9
+ yama/runner.py,sha256=9JXlJPSEFHKrZETdso5BCR_SQZ97lEzpP0ZwyYz5o0g,23823
10
10
  yama/workspace.py,sha256=rHQ9kQUkAo32gJpqRf7pSd5JhBc05xgxA1wPRC4bOQ8,3618
11
11
  yama/loaders/__init__.py,sha256=DIwfa8QlIlKt6NpFMZJ_OcqbJPPrmKLBzd9_e-BCuBs,174
12
- yama/loaders/case.py,sha256=gas5J9jtPuaqo43IO5gk-4uVJ49JWc7sNMXFI8I_7AA,14255
12
+ yama/loaders/case.py,sha256=Kh37rtT30lxkCRZ6wA3fo8_tTxeTeN0d0c-OTqkfSSY,14532
13
13
  yama/loaders/common.py,sha256=Fg71_vcnu5339QI_itvYPvRbk9LtBgEnzoA3t4Krb4U,754
14
14
  yama/loaders/tool_loader.py,sha256=BubcplVYKiJxgNsMKGRfiRiK1qVo0EvJfLOJzQEx9js,6388
15
15
  yama/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -20,8 +20,8 @@ yama/tools/bash/bash.py,sha256=4GlFvmqTUS4k6DgJ5Io91YF5fB6wF6e3e7p2P-pmbEQ,10358
20
20
  yama/tools/bash/fs.py,sha256=ncLZf4_gErRP3HHXinLEQeN6chrf7JaSiaTuadVl8MY,21314
21
21
  yama/tools/skill/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
22
  yama/tools/skill/skill.py,sha256=P2rDz6VqRLfhiabWjOU3ZBaWLw30Eywf3o_OxVfFbPI,1992
23
- python_yama-0.2.0.dist-info/METADATA,sha256=TuKyzkSIHUvjSVNTBj6YYErZjK91mznGMs6gFBFLCmg,4598
24
- python_yama-0.2.0.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
25
- python_yama-0.2.0.dist-info/entry_points.txt,sha256=N5se3y1FflUcDU3TmUrH2Tu9dzsrBBo7sUP-Gu_2cVs,39
26
- python_yama-0.2.0.dist-info/licenses/LICENSE,sha256=cMAJJAs7R1lemJPPc7qMNv4w_sqn5QncFf4aXKYyEc4,1067
27
- python_yama-0.2.0.dist-info/RECORD,,
23
+ python_yama-0.3.0.dist-info/METADATA,sha256=GK8pJCJR0KCRpRfc5FQ0YvAZ2Pym-HSGGnsSn8U30l8,5830
24
+ python_yama-0.3.0.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
25
+ python_yama-0.3.0.dist-info/entry_points.txt,sha256=N5se3y1FflUcDU3TmUrH2Tu9dzsrBBo7sUP-Gu_2cVs,39
26
+ python_yama-0.3.0.dist-info/licenses/LICENSE,sha256=cMAJJAs7R1lemJPPc7qMNv4w_sqn5QncFf4aXKYyEc4,1067
27
+ python_yama-0.3.0.dist-info/RECORD,,
yama/cli.py CHANGED
@@ -3,12 +3,17 @@ from __future__ import annotations
3
3
  import argparse
4
4
  import asyncio
5
5
  import json
6
+ import sys
6
7
  from io import StringIO
7
8
  from pathlib import Path
8
9
  from typing import Any
9
10
 
10
11
  from rich import box
11
12
  from rich.console import Console, Group
13
+ from rich.live import Live
14
+ from rich.padding import Padding
15
+ from rich.spinner import Spinner
16
+ from rich.status import Status
12
17
  from rich.table import Table
13
18
  from rich.text import Text
14
19
  from rich.tree import Tree
@@ -38,7 +43,109 @@ def _summary_case_key(case_key: str) -> str:
38
43
  return case_key.removeprefix(prefix)
39
44
 
40
45
 
41
- def build_results_renderable(results: list[Any]) -> Group:
46
+ def build_step_tree(step: Any) -> Tree:
47
+ """Per-step verdict subtree (hard checks + judge dimensions).
48
+
49
+ Shared by the live progress output (printed as soon as the step's
50
+ assertions settle) and the aggregated details of `format_text_results`.
51
+ """
52
+ failed = [
53
+ check for check in step.hard_checks if not check.get("passed", False)
54
+ ]
55
+ judge = step.judge_result
56
+ judge_passed = judge is None or bool(judge.get("passed", False))
57
+ step_passed = not failed and step.hard_pass and judge_passed
58
+ hard_passed = len(step.hard_checks) - len(failed)
59
+ step_label = Text.assemble(
60
+ _status(step_passed, compact=True),
61
+ " ",
62
+ (step.step_id, "bold"),
63
+ (
64
+ f" hard checks {hard_passed}/{len(step.hard_checks)}",
65
+ "dim",
66
+ ),
67
+ )
68
+ if judge is not None:
69
+ step_label.append(" judge ", style="dim")
70
+ step_label.append(
71
+ "passed" if judge_passed else "failed",
72
+ style="green" if judge_passed else "bold red",
73
+ )
74
+ if isinstance(judge.get("overall"), (int, float)):
75
+ step_label.append(f" {judge['overall']:.0%}", style="dim")
76
+ step_node = Tree(step_label, guide_style="dim")
77
+ if judge is not None and not judge_passed:
78
+ judge_node = step_node.add(Text("Judge dimensions", style="bold red"))
79
+ for dimension in judge.get("dimensions", []):
80
+ dimension_label = Text.assemble(
81
+ (str(dimension.get("name", "unnamed")), "bold"),
82
+ f": {dimension.get('score', '?')}/5",
83
+ )
84
+ if dimension.get("reason"):
85
+ dimension_label.append(
86
+ f" {dimension['reason']}", style="dim"
87
+ )
88
+ judge_node.add(dimension_label)
89
+ for index, check in enumerate(step.hard_checks, 1):
90
+ label = check.get("label") or check.get("type", "hard check")
91
+ if check.get("passed", False):
92
+ step_node.add(
93
+ Text.assemble(
94
+ _status(True, compact=True),
95
+ " ",
96
+ (f"{index:02d} {label}", "green"),
97
+ )
98
+ )
99
+ continue
100
+ expected = check.get("expected", "assertion passes")
101
+ actual = check.get("actual", check.get("detail", "unknown"))
102
+ reason = check.get("reason", check.get("detail", "assertion failed"))
103
+ check_node = step_node.add(
104
+ Text.assemble(
105
+ _status(False, compact=True),
106
+ " ",
107
+ (f"{index:02d} {label}", "bold red"),
108
+ )
109
+ )
110
+ check_node.add(
111
+ Text.assemble(("Expected ", "bold cyan"), str(expected))
112
+ )
113
+ check_node.add(
114
+ Text.assemble(("Actual ", "bold yellow"), str(actual))
115
+ )
116
+ check_node.add(
117
+ Text.assemble(("Reason ", "bold red"), str(reason))
118
+ )
119
+ return step_node
120
+
121
+
122
+ def build_case_tree(result: Any) -> Tree:
123
+ """Whole-case verdict tree (runs -> steps), shared by the aggregated
124
+ details of `format_text_results` and the parallel progress output."""
125
+ case_label = Text.assemble(
126
+ _status(result.passed, compact=True),
127
+ " ",
128
+ (result.case_key, "bold"),
129
+ (f" {result.pass_rate:.0%}", "dim"),
130
+ )
131
+ if result.description:
132
+ case_label.append(f"\n{result.description}", style="dim")
133
+ tree = Tree(case_label, guide_style="dim")
134
+ for run in result.runs:
135
+ run_node = tree.add(
136
+ Text.assemble(
137
+ _status(run.passed, compact=True),
138
+ " ",
139
+ (f"Run {run.run_index}", "bold"),
140
+ )
141
+ )
142
+ if run.error:
143
+ run_node.add(Text.assemble(("Error: ", "bold red"), (run.error, "red")))
144
+ run_node.children.extend(build_step_tree(step) for step in run.steps)
145
+ return tree
146
+
147
+
148
+ def build_summary_table(results: list[Any]) -> Table:
42
149
  table = Table(
43
150
  title="Yama Eval Results",
44
151
  box=box.SIMPLE_HEAVY,
@@ -57,9 +164,12 @@ def build_results_renderable(results: list[Any]) -> Group:
57
164
  case_passed_runs = sum(run.passed for run in result.runs)
58
165
  passed_runs += case_passed_runs
59
166
  total_runs += len(result.runs)
167
+ case_cell = Text(_summary_case_key(result.case_key))
168
+ if result.description:
169
+ case_cell.append(f"\n{result.description}", style="dim")
60
170
  table.add_row(
61
171
  _status(result.passed),
62
- Text(_summary_case_key(result.case_key)),
172
+ case_cell,
63
173
  f"{case_passed_runs}/{len(result.runs)}",
64
174
  f"{result.pass_rate:.0%}",
65
175
  )
@@ -70,97 +180,244 @@ def build_results_renderable(results: list[Any]) -> Group:
70
180
  f"{passed_runs}/{total_runs} runs passed"
71
181
  )
72
182
  table.caption_style = "green" if passed_cases == len(results) else "red"
183
+ return table
184
+
73
185
 
186
+ def build_results_renderable(results: list[Any]) -> Group:
187
+ table = build_summary_table(results)
74
188
  details = Tree(Text("Details", style="bold"), guide_style="dim")
75
- for result in results:
76
- case_label = Text.assemble(
77
- _status(result.passed, compact=True),
78
- " ",
79
- (result.case_key, "bold"),
80
- (f" {result.pass_rate:.0%}", "dim"),
81
- )
82
- case_node = details.add(case_label)
83
- for run in result.runs:
84
- run_label = Text.assemble(
85
- _status(run.passed, compact=True),
86
- " ",
87
- (f"Run {run.run_index}", "bold"),
189
+ details.children.extend(build_case_tree(result) for result in results)
190
+ return Group(table, Text(), details)
191
+
192
+
193
+ class ProgressPrinter:
194
+ """Print case/run/step results the moment YamaRunner completes them.
195
+
196
+ Wired into `YamaRunner(on_event=...)`. Completed results are append-only
197
+ lines, so they stay intact when piped or captured in CI logs; the only
198
+ live element is a transient spinner shown while a step is executing
199
+ (animated on a terminal, invisible in non-interactive output).
200
+ """
201
+
202
+ def __init__(self, console: Console, total_cases: int) -> None:
203
+ self.console = console
204
+ self.total_cases = total_cases
205
+ self._case_index = 0
206
+ self._spinner: Status | None = None
207
+
208
+ def _stop_spinner(self) -> None:
209
+ if self._spinner is not None:
210
+ self._spinner.stop()
211
+ self._spinner = None
212
+
213
+ def close(self) -> None:
214
+ """Stop the live element when no further events will arrive (a case
215
+ that dies before its case_end otherwise leaves the spinner running)."""
216
+ self._stop_spinner()
217
+
218
+ def __call__(self, event: str, payload: dict[str, Any]) -> None:
219
+ # Whatever comes in, the previous "step is executing" spinner is over.
220
+ self._stop_spinner()
221
+ if event == "step_start":
222
+ self._spinner = self.console.status(
223
+ Text.assemble(
224
+ ("running ", "dim"),
225
+ (payload["step_id"], "bold"),
226
+ (" …", "dim"),
227
+ ),
228
+ spinner="dots",
229
+ )
230
+ self._spinner.start()
231
+ elif event == "case_start":
232
+ self._case_index += 1
233
+ self.console.print(
234
+ Text.assemble(
235
+ (f"[{self._case_index}/{self.total_cases}] ", "bold cyan"),
236
+ (payload["case_key"], "bold"),
237
+ )
88
238
  )
89
- run_node = case_node.add(run_label)
239
+ if payload["description"]:
240
+ self.console.print(
241
+ Padding(Text(payload["description"], style="dim"), (0, 0, 0, 2))
242
+ )
243
+ elif event == "run_start":
244
+ self.console.print(
245
+ Padding(
246
+ Text(
247
+ f"Run {payload['run_index']}/{payload['repeat']}",
248
+ style="bold",
249
+ ),
250
+ (0, 0, 0, 2),
251
+ )
252
+ )
253
+ elif event == "step_end":
254
+ self.console.print(Padding(build_step_tree(payload["step"]), (0, 0, 0, 4)))
255
+ elif event == "run_end":
256
+ run = payload["run"]
90
257
  if run.error:
91
- run_node.add(Text.assemble(("Error: ", "bold red"), (run.error, "red")))
92
- for step in run.steps:
93
- failed = [
94
- check
95
- for check in step.hard_checks
96
- if not check.get("passed", False)
97
- ]
98
- judge = step.judge_result
99
- judge_passed = judge is None or bool(judge.get("passed", False))
100
- step_passed = not failed and step.hard_pass and judge_passed
101
- hard_passed = len(step.hard_checks) - len(failed)
102
- step_label = Text.assemble(
103
- _status(step_passed, compact=True),
258
+ self.console.print(
259
+ Padding(
260
+ Text.assemble(("Error: ", "bold red"), (run.error, "red")),
261
+ (0, 0, 0, 4),
262
+ )
263
+ )
264
+ elif event == "case_end":
265
+ result = payload["result"]
266
+ passed_runs = sum(run.passed for run in result.runs)
267
+ self.console.print(
268
+ Text.assemble(
269
+ _status(result.passed, compact=True),
104
270
  " ",
105
- (step.step_id, "bold"),
271
+ (result.case_key, "bold"),
106
272
  (
107
- f" hard checks {hard_passed}/{len(step.hard_checks)}",
273
+ f" {passed_runs}/{len(result.runs)} runs passed"
274
+ f" {result.pass_rate:.0%}",
108
275
  "dim",
109
276
  ),
110
277
  )
111
- if judge is not None:
112
- step_label.append(" judge ", style="dim")
113
- step_label.append(
114
- "passed" if judge_passed else "failed",
115
- style="green" if judge_passed else "bold red",
116
- )
117
- if isinstance(judge.get("overall"), (int, float)):
118
- step_label.append(f" {judge['overall']:.0%}", style="dim")
119
- step_node = run_node.add(step_label)
120
- if judge is not None and not judge_passed:
121
- judge_node = step_node.add(Text("Judge dimensions", style="bold red"))
122
- for dimension in judge.get("dimensions", []):
123
- dimension_label = Text.assemble(
124
- (str(dimension.get("name", "unnamed")), "bold"),
125
- f": {dimension.get('score', '?')}/5",
126
- )
127
- if dimension.get("reason"):
128
- dimension_label.append(
129
- f" {dimension['reason']}", style="dim"
130
- )
131
- judge_node.add(dimension_label)
132
- for index, check in enumerate(step.hard_checks, 1):
133
- label = check.get("label") or check.get("type", "hard check")
134
- if check.get("passed", False):
135
- step_node.add(
136
- Text.assemble(
137
- _status(True, compact=True),
138
- " ",
139
- (f"{index:02d} {label}", "green"),
140
- )
141
- )
142
- continue
143
- expected = check.get("expected", "assertion passes")
144
- actual = check.get("actual", check.get("detail", "unknown"))
145
- reason = check.get("reason", check.get("detail", "assertion failed"))
146
- check_node = step_node.add(
147
- Text.assemble(
148
- _status(False, compact=True),
149
- " ",
150
- (f"{index:02d} {label}", "bold red"),
151
- )
152
- )
153
- check_node.add(
154
- Text.assemble(("Expected ", "bold cyan"), str(expected))
155
- )
156
- check_node.add(
157
- Text.assemble(("Actual ", "bold yellow"), str(actual))
158
- )
159
- check_node.add(
160
- Text.assemble(("Reason ", "bold red"), str(reason))
278
+ )
279
+ self.console.print()
280
+
281
+
282
+ class ParallelProgressPrinter:
283
+ """Live per-case dashboard for concurrently running cases.
284
+
285
+ Wired into `YamaRunner(on_event=...)` when cases run concurrently
286
+ (--concurrency > 1 with several cases collected): ProgressPrinter's
287
+ per-step stream would interleave lines of unrelated cases under the
288
+ wrong case header. Instead, every collected case gets one row in a
289
+ transient live panel, updated in place as its state changes --
290
+ waiting for a slot, then a spinner with the run/step currently
291
+ executing, then its final compact verdict -- and a case's full
292
+ run/step detail is printed above the panel as one block the moment
293
+ its case_end verdict settles. The panel only renders on a terminal;
294
+ piped/CI output just gets the append-only case blocks.
295
+ """
296
+
297
+ def __init__(self, console: Console, cases: list[Any]) -> None:
298
+ self.console = console
299
+ self._rows: dict[str, dict[str, Any]] = {
300
+ case.case_key: {"status": "waiting"} for case in cases
301
+ }
302
+ self._finished = 0
303
+ self._live: Live | None = None
304
+ # One Spinner shared by every running row: recreating spinners on
305
+ # each refresh frame would reset their start_time every time and
306
+ # freeze the glyph on frame zero.
307
+ self._spinner = Spinner("dots", style="cyan")
308
+ self._saved_termios: list[Any] | None = None
309
+
310
+ def close(self) -> None:
311
+ """Stop the live panel when no further events will arrive (a case
312
+ that dies before its case_end otherwise leaves the panel running)."""
313
+ if self._live is not None:
314
+ self._live.stop()
315
+ self._live = None
316
+ self._set_input_echo(True)
317
+
318
+ def _set_input_echo(self, enabled: bool) -> None:
319
+ """Keystrokes echoed while the panel is live (a stray Enter) shift
320
+ the cursor under Live's feet, desyncing its repaint origin and
321
+ leaving stale copies of the panel's top line behind -- so terminal
322
+ echo is disabled while the panel is up and restored when it stops."""
323
+ try:
324
+ import termios
325
+ except ImportError: # pragma: no cover - non-POSIX platform
326
+ return
327
+ try:
328
+ if enabled:
329
+ if self._saved_termios is not None:
330
+ termios.tcsetattr(
331
+ sys.stdin.fileno(), termios.TCSADRAIN, self._saved_termios
161
332
  )
333
+ self._saved_termios = None
334
+ return
335
+ if not sys.stdin.isatty():
336
+ return
337
+ fd = sys.stdin.fileno()
338
+ self._saved_termios = termios.tcgetattr(fd)
339
+ mode = termios.tcgetattr(fd)
340
+ mode[3] &= ~(termios.ECHO | termios.ECHONL)
341
+ termios.tcsetattr(fd, termios.TCSADRAIN, mode)
342
+ except (ValueError, OSError, termios.error):
343
+ self._saved_termios = None
162
344
 
163
- return Group(table, Text(), details)
345
+ def _render(self) -> Table:
346
+ # Rows are rebuilt from scratch on every refresh tick; the tick runs
347
+ # on Live's refresh thread, so event handling only ever swaps whole
348
+ # row dicts (never mutates one in place) to keep reads consistent.
349
+ grid = Table.grid(padding=(0, 1))
350
+ for case_key, row in self._rows.items():
351
+ if row["status"] == "waiting":
352
+ grid.add_row(
353
+ Text("·", style="dim"),
354
+ Text.assemble((case_key, "dim"), (" waiting", "dim")),
355
+ )
356
+ elif row["status"] == "running":
357
+ progress = ""
358
+ if row.get("run_index"):
359
+ progress = f" Run {row['run_index']}/{row['repeat']}"
360
+ if row.get("step_id"):
361
+ progress += f" · {row['step_id']}"
362
+ grid.add_row(
363
+ self._spinner,
364
+ Text.assemble((case_key, "bold"), (progress, "dim")),
365
+ )
366
+ else:
367
+ result = row["result"]
368
+ passed_runs = sum(run.passed for run in result.runs)
369
+ grid.add_row(
370
+ _status(result.passed, compact=True),
371
+ Text.assemble(
372
+ (case_key, "bold"),
373
+ (
374
+ f" {passed_runs}/{len(result.runs)} runs"
375
+ f" {result.pass_rate:.0%}",
376
+ "dim",
377
+ ),
378
+ ),
379
+ )
380
+ return grid
381
+
382
+ def _ensure_live(self) -> None:
383
+ if self._live is None:
384
+ if self.console.is_terminal:
385
+ self._set_input_echo(False)
386
+ self._live = Live(
387
+ get_renderable=self._render,
388
+ console=self.console,
389
+ transient=True,
390
+ refresh_per_second=12.5,
391
+ )
392
+ self._live.start()
393
+
394
+ def __call__(self, event: str, payload: dict[str, Any]) -> None:
395
+ if event == "case_start":
396
+ self._ensure_live()
397
+ self._rows[payload["case_key"]] = {
398
+ "status": "running",
399
+ "repeat": payload["repeat"],
400
+ }
401
+ elif event in {"run_start", "step_start"}:
402
+ row = self._rows.get(payload["case_key"])
403
+ if row is None or row["status"] != "running":
404
+ return
405
+ row = dict(row)
406
+ if event == "run_start":
407
+ row["run_index"] = payload["run_index"]
408
+ row["repeat"] = payload["repeat"]
409
+ row["step_id"] = None
410
+ else:
411
+ row["step_id"] = payload["step_id"]
412
+ self._rows[payload["case_key"]] = row
413
+ elif event == "case_end":
414
+ result = payload["result"]
415
+ self._rows[result.case_key] = {"status": "done", "result": result}
416
+ self._finished += 1
417
+ self.console.print(build_case_tree(result))
418
+ self.console.print()
419
+ if self._finished >= len(self._rows):
420
+ self.close()
164
421
 
165
422
 
166
423
  def format_text_results(results: list[Any]) -> str:
@@ -176,6 +433,16 @@ def format_text_results(results: list[Any]) -> str:
176
433
  return output.getvalue().rstrip()
177
434
 
178
435
 
436
+ def _positive_int(value: str) -> int:
437
+ try:
438
+ number = int(value)
439
+ except ValueError:
440
+ raise argparse.ArgumentTypeError(f"invalid int value: {value!r}")
441
+ if number < 1:
442
+ raise argparse.ArgumentTypeError("must be at least 1")
443
+ return number
444
+
445
+
179
446
  def _parser() -> argparse.ArgumentParser:
180
447
  parser = argparse.ArgumentParser(
181
448
  prog="yama", description="Run Agent Skill eval cases"
@@ -191,6 +458,16 @@ def _parser() -> argparse.ArgumentParser:
191
458
  "--all-plugins", action="store_true", help="Run all configured plugins"
192
459
  )
193
460
  parser.add_argument("--result-dir", type=Path, help="Override artifact directory")
461
+ parser.add_argument(
462
+ "--concurrency",
463
+ type=_positive_int,
464
+ default=10,
465
+ metavar="N",
466
+ help=(
467
+ "Maximum number of cases to run in parallel"
468
+ " (default: 10; 1 runs cases sequentially with the live step stream)"
469
+ ),
470
+ )
194
471
  parser.add_argument(
195
472
  "--report",
196
473
  type=Path,
@@ -252,22 +529,52 @@ async def _run(args: argparse.Namespace) -> int:
252
529
  Console(stderr=True).print("[bold red]No eval cases collected.[/bold red]")
253
530
  return 2
254
531
 
255
- llm = LiteLLMClient()
256
- all_results = []
257
- result_roots = []
258
- for case in collected:
259
- result_root = (
260
- args.result_dir.resolve()
261
- if args.result_dir
262
- else case.plugin_root / workspace.result_dir
263
- )
264
- result_roots.append(result_root)
265
- runner = YamaRunner(
266
- llm,
267
- result_root=result_root,
268
- write_artifacts=not args.no_artifacts,
532
+ # With --json, stdout must stay valid JSON, so live progress moves to
533
+ # stderr instead of disappearing.
534
+ progress_console = Console(stderr=args.json)
535
+ parallel = args.concurrency > 1 and len(collected) > 1
536
+ progress: ProgressPrinter | ParallelProgressPrinter = (
537
+ ParallelProgressPrinter(progress_console, cases=collected)
538
+ if parallel
539
+ else ProgressPrinter(progress_console, total_cases=len(collected))
540
+ )
541
+ result_roots = [
542
+ args.result_dir.resolve()
543
+ if args.result_dir
544
+ else case.plugin_root / workspace.result_dir
545
+ for case in collected
546
+ ]
547
+ semaphore = asyncio.Semaphore(args.concurrency)
548
+
549
+ async def run_one(case: Any, result_root: Path) -> Any:
550
+ async with semaphore:
551
+ # One LLM client per case: the runner reads last_request /
552
+ # last_provider back after every complete(), which concurrently
553
+ # running cases would clobber on a shared client.
554
+ runner = YamaRunner(
555
+ LiteLLMClient(),
556
+ result_root=result_root,
557
+ write_artifacts=not args.no_artifacts,
558
+ on_event=progress,
559
+ )
560
+ return await runner.run_case(case)
561
+
562
+ try:
563
+ # return_exceptions lets every case finish (and write its artifacts)
564
+ # before the first failure is re-raised for main()'s error handling.
565
+ outcomes = await asyncio.gather(
566
+ *(
567
+ run_one(case, result_root)
568
+ for case, result_root in zip(collected, result_roots)
569
+ ),
570
+ return_exceptions=True,
269
571
  )
270
- all_results.append(await runner.run_case(case))
572
+ finally:
573
+ progress.close()
574
+ for outcome in outcomes:
575
+ if isinstance(outcome, BaseException):
576
+ raise outcome
577
+ all_results = list(outcomes)
271
578
  report_target = args.report
272
579
  if report_target == DEFAULT_REPORT:
273
580
  report_target = result_roots[0].parent / "reports" / "latest.html"
@@ -285,7 +592,9 @@ async def _run(args: argparse.Namespace) -> int:
285
592
  )
286
593
  )
287
594
  else:
288
- Console().print(build_results_renderable(all_results))
595
+ # Step/assert details already streamed above as they completed; close
596
+ # with the per-case summary table only.
597
+ Console().print(build_summary_table(all_results))
289
598
  if report_path:
290
599
  Console(stderr=args.json).print(
291
600
  Text.assemble(
yama/loaders/case.py CHANGED
@@ -235,6 +235,12 @@ def resolve_case(
235
235
  evals_root = (plugin_root / "__evals__").resolve()
236
236
  context = raw.get("context")
237
237
  steps = raw.get("steps")
238
+ description = raw.get("description")
239
+ if description is None:
240
+ description = ""
241
+ if not isinstance(description, str):
242
+ raise CollectionError(f"description must be a string: {path}")
243
+ description = description.strip()
238
244
  if not isinstance(context, dict):
239
245
  raise CollectionError(f"context is required: {path}")
240
246
  if "skill_tool" in context:
@@ -362,6 +368,7 @@ def resolve_case(
362
368
  return ResolvedCase(
363
369
  path=path.resolve(),
364
370
  case_key=case_key,
371
+ description=description,
365
372
  plugin_root=plugin_root.resolve(),
366
373
  evals_root=evals_root,
367
374
  model=model,
yama/models.py CHANGED
@@ -156,4 +156,5 @@ class ResolvedCase:
156
156
  skills: list[LoadedSkill]
157
157
  tools: list[ToolSchema]
158
158
  initial_messages: list[Json]
159
+ description: str = ""
159
160
  fixture_manifest: list[Json] = field(default_factory=list)
yama/report.py CHANGED
@@ -531,11 +531,17 @@ def _render_case(case: ResolvedCase, result: CaseResult) -> str:
531
531
  tools = ", ".join(tool.name for tool in case.tools) or "none"
532
532
  skills = ", ".join(skill.name for skill in case.skills) or "none"
533
533
  runs = "".join(_render_run(run) for run in result.runs)
534
+ description = (
535
+ f'<p class="case-description">{_text(case.description)}</p>'
536
+ if case.description
537
+ else ""
538
+ )
534
539
  return (
535
540
  '<section class="case">'
536
541
  '<header class="case-header">'
537
542
  '<div><div class="eyebrow">Case</div>'
538
543
  f'<h2>{_text(result.case_key)}</h2>'
544
+ f'{description}'
539
545
  f'<p class="path">{_text(case.path)}</p></div>'
540
546
  '<div class="case-outcome">'
541
547
  f'{_status(result.passed, kind="stamp", size="md", seed=result.case_key)}'
@@ -723,6 +729,7 @@ summary:focus-visible, a:focus-visible, .verdict:focus-visible {{ outline: 2px s
723
729
  .case {{ background: var(--surface); border: 1px solid var(--border); border-radius: 6px; margin-bottom: 20px; overflow: clip; }}
724
730
  .case-header {{ display: flex; justify-content: space-between; gap: 24px; padding: 20px; border-bottom: 1px solid var(--border); }}
725
731
  .case-header > div {{ min-width: 0; }}
732
+ .case-header .case-description {{ margin: 2px 0 6px; color: var(--muted); overflow-wrap: anywhere; }}
726
733
  .case-header .path {{ margin: 0; overflow-wrap: anywhere; font-family: var(--font-mono); font-size: 12px; }}
727
734
  .eyebrow {{ color: var(--muted); font-family: var(--font-display); text-transform: uppercase; letter-spacing: .12em; font-size: 11px; }}
728
735
  .case-outcome {{ min-width: 130px; display: grid; justify-items: end; align-content: start; gap: 5px; }}
yama/runner.py CHANGED
@@ -9,7 +9,7 @@ from copy import deepcopy
9
9
  from dataclasses import dataclass, field
10
10
  from datetime import datetime, timezone
11
11
  from pathlib import Path
12
- from typing import Any
12
+ from typing import Any, Callable
13
13
 
14
14
  import yaml
15
15
 
@@ -89,16 +89,29 @@ class CaseResult:
89
89
  passed: bool
90
90
  runs: list[RunResult]
91
91
  pass_rate: float
92
+ description: str = ""
92
93
 
93
94
  def to_dict(self) -> dict[str, Any]:
94
95
  return {
95
96
  "case_key": self.case_key,
97
+ "description": self.description,
96
98
  "passed": self.passed,
97
99
  "pass_rate": self.pass_rate,
98
100
  "runs": [run.to_dict() for run in self.runs],
99
101
  }
100
102
 
101
103
 
104
+ # Progress callback: (event name, payload). Events, in emission order per case:
105
+ # "case_start" {case_key, description, repeat} -> per run: "run_start"
106
+ # {case_key, run_index, repeat} -> per step: "step_start" {case_key,
107
+ # run_index, step_id} then "step_end" {case_key, run_index, step: StepResult}
108
+ # -> "run_end" {case_key, run: RunResult} -> "case_end" {result: CaseResult}.
109
+ # step_end fires after the step's hard checks and judge have settled, so
110
+ # payloads carry final verdicts. A run that dies mid-step (timeout, handler
111
+ # exception) skips that step's step_end but still gets its run_end.
112
+ RunnerEventCallback = Callable[[str, dict[str, Any]], None]
113
+
114
+
102
115
  class YamaRunner:
103
116
  def __init__(
104
117
  self,
@@ -106,15 +119,27 @@ class YamaRunner:
106
119
  *,
107
120
  result_root: Path | None = None,
108
121
  write_artifacts: bool = True,
122
+ on_event: RunnerEventCallback | None = None,
109
123
  ) -> None:
110
124
  self.llm = llm
111
125
  self.result_root = result_root
112
126
  self.write_artifacts = write_artifacts
127
+ self.on_event = on_event
128
+
129
+ def _emit(self, event: str, **payload: Any) -> None:
130
+ if self.on_event is not None:
131
+ self.on_event(event, payload)
113
132
 
114
133
  async def run_case(self, case: ResolvedCase) -> CaseResult:
115
134
  repeat = int(case.execution.get("repeat", 1))
116
135
  if repeat < 1:
117
136
  raise ValueError("execution.repeat must be at least 1")
137
+ self._emit(
138
+ "case_start",
139
+ case_key=case.case_key,
140
+ description=case.description,
141
+ repeat=repeat,
142
+ )
118
143
  self._clean_case_dirs(case)
119
144
  runs = [
120
145
  await self._run_once(case, run_index) for run_index in range(1, repeat + 1)
@@ -122,13 +147,21 @@ class YamaRunner:
122
147
  passed_count = sum(run.passed for run in runs)
123
148
  result = CaseResult(
124
149
  case_key=case.case_key,
150
+ description=case.description,
125
151
  passed=passed_count == repeat,
126
152
  runs=runs,
127
153
  pass_rate=passed_count / repeat,
128
154
  )
155
+ self._emit("case_end", result=result)
129
156
  return result
130
157
 
131
158
  async def _run_once(self, case: ResolvedCase, run_index: int) -> RunResult:
159
+ self._emit(
160
+ "run_start",
161
+ case_key=case.case_key,
162
+ run_index=run_index,
163
+ repeat=int(case.execution.get("repeat", 1)),
164
+ )
132
165
  artifact_dir = self._artifact_dir(case, run_index)
133
166
  registry: MockToolRegistry | None = None
134
167
  steps: list[StepResult] = []
@@ -142,6 +175,12 @@ class YamaRunner:
142
175
  )
143
176
  messages = await self._initial_messages(case, registry, run_index)
144
177
  for step in case.steps:
178
+ self._emit(
179
+ "step_start",
180
+ case_key=case.case_key,
181
+ run_index=run_index,
182
+ step_id=step["id"],
183
+ )
145
184
  transcript_before = deepcopy(messages)
146
185
  timeout = float(case.execution.get("timeout_seconds_per_step", 120))
147
186
  try:
@@ -158,8 +197,13 @@ class YamaRunner:
158
197
  )
159
198
  except MaxToolRoundsExceeded as exc:
160
199
  messages[:] = transcript_before
161
- steps.append(
162
- self._max_tool_rounds_step_result(case, step, exc)
200
+ step_result = self._max_tool_rounds_step_result(case, step, exc)
201
+ steps.append(step_result)
202
+ self._emit(
203
+ "step_end",
204
+ case_key=case.case_key,
205
+ run_index=run_index,
206
+ step=step_result,
163
207
  )
164
208
  continue
165
209
  assertion_config = step.get("assert", {})
@@ -188,6 +232,12 @@ class YamaRunner:
188
232
  default_model=case.model,
189
233
  )
190
234
  steps.append(step_result)
235
+ self._emit(
236
+ "step_end",
237
+ case_key=case.case_key,
238
+ run_index=run_index,
239
+ step=step_result,
240
+ )
191
241
  passed = self._case_passed(case, steps)
192
242
  run = RunResult(
193
243
  run_index=run_index,
@@ -215,6 +265,7 @@ class YamaRunner:
215
265
  await cleanup_session(registry.state)
216
266
  if self.write_artifacts:
217
267
  self._write_artifacts(case, run)
268
+ self._emit("run_end", case_key=case.case_key, run=run)
218
269
  return run
219
270
 
220
271
  def _max_tool_rounds_step_result(
@@ -502,6 +553,7 @@ class YamaRunner:
502
553
  entry["materialized_path"] = str(target)
503
554
  resolved = {
504
555
  "case_key": case.case_key,
556
+ "description": case.description,
505
557
  "path": str(case.path),
506
558
  "plugin_root": str(case.plugin_root),
507
559
  "evals_root": str(case.evals_root),