python-yama 0.6.0__py3-none-any.whl → 0.7.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.
- {python_yama-0.6.0.dist-info → python_yama-0.7.0.dist-info}/METADATA +3 -4
- {python_yama-0.6.0.dist-info → python_yama-0.7.0.dist-info}/RECORD +10 -10
- yama/cli.py +115 -21
- yama/models.py +2 -0
- yama/report.py +192 -62
- yama/runner.py +159 -18
- yama/thread_case.py +3 -1
- {python_yama-0.6.0.dist-info → python_yama-0.7.0.dist-info}/WHEEL +0 -0
- {python_yama-0.6.0.dist-info → python_yama-0.7.0.dist-info}/entry_points.txt +0 -0
- {python_yama-0.6.0.dist-info → python_yama-0.7.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-yama
|
|
3
|
-
Version: 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`);
|
|
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
|
|
|
@@ -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=9tp_fuoFxqHPrClq_D1WF4i58TxgZUMnTdc-Kc9uKiw,23000
|
|
4
|
-
yama/cli.py,sha256=
|
|
4
|
+
yama/cli.py,sha256=bM1w8AbSzLkaAKypznIfhGA0iWKbpN8BoS0a4G9vCpI,38032
|
|
5
5
|
yama/dashboard.py,sha256=0yxRh-j_5Mk6Ug_xgv9-VyBSEr1aVKxX-zJwxGfd_TU,11601
|
|
6
6
|
yama/llm.py,sha256=JzQ4YHhBLd1WE8W_ipTVcoNK6f-nSqRKDzqEl5kmuis,16085
|
|
7
7
|
yama/mocks.py,sha256=YyiU6Y7NgttxHYJBsqGPILKYlTsM4IMTIilMNRkUuzs,14973
|
|
8
|
-
yama/models.py,sha256=
|
|
8
|
+
yama/models.py,sha256=zd8RIxvUoWa3OdCLIRtgLvYmCVtkAjhQECJheo3HmKE,4128
|
|
9
9
|
yama/preview.py,sha256=gVTMqArXQqOLktGnactK9c0kfX6oHd6fWGjhkB7-QLQ,14220
|
|
10
|
-
yama/report.py,sha256=
|
|
11
|
-
yama/runner.py,sha256=
|
|
12
|
-
yama/thread_case.py,sha256=
|
|
10
|
+
yama/report.py,sha256=WVY4EWInVQbE-Pv2LFHcH-QMoPFpdOd5unDs4uGEq-w,64557
|
|
11
|
+
yama/runner.py,sha256=e3vIBgYBAbhRzG7aUTb9YKw5HJlEUWdpASIDwav1RGQ,38942
|
|
12
|
+
yama/thread_case.py,sha256=9TvZxbzqk3Klihq9ghyRcyhv63HSkjEMQgrOEf26L4g,13171
|
|
13
13
|
yama/workspace.py,sha256=4GAe36Uj1-gjROMPwrQfTIg1TkzEIk9-gHEuezjbY_I,4614
|
|
14
14
|
yama/loaders/__init__.py,sha256=DIwfa8QlIlKt6NpFMZJ_OcqbJPPrmKLBzd9_e-BCuBs,174
|
|
15
15
|
yama/loaders/case.py,sha256=5uUpXm1t9EOmee2BZe7vDGXCrc4CSgcFGApSkuFe5tc,13954
|
|
@@ -23,8 +23,8 @@ yama/tools/bash/bash.py,sha256=4GlFvmqTUS4k6DgJ5Io91YF5fB6wF6e3e7p2P-pmbEQ,10358
|
|
|
23
23
|
yama/tools/bash/fs.py,sha256=GChDwGe_Sgn73btZJDNp5nOwlVDhLfZyaMVqWSQwfOw,21859
|
|
24
24
|
yama/tools/skill/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
25
25
|
yama/tools/skill/skill.py,sha256=H2KdIBLkYhecYX7M2xbn79csDpDvougpRcAmlrwigEM,2235
|
|
26
|
-
python_yama-0.
|
|
27
|
-
python_yama-0.
|
|
28
|
-
python_yama-0.
|
|
29
|
-
python_yama-0.
|
|
30
|
-
python_yama-0.
|
|
26
|
+
python_yama-0.7.0.dist-info/METADATA,sha256=abnFJBim_JNAHsPiflJ6wn-OT8lhwBALIM9NrnzMsmw,7539
|
|
27
|
+
python_yama-0.7.0.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
|
|
28
|
+
python_yama-0.7.0.dist-info/entry_points.txt,sha256=N5se3y1FflUcDU3TmUrH2Tu9dzsrBBo7sUP-Gu_2cVs,39
|
|
29
|
+
python_yama-0.7.0.dist-info/licenses/LICENSE,sha256=cMAJJAs7R1lemJPPc7qMNv4w_sqn5QncFf4aXKYyEc4,1067
|
|
30
|
+
python_yama-0.7.0.dist-info/RECORD,,
|
yama/cli.py
CHANGED
|
@@ -47,12 +47,48 @@ from .thread_case import (
|
|
|
47
47
|
DEFAULT_REPORT = Path("__yama_default_report__")
|
|
48
48
|
|
|
49
49
|
|
|
50
|
-
def
|
|
51
|
-
if
|
|
50
|
+
def _result_status(value: Any) -> str:
|
|
51
|
+
if isinstance(value, bool):
|
|
52
|
+
return "pass" if value else "fail"
|
|
53
|
+
if isinstance(value, str) and value in {"pass", "fail", "error"}:
|
|
54
|
+
return value
|
|
55
|
+
if hasattr(value, "status"):
|
|
56
|
+
return _result_status(getattr(value, "status"))
|
|
57
|
+
if hasattr(value, "passed"):
|
|
58
|
+
return _result_status(bool(getattr(value, "passed")))
|
|
59
|
+
return "fail"
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def _status(value: Any, *, compact: bool = False) -> Text:
|
|
63
|
+
status = _result_status(value)
|
|
64
|
+
if status == "pass":
|
|
52
65
|
return Text("✓" if compact else "PASS", style="bold green")
|
|
66
|
+
if status == "error":
|
|
67
|
+
return Text("!" if compact else "ERROR", style="bold yellow")
|
|
53
68
|
return Text("✗" if compact else "FAIL", style="bold red")
|
|
54
69
|
|
|
55
70
|
|
|
71
|
+
def _evaluated_runs(result: Any) -> list[Any]:
|
|
72
|
+
return [run for run in result.runs if _result_status(run) != "error"]
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def _error_kind(value: Any) -> str | None:
|
|
76
|
+
kind = getattr(value, "error_kind", None)
|
|
77
|
+
return kind if kind in {"llm", "framework"} else None
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def _error_kind_label(kind: str | None) -> str:
|
|
81
|
+
if kind == "llm":
|
|
82
|
+
return "LLM error"
|
|
83
|
+
if kind == "framework":
|
|
84
|
+
return "Framework error"
|
|
85
|
+
return "Error"
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def _plural(count: int, singular: str) -> str:
|
|
89
|
+
return f"{count} {singular}{'' if count == 1 else 's'}"
|
|
90
|
+
|
|
91
|
+
|
|
56
92
|
def _usage_label(usage: dict[str, int] | None, *, split: bool = False) -> str:
|
|
57
93
|
"""`tokens 12,345`-style suffix for labels and captions; empty when no
|
|
58
94
|
LLM call reported usage (scripted replays, runs that died early)."""
|
|
@@ -67,6 +103,13 @@ def _usage_label(usage: dict[str, int] | None, *, split: bool = False) -> str:
|
|
|
67
103
|
return label
|
|
68
104
|
|
|
69
105
|
|
|
106
|
+
def _judge_required_label(judge: dict[str, Any]) -> str:
|
|
107
|
+
required = judge.get("overall_required")
|
|
108
|
+
if isinstance(required, (int, float)):
|
|
109
|
+
return f" (required >= {required:.0%})"
|
|
110
|
+
return ""
|
|
111
|
+
|
|
112
|
+
|
|
70
113
|
def _summary_case_key(case_key: str) -> str:
|
|
71
114
|
prefix = "__evals__/cases/"
|
|
72
115
|
return case_key.removeprefix(prefix)
|
|
@@ -102,6 +145,7 @@ def build_step_tree(step: Any) -> Tree:
|
|
|
102
145
|
)
|
|
103
146
|
if isinstance(judge.get("overall"), (int, float)):
|
|
104
147
|
step_label.append(f" {judge['overall']:.0%}", style="dim")
|
|
148
|
+
step_label.append(_judge_required_label(judge), style="dim")
|
|
105
149
|
step_node = Tree(step_label, guide_style="dim")
|
|
106
150
|
if judge is not None and not judge_passed:
|
|
107
151
|
judge_node = step_node.add(Text("Judge dimensions", style="bold red"))
|
|
@@ -152,7 +196,7 @@ def build_case_tree(result: Any) -> Tree:
|
|
|
152
196
|
"""Whole-case verdict tree (runs -> steps), shared by the aggregated
|
|
153
197
|
details of `format_text_results` and the parallel progress output."""
|
|
154
198
|
case_label = Text.assemble(
|
|
155
|
-
_status(result
|
|
199
|
+
_status(result, compact=True),
|
|
156
200
|
" ",
|
|
157
201
|
(result.case_key, "bold"),
|
|
158
202
|
(f" {result.pass_rate:.0%}", "dim"),
|
|
@@ -165,7 +209,7 @@ def build_case_tree(result: Any) -> Tree:
|
|
|
165
209
|
tree = Tree(case_label, guide_style="dim")
|
|
166
210
|
for run in result.runs:
|
|
167
211
|
run_label = Text.assemble(
|
|
168
|
-
_status(run
|
|
212
|
+
_status(run, compact=True),
|
|
169
213
|
" ",
|
|
170
214
|
(f"Run {run.run_index}", "bold"),
|
|
171
215
|
)
|
|
@@ -176,7 +220,12 @@ def build_case_tree(result: Any) -> Tree:
|
|
|
176
220
|
run_label.append(f" {_usage_label(run_usage)}", style="dim")
|
|
177
221
|
run_node = tree.add(run_label)
|
|
178
222
|
if run.error:
|
|
179
|
-
run_node.add(
|
|
223
|
+
run_node.add(
|
|
224
|
+
Text.assemble(
|
|
225
|
+
(f"{_error_kind_label(_error_kind(run))}: ", "bold yellow"),
|
|
226
|
+
(run.error, "yellow"),
|
|
227
|
+
)
|
|
228
|
+
)
|
|
180
229
|
run_node.children.extend(build_step_tree(step) for step in run.steps)
|
|
181
230
|
return tree
|
|
182
231
|
|
|
@@ -196,32 +245,65 @@ def build_summary_table(results: list[Any]) -> Table:
|
|
|
196
245
|
table.add_column("Tokens", justify="right", no_wrap=True)
|
|
197
246
|
|
|
198
247
|
passed_runs = 0
|
|
199
|
-
|
|
248
|
+
evaluated_run_count = 0
|
|
249
|
+
error_runs = 0
|
|
250
|
+
llm_errors = 0
|
|
251
|
+
framework_errors = 0
|
|
200
252
|
for result in results:
|
|
201
|
-
|
|
253
|
+
evaluated_runs = _evaluated_runs(result)
|
|
254
|
+
case_passed_runs = sum(run.passed for run in evaluated_runs)
|
|
255
|
+
case_error_runs = len(result.runs) - len(evaluated_runs)
|
|
202
256
|
passed_runs += case_passed_runs
|
|
203
|
-
|
|
257
|
+
evaluated_run_count += len(evaluated_runs)
|
|
258
|
+
error_runs += case_error_runs
|
|
259
|
+
llm_errors += sum(1 for run in result.runs if _error_kind(run) == "llm")
|
|
260
|
+
framework_errors += sum(
|
|
261
|
+
1 for run in result.runs if _error_kind(run) == "framework"
|
|
262
|
+
)
|
|
204
263
|
case_cell = Text(_summary_case_key(result.case_key))
|
|
205
264
|
if result.description:
|
|
206
265
|
case_cell.append(f"\n{result.description}", style="dim")
|
|
207
266
|
usage = result.usage()
|
|
267
|
+
run_count = f"{case_passed_runs}/{len(evaluated_runs)}"
|
|
268
|
+
if case_error_runs:
|
|
269
|
+
run_count += f" (+{case_error_runs} error)"
|
|
208
270
|
table.add_row(
|
|
209
|
-
_status(result
|
|
271
|
+
_status(result),
|
|
210
272
|
case_cell,
|
|
211
|
-
|
|
273
|
+
run_count,
|
|
212
274
|
f"{result.pass_rate:.0%}",
|
|
213
275
|
f"{usage['total_tokens']:,}" if usage else "–",
|
|
214
276
|
)
|
|
215
277
|
|
|
216
|
-
|
|
278
|
+
error_cases = sum(1 for result in results if _result_status(result) == "error")
|
|
279
|
+
evaluated_cases = len(results) - error_cases
|
|
280
|
+
passed_cases = sum(
|
|
281
|
+
result.passed for result in results if _result_status(result) != "error"
|
|
282
|
+
)
|
|
217
283
|
table.caption = (
|
|
218
|
-
f"{passed_cases}/{
|
|
219
|
-
f"{passed_runs}/{
|
|
284
|
+
f"{passed_cases}/{evaluated_cases} cases passed • "
|
|
285
|
+
f"{passed_runs}/{evaluated_run_count} runs passed"
|
|
220
286
|
)
|
|
287
|
+
if error_cases:
|
|
288
|
+
table.caption += f" • {error_cases} case error"
|
|
289
|
+
if error_cases != 1:
|
|
290
|
+
table.caption += "s"
|
|
291
|
+
if error_runs:
|
|
292
|
+
table.caption += f" • {_plural(error_runs, 'run error')}"
|
|
293
|
+
if llm_errors:
|
|
294
|
+
table.caption += f" • {_plural(llm_errors, 'llm error')}"
|
|
295
|
+
if framework_errors:
|
|
296
|
+
table.caption += f" • {_plural(framework_errors, 'framework error')}"
|
|
221
297
|
total_usage = combine_usage(result.usage() for result in results)
|
|
222
298
|
if total_usage:
|
|
223
299
|
table.caption += f" • {_usage_label(total_usage, split=True)}"
|
|
224
|
-
|
|
300
|
+
failed_cases = evaluated_cases - passed_cases
|
|
301
|
+
if failed_cases:
|
|
302
|
+
table.caption_style = "red"
|
|
303
|
+
elif error_cases:
|
|
304
|
+
table.caption_style = "yellow"
|
|
305
|
+
else:
|
|
306
|
+
table.caption_style = "green"
|
|
225
307
|
return table
|
|
226
308
|
|
|
227
309
|
|
|
@@ -303,17 +385,21 @@ class ProgressPrinter:
|
|
|
303
385
|
)
|
|
304
386
|
elif event == "case_end":
|
|
305
387
|
result = payload["result"]
|
|
306
|
-
|
|
388
|
+
evaluated_runs = _evaluated_runs(result)
|
|
389
|
+
passed_runs = sum(run.passed for run in evaluated_runs)
|
|
390
|
+
error_runs = len(result.runs) - len(evaluated_runs)
|
|
307
391
|
meta = (
|
|
308
|
-
f" {passed_runs}/{len(
|
|
392
|
+
f" {passed_runs}/{len(evaluated_runs)} runs passed"
|
|
309
393
|
f" {result.pass_rate:.0%}"
|
|
310
394
|
)
|
|
395
|
+
if error_runs:
|
|
396
|
+
meta += f" {error_runs} error"
|
|
311
397
|
usage = result.usage()
|
|
312
398
|
if usage:
|
|
313
399
|
meta += f" {_usage_label(usage)}"
|
|
314
400
|
self.console.print(
|
|
315
401
|
Text.assemble(
|
|
316
|
-
_status(result
|
|
402
|
+
_status(result, compact=True),
|
|
317
403
|
" ",
|
|
318
404
|
(result.case_key, "bold"),
|
|
319
405
|
(meta, "dim"),
|
|
@@ -410,16 +496,20 @@ class ParallelProgressPrinter:
|
|
|
410
496
|
)
|
|
411
497
|
else:
|
|
412
498
|
result = row["result"]
|
|
413
|
-
|
|
499
|
+
evaluated_runs = _evaluated_runs(result)
|
|
500
|
+
passed_runs = sum(run.passed for run in evaluated_runs)
|
|
501
|
+
error_runs = len(result.runs) - len(evaluated_runs)
|
|
414
502
|
meta = (
|
|
415
|
-
f" {passed_runs}/{len(
|
|
503
|
+
f" {passed_runs}/{len(evaluated_runs)} runs"
|
|
416
504
|
f" {result.pass_rate:.0%}"
|
|
417
505
|
)
|
|
506
|
+
if error_runs:
|
|
507
|
+
meta += f" {error_runs} error"
|
|
418
508
|
usage = result.usage()
|
|
419
509
|
if usage:
|
|
420
510
|
meta += f" {_usage_label(usage)}"
|
|
421
511
|
grid.add_row(
|
|
422
|
-
_status(result
|
|
512
|
+
_status(result, compact=True),
|
|
423
513
|
Text.assemble((case_key, "bold"), (meta, "dim")),
|
|
424
514
|
)
|
|
425
515
|
return grid
|
|
@@ -727,7 +817,11 @@ async def _run(args: argparse.Namespace) -> int:
|
|
|
727
817
|
(str(report_path), f"cyan link {report_path.as_uri()}"),
|
|
728
818
|
)
|
|
729
819
|
)
|
|
730
|
-
|
|
820
|
+
if any(_result_status(result) == "fail" for result in all_results):
|
|
821
|
+
return 1
|
|
822
|
+
if any(_result_status(result) == "error" for result in all_results):
|
|
823
|
+
return 2
|
|
824
|
+
return 0
|
|
731
825
|
|
|
732
826
|
|
|
733
827
|
def _dashboard_parser() -> argparse.ArgumentParser:
|
yama/models.py
CHANGED
|
@@ -111,6 +111,7 @@ class StepResult:
|
|
|
111
111
|
messages: list[Json]
|
|
112
112
|
hard_checks: list[Json] = field(default_factory=list)
|
|
113
113
|
hard_pass: bool = True
|
|
114
|
+
tag_summary: dict[str, Json] = field(default_factory=dict)
|
|
114
115
|
judge_result: Json | None = None
|
|
115
116
|
|
|
116
117
|
def to_dict(self) -> Json:
|
|
@@ -122,6 +123,7 @@ class StepResult:
|
|
|
122
123
|
"messages": self.messages,
|
|
123
124
|
"hard_checks": self.hard_checks,
|
|
124
125
|
"hard_pass": self.hard_pass,
|
|
126
|
+
"tag_summary": self.tag_summary,
|
|
125
127
|
"judge_result": self.judge_result,
|
|
126
128
|
}
|
|
127
129
|
|
yama/report.py
CHANGED
|
@@ -12,8 +12,10 @@ from .assertions import HARD_ASSERTION_TAG_THRESHOLDS
|
|
|
12
12
|
from .models import ResolvedCase, StepResult
|
|
13
13
|
from .runner import (
|
|
14
14
|
CaseResult,
|
|
15
|
+
ResultStatus,
|
|
15
16
|
RunResult,
|
|
16
17
|
_tool_result_content,
|
|
18
|
+
combine_duration_ms,
|
|
17
19
|
combine_usage,
|
|
18
20
|
resolve_run_plan,
|
|
19
21
|
)
|
|
@@ -42,6 +44,13 @@ def _usage_inline(usage: Any) -> str:
|
|
|
42
44
|
)
|
|
43
45
|
|
|
44
46
|
|
|
47
|
+
def _duration_inline(duration_ms: Any) -> str:
|
|
48
|
+
if isinstance(duration_ms, bool) or not isinstance(duration_ms, (int, float)):
|
|
49
|
+
return ""
|
|
50
|
+
formatted = f"{float(duration_ms):,.3f}".rstrip("0").rstrip(".")
|
|
51
|
+
return f"{formatted} ms"
|
|
52
|
+
|
|
53
|
+
|
|
45
54
|
def _json(value: Any) -> str:
|
|
46
55
|
return escape(
|
|
47
56
|
json.dumps(value, ensure_ascii=False, indent=2, default=str), quote=False
|
|
@@ -57,8 +66,43 @@ def _stamp_angle(seed: str | None) -> float:
|
|
|
57
66
|
return (digest[0] / 255) * 6.4 - 3.2
|
|
58
67
|
|
|
59
68
|
|
|
69
|
+
def _result_status(value: bool | str | Any) -> ResultStatus:
|
|
70
|
+
if isinstance(value, bool):
|
|
71
|
+
return "pass" if value else "fail"
|
|
72
|
+
if isinstance(value, str) and value in {"pass", "fail", "error"}:
|
|
73
|
+
return value
|
|
74
|
+
if hasattr(value, "status"):
|
|
75
|
+
return _result_status(getattr(value, "status"))
|
|
76
|
+
if hasattr(value, "passed"):
|
|
77
|
+
return _result_status(bool(getattr(value, "passed")))
|
|
78
|
+
return "fail"
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def _row_class(value: bool | str | Any) -> str:
|
|
82
|
+
status = _result_status(value)
|
|
83
|
+
return "passed" if status == "pass" else status
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def _status_label(value: bool | str | Any) -> str:
|
|
87
|
+
return {"pass": "PASS", "fail": "FAIL", "error": "ERROR"}[_result_status(value)]
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def _error_kind(value: Any) -> str | None:
|
|
91
|
+
kind = getattr(value, "error_kind", None)
|
|
92
|
+
return kind if kind in {"llm", "framework"} else None
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def _error_kind_title(value: Any) -> str:
|
|
96
|
+
kind = _error_kind(value)
|
|
97
|
+
if kind == "llm":
|
|
98
|
+
return "LLM error"
|
|
99
|
+
if kind == "framework":
|
|
100
|
+
return "Framework error"
|
|
101
|
+
return "Run error"
|
|
102
|
+
|
|
103
|
+
|
|
60
104
|
def _status(
|
|
61
|
-
passed: bool,
|
|
105
|
+
passed: bool | str,
|
|
62
106
|
*,
|
|
63
107
|
kind: str = "stamp",
|
|
64
108
|
size: str = "md",
|
|
@@ -67,8 +111,9 @@ def _status(
|
|
|
67
111
|
"""Render a verdict. High-frequency, low-stakes rows (check/mock-event
|
|
68
112
|
lists) get a quiet inline tick; the handful of hierarchical verdicts
|
|
69
113
|
per report (report/case/run/step/judge) get a stamped chop instead."""
|
|
70
|
-
|
|
71
|
-
|
|
114
|
+
status = _result_status(passed)
|
|
115
|
+
label = _status_label(status)
|
|
116
|
+
css_class = status
|
|
72
117
|
if kind == "tick":
|
|
73
118
|
return (
|
|
74
119
|
f'<span class="verdict tick {css_class}">'
|
|
@@ -283,11 +328,16 @@ def _render_llm_request_details(request: dict[str, Any]) -> str:
|
|
|
283
328
|
invocation = request.get("invocation")
|
|
284
329
|
if not isinstance(invocation, dict):
|
|
285
330
|
invocation = {}
|
|
331
|
+
duration = _duration_inline(request.get("duration_ms")) or "–"
|
|
286
332
|
return (
|
|
287
333
|
'<h5>Method</h5>'
|
|
288
334
|
f'<pre><code>{_text(invocation.get("method", "unknown"))}</code></pre>'
|
|
335
|
+
'<h5>Duration</h5>'
|
|
336
|
+
f'<pre><code>{_text(duration)}</code></pre>'
|
|
289
337
|
'<h5>Arguments</h5>'
|
|
290
338
|
f'<pre><code>{_json(invocation.get("arguments", {}))}</code></pre>'
|
|
339
|
+
'<h5>Response</h5>'
|
|
340
|
+
f'<pre><code>{_json(request.get("response", {}))}</code></pre>'
|
|
291
341
|
)
|
|
292
342
|
|
|
293
343
|
|
|
@@ -314,6 +364,8 @@ def _render_assistant_call(request: dict[str, Any]) -> str:
|
|
|
314
364
|
|
|
315
365
|
usage_note = _usage_inline(request.get("usage"))
|
|
316
366
|
usage_html = f" · {_text(usage_note)}" if usage_note else ""
|
|
367
|
+
duration_note = _duration_inline(request.get("duration_ms"))
|
|
368
|
+
duration_prefix = f"{_text(duration_note)} · " if duration_note else ""
|
|
317
369
|
content = response.get("content", "") if isinstance(response, dict) else ""
|
|
318
370
|
response_html = (
|
|
319
371
|
'<div class="assistant-content"><h5>Assistant text content</h5>'
|
|
@@ -336,6 +388,7 @@ def _render_assistant_call(request: dict[str, Any]) -> str:
|
|
|
336
388
|
'<span class="event-kind">assistant</span>'
|
|
337
389
|
'<strong>Assistant response</strong>'
|
|
338
390
|
f'<span class="muted">request {_text(request.get("request_index", "?"))} · '
|
|
391
|
+
f'{duration_prefix}'
|
|
339
392
|
f'{_text(provider_name)} · {_text(model_name)}{usage_html}</span>'
|
|
340
393
|
"</div>"
|
|
341
394
|
f'<div class="assistant-response">{response_html}{error_html}</div>'
|
|
@@ -363,12 +416,13 @@ def _render_checks(step: StepResult) -> str:
|
|
|
363
416
|
f'<td>{_text(check.get("reason", check.get("detail", "")))}</td>'
|
|
364
417
|
"</tr>"
|
|
365
418
|
)
|
|
366
|
-
|
|
419
|
+
table = (
|
|
367
420
|
'<div class="table-wrap"><table class="checks">'
|
|
368
421
|
"<thead><tr><th>Status</th><th>Check</th><th>Tag</th><th>Expected</th>"
|
|
369
422
|
"<th>Actual</th><th>Reason</th></tr></thead>"
|
|
370
423
|
f'<tbody>{"".join(rows)}</tbody></table></div>'
|
|
371
424
|
)
|
|
425
|
+
return table + _render_tag_summary(getattr(step, "tag_summary", {}))
|
|
372
426
|
|
|
373
427
|
|
|
374
428
|
def _render_judge(judge: dict[str, Any] | None) -> str:
|
|
@@ -379,6 +433,12 @@ def _render_judge(judge: dict[str, Any] | None) -> str:
|
|
|
379
433
|
overall_label = (
|
|
380
434
|
f"{overall:.0%}" if isinstance(overall, (int, float)) else "unknown"
|
|
381
435
|
)
|
|
436
|
+
required = judge.get("overall_required")
|
|
437
|
+
required_html = (
|
|
438
|
+
f'<span class="metric-inline">required >= {required:.0%}</span>'
|
|
439
|
+
if isinstance(required, (int, float))
|
|
440
|
+
else ""
|
|
441
|
+
)
|
|
382
442
|
dimensions: list[str] = []
|
|
383
443
|
for item in judge.get("dimensions", []):
|
|
384
444
|
score = item.get("score", "?")
|
|
@@ -403,6 +463,7 @@ def _render_judge(judge: dict[str, Any] | None) -> str:
|
|
|
403
463
|
'<div class="section-heading"><h4>Judge</h4>'
|
|
404
464
|
f'{_status(passed, kind="stamp", size="sm", seed="judge")}'
|
|
405
465
|
f'<span class="metric-inline">Overall {overall_label}</span>'
|
|
466
|
+
f'{required_html}'
|
|
406
467
|
f'{usage_html}'
|
|
407
468
|
"</div>"
|
|
408
469
|
f'<div class="judge-grid">{"".join(dimensions)}</div>'
|
|
@@ -495,9 +556,15 @@ def _render_step(
|
|
|
495
556
|
[request.get("usage") for request in step_requests]
|
|
496
557
|
+ [step.judge_result.get("usage") if isinstance(step.judge_result, dict) else None]
|
|
497
558
|
)
|
|
559
|
+
request_duration = combine_duration_ms(
|
|
560
|
+
request.get("duration_ms") for request in step_requests
|
|
561
|
+
)
|
|
498
562
|
tokens_meta = (
|
|
499
563
|
f' · {step_usage["total_tokens"]:,} tokens' if step_usage else ""
|
|
500
564
|
)
|
|
565
|
+
duration_meta = (
|
|
566
|
+
f' · {_duration_inline(request_duration)}' if request_duration is not None else ""
|
|
567
|
+
)
|
|
501
568
|
html = (
|
|
502
569
|
f'<details class="step" {"open" if not passed else ""}>'
|
|
503
570
|
"<summary>"
|
|
@@ -505,6 +572,7 @@ def _render_step(
|
|
|
505
572
|
f'<strong>Step {step_number}</strong>'
|
|
506
573
|
f'<span class="run-label">{_text(step.step_id)}</span>'
|
|
507
574
|
'<span class="summary-meta">'
|
|
575
|
+
f'{len(step_requests)} LLM requests{duration_meta} · '
|
|
508
576
|
f'{len(step.tool_calls)} tool calls · '
|
|
509
577
|
f'{len(step.hard_checks) - failed_checks}/{len(step.hard_checks)} checks passed'
|
|
510
578
|
f'{tokens_meta}'
|
|
@@ -541,11 +609,13 @@ def _render_request(request: dict[str, Any]) -> str:
|
|
|
541
609
|
if isinstance(usage, dict)
|
|
542
610
|
else ""
|
|
543
611
|
)
|
|
612
|
+
duration = _duration_inline(request.get("duration_ms"))
|
|
613
|
+
duration_html = f" · {_text(duration)}" if duration else ""
|
|
544
614
|
return (
|
|
545
615
|
'<details class="raw request">'
|
|
546
616
|
"<summary>"
|
|
547
617
|
f'Request {_text(request.get("request_index", "?"))} · '
|
|
548
|
-
f'{_text(request.get("step_id", "unknown step"))}{provider}{tokens}'
|
|
618
|
+
f'{_text(request.get("step_id", "unknown step"))}{duration_html}{provider}{tokens}'
|
|
549
619
|
"</summary>"
|
|
550
620
|
f'{_render_llm_request_details(request)}'
|
|
551
621
|
"</details>"
|
|
@@ -617,6 +687,7 @@ def _run_rank_key(run: RunResult) -> tuple[float, ...]:
|
|
|
617
687
|
overall = _run_judge_overall(run)
|
|
618
688
|
usage = run.usage()
|
|
619
689
|
return (
|
|
690
|
+
-1.0 if run.status == "error" else 0.0,
|
|
620
691
|
float(run.passed),
|
|
621
692
|
float(steps_passed),
|
|
622
693
|
float(checks_passed),
|
|
@@ -699,8 +770,8 @@ def _render_merged_variant_comparison(
|
|
|
699
770
|
rows: list[str] = []
|
|
700
771
|
for index, run in enumerate(runs):
|
|
701
772
|
rows.append(
|
|
702
|
-
f'<tr class="{
|
|
703
|
-
f'<td>{_status(run.passed, kind="tick")}</td>'
|
|
773
|
+
f'<tr class="{_row_class(run)}">'
|
|
774
|
+
f'<td>{_status(run.status or run.passed, kind="tick")}</td>'
|
|
704
775
|
f'{_variant_name_cell(run.label or "default", _variant_model_names([run]), champion=index == champion)}'
|
|
705
776
|
f"{_run_detail_cells(run)}"
|
|
706
777
|
"</tr>"
|
|
@@ -715,8 +786,15 @@ def _render_merged_variant_comparison(
|
|
|
715
786
|
def _render_variant_comparison(groups: dict[str, list[RunResult]]) -> str:
|
|
716
787
|
rows: list[str] = []
|
|
717
788
|
for label, runs in groups.items():
|
|
718
|
-
|
|
719
|
-
|
|
789
|
+
evaluated = [run for run in runs if run.status != "error"]
|
|
790
|
+
passed = sum(run.passed for run in evaluated)
|
|
791
|
+
errors = len(runs) - len(evaluated)
|
|
792
|
+
if any(run.status == "fail" for run in runs):
|
|
793
|
+
status = "fail"
|
|
794
|
+
elif errors:
|
|
795
|
+
status = "error"
|
|
796
|
+
else:
|
|
797
|
+
status = "pass"
|
|
720
798
|
overalls = [
|
|
721
799
|
overall
|
|
722
800
|
for run in runs
|
|
@@ -725,12 +803,14 @@ def _render_variant_comparison(groups: dict[str, list[RunResult]]) -> str:
|
|
|
725
803
|
judge_cell = f"{sum(overalls) / len(overalls):.0%}" if overalls else "–"
|
|
726
804
|
usage = combine_usage(run.usage() for run in runs)
|
|
727
805
|
tokens_cell = f"{usage['total_tokens']:,}" if usage else "–"
|
|
806
|
+
error_note = f' <span class="muted">(+{errors} error)</span>' if errors else ""
|
|
807
|
+
pass_rate_cell = f"{passed / len(evaluated):.0%}" if evaluated else "–"
|
|
728
808
|
rows.append(
|
|
729
|
-
f'<tr class="{
|
|
730
|
-
f'<td>{_status(
|
|
809
|
+
f'<tr class="{_row_class(status)}">'
|
|
810
|
+
f'<td>{_status(status, kind="tick")}</td>'
|
|
731
811
|
f'{_variant_name_cell(label, _variant_model_names(runs), champion=False)}'
|
|
732
|
-
f"<td>{passed}/{len(
|
|
733
|
-
f"<td>{
|
|
812
|
+
f"<td>{passed}/{len(evaluated)}{error_note}</td>"
|
|
813
|
+
f"<td>{_text(pass_rate_cell)}</td>"
|
|
734
814
|
f"<td>{_text(judge_cell)}</td>"
|
|
735
815
|
f"<td>{_text(tokens_cell)}</td>"
|
|
736
816
|
"</tr>"
|
|
@@ -780,8 +860,8 @@ def _render_run_comparison(result: CaseResult) -> str:
|
|
|
780
860
|
f"<td>{_text(run.label or '–')}</td>" if has_variants else ""
|
|
781
861
|
)
|
|
782
862
|
rows.append(
|
|
783
|
-
f'<tr class="{
|
|
784
|
-
f'<td>{_status(run.passed, kind="tick")}</td>'
|
|
863
|
+
f'<tr class="{_row_class(run)}">'
|
|
864
|
+
f'<td>{_status(run.status or run.passed, kind="tick")}</td>'
|
|
785
865
|
f"<td><strong>Run {run.run_index}</strong>{badge}</td>"
|
|
786
866
|
f"{variant_cell}"
|
|
787
867
|
f"{_run_detail_cells(run)}"
|
|
@@ -835,37 +915,11 @@ def _render_tag_summary(tag_summary: dict[Any, dict[str, Any]]) -> str:
|
|
|
835
915
|
return _fold("Pass rate by tag", table)
|
|
836
916
|
|
|
837
917
|
|
|
838
|
-
def _render_case_tag_summary(tag_summary: dict[Any, dict[str, Any]]) -> str:
|
|
839
|
-
if not tag_summary:
|
|
840
|
-
return ""
|
|
841
|
-
rows: list[str] = []
|
|
842
|
-
for label, entry in _ordered_tag_items(tag_summary):
|
|
843
|
-
ok = bool(entry.get("ok"))
|
|
844
|
-
rows.append(
|
|
845
|
-
f'<tr class="{"passed" if ok else "failed"}">'
|
|
846
|
-
f'<td>{_status(ok, kind="tick")}</td>'
|
|
847
|
-
f'<td><strong>{_text(label)}</strong></td>'
|
|
848
|
-
f'<td>{entry.get("passed", 0)}/{entry.get("total", 0)}</td>'
|
|
849
|
-
f'<td>{entry.get("rate", 0.0):.0%}</td>'
|
|
850
|
-
f'<td>{entry.get("threshold", 1.0):.0%}</td>'
|
|
851
|
-
"</tr>"
|
|
852
|
-
)
|
|
853
|
-
return (
|
|
854
|
-
'<section class="case-tag-summary">'
|
|
855
|
-
"<h3>Case tag summary</h3>"
|
|
856
|
-
'<div class="table-wrap"><table class="checks">'
|
|
857
|
-
"<thead><tr><th>Status</th><th>Tag</th><th>Passed</th>"
|
|
858
|
-
"<th>Rate</th><th>Threshold</th></tr></thead>"
|
|
859
|
-
f'<tbody>{"".join(rows)}</tbody></table></div>'
|
|
860
|
-
"</section>"
|
|
861
|
-
)
|
|
862
|
-
|
|
863
|
-
|
|
864
918
|
def _render_run(run: RunResult) -> str:
|
|
865
919
|
error = ""
|
|
866
920
|
if run.error:
|
|
867
921
|
error = (
|
|
868
|
-
'<div class="run-error"><strong>
|
|
922
|
+
f'<div class="run-error"><strong>{_text(_error_kind_title(run))}</strong>'
|
|
869
923
|
f'<pre>{_text(run.error)}</pre>'
|
|
870
924
|
f'<details><summary>Traceback</summary><pre>{_text(run.traceback or "")}</pre></details>'
|
|
871
925
|
"</div>"
|
|
@@ -881,7 +935,10 @@ def _render_run(run: RunResult) -> str:
|
|
|
881
935
|
requests = "".join(_render_request(request) for request in run.requests)
|
|
882
936
|
mocks = "".join(_render_mock_event(event) for event in run.mock_events)
|
|
883
937
|
run_usage = run.usage()
|
|
938
|
+
run_duration = run.request_duration_ms()
|
|
884
939
|
meta_parts = []
|
|
940
|
+
if run_duration is not None:
|
|
941
|
+
meta_parts.append(f"LLM request time {_duration_inline(run_duration)}")
|
|
885
942
|
if run_usage:
|
|
886
943
|
meta_parts.append(_usage_inline(run_usage))
|
|
887
944
|
if run.artifact_dir:
|
|
@@ -895,13 +952,13 @@ def _render_run(run: RunResult) -> str:
|
|
|
895
952
|
f'<span class="run-label">{_text(run.label)}</span>' if run.label else ""
|
|
896
953
|
)
|
|
897
954
|
return (
|
|
898
|
-
f'<details class="run" {"open" if
|
|
955
|
+
f'<details class="run" {"open" if run.status != "pass" else ""}>'
|
|
899
956
|
"<summary>"
|
|
900
|
-
f'{_status(run.passed, kind="stamp", size="sm", seed=f"run-{run.run_index}")}'
|
|
957
|
+
f'{_status(run.status or run.passed, kind="stamp", size="sm", seed=f"run-{run.run_index}")}'
|
|
901
958
|
f'<strong>Run {run.run_index}</strong>{label_html}{meta}'
|
|
902
959
|
"</summary>"
|
|
903
960
|
'<div class="run-body">'
|
|
904
|
-
f"{error}{steps}
|
|
961
|
+
f"{error}{steps}"
|
|
905
962
|
# The count stays inside the summary text (not a meta span): the
|
|
906
963
|
# `LLM requests (N)` form is part of the report's stable markup.
|
|
907
964
|
+ _fold(
|
|
@@ -921,6 +978,23 @@ def _render_run(run: RunResult) -> str:
|
|
|
921
978
|
)
|
|
922
979
|
|
|
923
980
|
|
|
981
|
+
def _render_case_errors(result: CaseResult) -> str:
|
|
982
|
+
items: list[str] = []
|
|
983
|
+
for run in result.runs:
|
|
984
|
+
if run.status != "error" or not run.error:
|
|
985
|
+
continue
|
|
986
|
+
items.append(
|
|
987
|
+
'<div class="case-error">'
|
|
988
|
+
f'<strong>{_text(_error_kind_title(run))}</strong>'
|
|
989
|
+
f'<span class="muted">Run {run.run_index}</span>'
|
|
990
|
+
f'<pre>{_text(run.error)}</pre>'
|
|
991
|
+
"</div>"
|
|
992
|
+
)
|
|
993
|
+
if not items:
|
|
994
|
+
return ""
|
|
995
|
+
return f'<div class="case-errors">{"".join(items)}</div>'
|
|
996
|
+
|
|
997
|
+
|
|
924
998
|
def _render_planned_runs(case: ResolvedCase) -> str:
|
|
925
999
|
"""The "Planned runs" fold shared by the run report and the case
|
|
926
1000
|
preview page: one row per run `execution.repeat` expands to — a variant
|
|
@@ -972,7 +1046,10 @@ def _render_planned_runs(case: ResolvedCase) -> str:
|
|
|
972
1046
|
|
|
973
1047
|
|
|
974
1048
|
def _render_case(case: ResolvedCase, result: CaseResult) -> str:
|
|
975
|
-
|
|
1049
|
+
evaluated_runs = [run for run in result.runs if run.status != "error"]
|
|
1050
|
+
passed_runs = sum(run.passed for run in evaluated_runs)
|
|
1051
|
+
run_errors = len(result.runs) - len(evaluated_runs)
|
|
1052
|
+
run_error_note = f" · {run_errors} error" if run_errors else ""
|
|
976
1053
|
tools = ", ".join(tool.name for tool in case.tools) or "none"
|
|
977
1054
|
skills = ", ".join(skill.name for skill in case.skills) or "none"
|
|
978
1055
|
runs = "".join(_render_run(run) for run in result.runs)
|
|
@@ -991,6 +1068,8 @@ def _render_case(case: ResolvedCase, result: CaseResult) -> str:
|
|
|
991
1068
|
if case_usage
|
|
992
1069
|
else "–"
|
|
993
1070
|
)
|
|
1071
|
+
case_duration = result.request_duration_ms()
|
|
1072
|
+
duration_cell = _duration_inline(case_duration) if case_duration is not None else "–"
|
|
994
1073
|
# The description is the human-meaningful headline; the case_key only
|
|
995
1074
|
# steps in when a case declared no description. The file path below the
|
|
996
1075
|
# title already carries the case's identity.
|
|
@@ -1000,19 +1079,20 @@ def _render_case(case: ResolvedCase, result: CaseResult) -> str:
|
|
|
1000
1079
|
'<header class="case-header">'
|
|
1001
1080
|
'<div><div class="eyebrow">Case</div>'
|
|
1002
1081
|
f'<h2>{_text(title)}</h2>'
|
|
1003
|
-
f'<p class="path">{_text(case.path)}</p
|
|
1082
|
+
f'<p class="path">{_text(case.path)}</p>'
|
|
1083
|
+
f'{_render_case_errors(result)}</div>'
|
|
1004
1084
|
'<div class="case-outcome">'
|
|
1005
|
-
f'{_status(result.passed, kind="stamp", size="md", seed=result.case_key)}'
|
|
1085
|
+
f'{_status(result.status or result.passed, kind="stamp", size="md", seed=result.case_key)}'
|
|
1006
1086
|
f'<strong>{result.pass_rate:.0%}</strong>'
|
|
1007
|
-
f'<span>{passed_runs}/{len(
|
|
1087
|
+
f'<span>{passed_runs}/{len(evaluated_runs)} runs passed{_text(run_error_note)}</span>'
|
|
1008
1088
|
"</div>"
|
|
1009
1089
|
"</header>"
|
|
1010
|
-
f"{_render_case_tag_summary(result.tag_summary)}"
|
|
1011
1090
|
'<div class="metadata">'
|
|
1012
1091
|
f'<div><span>Model</span><strong>{_text(model_cell)}</strong></div>'
|
|
1013
1092
|
f'<div><span>Tools</span><strong>{_text(tools)}</strong></div>'
|
|
1014
1093
|
f'<div><span>Skills</span><strong>{_text(skills)}</strong></div>'
|
|
1015
1094
|
f'<div><span>LLM tokens</span><strong>{_text(usage_cell)}</strong></div>'
|
|
1095
|
+
f'<div><span>LLM request time</span><strong>{_text(duration_cell)}</strong></div>'
|
|
1016
1096
|
"</div>"
|
|
1017
1097
|
f'{_render_run_comparison(result)}'
|
|
1018
1098
|
f'{_render_planned_runs(case)}'
|
|
@@ -1035,6 +1115,8 @@ _PAGE_CSS = """:root {
|
|
|
1035
1115
|
--fail: #a6332a;
|
|
1036
1116
|
--fail-bg: #f1ded9;
|
|
1037
1117
|
--warn: #8a6a2c;
|
|
1118
|
+
--error: #8a6a2c;
|
|
1119
|
+
--error-bg: #ede4ce;
|
|
1038
1120
|
--system: #6b4c7a;
|
|
1039
1121
|
--system-bg: #e6dee8;
|
|
1040
1122
|
--user: #33507d;
|
|
@@ -1063,6 +1145,8 @@ _PAGE_CSS = """:root {
|
|
|
1063
1145
|
--fail: #e2756a;
|
|
1064
1146
|
--fail-bg: #3a2320;
|
|
1065
1147
|
--warn: #d9ae63;
|
|
1148
|
+
--error: #d9ae63;
|
|
1149
|
+
--error-bg: #362b18;
|
|
1066
1150
|
--system: #b79bc7;
|
|
1067
1151
|
--system-bg: #2c2436;
|
|
1068
1152
|
--user: #93a9d6;
|
|
@@ -1102,7 +1186,7 @@ summary:focus-visible, a:focus-visible, .verdict:focus-visible { outline: 2px so
|
|
|
1102
1186
|
.report-header p { font-family: var(--font-mono); font-size: 12px; letter-spacing: .02em; }
|
|
1103
1187
|
.overall { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
|
|
1104
1188
|
.overall span { font-family: var(--font-display); text-transform: uppercase; letter-spacing: .12em; font-size: 11px; color: var(--muted); }
|
|
1105
|
-
.summary-grid { display: grid; grid-template-columns: repeat(
|
|
1189
|
+
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; margin-bottom: 30px; overflow: clip; }
|
|
1106
1190
|
.summary-card { padding: 16px 22px; border-right: 1px solid var(--border); }
|
|
1107
1191
|
.summary-card:last-child { border-right: 0; }
|
|
1108
1192
|
.summary-card span { display: block; color: var(--muted); font-family: var(--font-display); text-transform: uppercase; letter-spacing: .08em; font-size: 11px; }
|
|
@@ -1117,6 +1201,7 @@ summary:focus-visible, a:focus-visible, .verdict:focus-visible { outline: 2px so
|
|
|
1117
1201
|
.verdict.tick { gap: 6px; font-family: var(--font-mono); font-size: 11px; font-weight: 600; letter-spacing: .04em; }
|
|
1118
1202
|
.verdict.tick.pass { color: var(--pass); }
|
|
1119
1203
|
.verdict.tick.fail { color: var(--fail); }
|
|
1204
|
+
.verdict.tick.error { color: var(--error); }
|
|
1120
1205
|
.tick-mark { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
|
|
1121
1206
|
.verdict.stamp {
|
|
1122
1207
|
--tilt: 0deg;
|
|
@@ -1137,6 +1222,7 @@ summary:focus-visible, a:focus-visible, .verdict:focus-visible { outline: 2px so
|
|
|
1137
1222
|
}
|
|
1138
1223
|
.verdict.stamp.pass { color: var(--pass); }
|
|
1139
1224
|
.verdict.stamp.fail { color: var(--fail); }
|
|
1225
|
+
.verdict.stamp.error { color: var(--error); }
|
|
1140
1226
|
.verdict.stamp.size-sm { font-size: 10px; padding: 2px 9px; }
|
|
1141
1227
|
.verdict.stamp.size-md { font-size: 12px; padding: 4px 13px; }
|
|
1142
1228
|
.verdict.stamp.size-lg { font-size: 17px; padding: 8px 22px; letter-spacing: .16em; }
|
|
@@ -1154,9 +1240,13 @@ summary:focus-visible, a:focus-visible, .verdict:focus-visible { outline: 2px so
|
|
|
1154
1240
|
.eyebrow { color: var(--muted); font-family: var(--font-display); text-transform: uppercase; letter-spacing: .12em; font-size: 11px; }
|
|
1155
1241
|
.case-outcome { min-width: 130px; display: grid; justify-items: end; align-content: start; gap: 5px; }
|
|
1156
1242
|
.case-outcome strong { font-family: var(--font-mono); font-size: 22px; }
|
|
1243
|
+
.case-errors { display: grid; gap: 8px; margin-top: 12px; }
|
|
1244
|
+
.case-error { padding: 10px 12px; border-radius: 6px; background: var(--error-bg); color: var(--error); }
|
|
1245
|
+
.case-error strong, .case-error span { display: inline-block; margin-right: 8px; }
|
|
1246
|
+
.case-error pre { margin-top: 6px; max-height: 180px; }
|
|
1157
1247
|
.case-tag-summary { padding: 16px 20px; border-bottom: 1px solid var(--border); }
|
|
1158
1248
|
.case-tag-summary h3 { margin: 0 0 10px; font-family: var(--font-display); font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
|
|
1159
|
-
.metadata { display: grid; grid-template-columns: repeat(
|
|
1249
|
+
.metadata { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); border-bottom: 1px solid var(--border); }
|
|
1160
1250
|
.metadata > div { min-width: 0; padding: 14px 20px; border-right: 1px solid var(--border); }
|
|
1161
1251
|
.metadata > div:last-child { border-right: 0; }
|
|
1162
1252
|
.metadata span, .metadata strong { display: block; }
|
|
@@ -1229,6 +1319,7 @@ table { width: 100%; border-collapse: collapse; }
|
|
|
1229
1319
|
th, td { padding: 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; min-width: 100px; }
|
|
1230
1320
|
th { color: var(--muted); font-family: var(--font-display); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
|
|
1231
1321
|
tr.failed td { background: color-mix(in srgb, var(--fail-bg) 45%, transparent); }
|
|
1322
|
+
tr.error td { background: color-mix(in srgb, var(--error-bg) 45%, transparent); }
|
|
1232
1323
|
.judge-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
|
|
1233
1324
|
.judge-dimension, .attachment { background: var(--surface-2); border-radius: 6px; padding: 12px; }
|
|
1234
1325
|
.judge-score { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
|
|
@@ -1249,7 +1340,7 @@ tr.failed td { background: color-mix(in srgb, var(--fail-bg) 45%, transparent);
|
|
|
1249
1340
|
.raw[open] > summary { margin-bottom: 8px; }
|
|
1250
1341
|
.request, .mock-event { padding: 10px 0; border-bottom: 1px solid var(--border); }
|
|
1251
1342
|
.request > summary, .mock-event > summary { display: flex; align-items: center; gap: 8px; }
|
|
1252
|
-
.run-error { margin-top: 16px; padding: 14px; border-radius: 6px; background: var(--
|
|
1343
|
+
.run-error { margin-top: 16px; padding: 14px; border-radius: 6px; background: var(--error-bg); color: var(--error); }
|
|
1253
1344
|
.run-error pre { margin-top: 8px; }
|
|
1254
1345
|
@media (prefers-reduced-motion: reduce) {
|
|
1255
1346
|
* { transition: none !important; animation: none !important; }
|
|
@@ -1329,7 +1420,28 @@ def render_html_report(
|
|
|
1329
1420
|
raise ValueError("HTML report requires one result for every resolved case")
|
|
1330
1421
|
|
|
1331
1422
|
total_runs = sum(len(result.runs) for result in results)
|
|
1332
|
-
|
|
1423
|
+
error_runs = sum(
|
|
1424
|
+
1 for result in results for run in result.runs if run.status == "error"
|
|
1425
|
+
)
|
|
1426
|
+
llm_errors = sum(
|
|
1427
|
+
1
|
|
1428
|
+
for result in results
|
|
1429
|
+
for run in result.runs
|
|
1430
|
+
if run.status == "error" and _error_kind(run) == "llm"
|
|
1431
|
+
)
|
|
1432
|
+
framework_errors = sum(
|
|
1433
|
+
1
|
|
1434
|
+
for result in results
|
|
1435
|
+
for run in result.runs
|
|
1436
|
+
if run.status == "error" and _error_kind(run) == "framework"
|
|
1437
|
+
)
|
|
1438
|
+
evaluated_runs = total_runs - error_runs
|
|
1439
|
+
passed_runs = sum(
|
|
1440
|
+
run.passed
|
|
1441
|
+
for result in results
|
|
1442
|
+
for run in result.runs
|
|
1443
|
+
if run.status != "error"
|
|
1444
|
+
)
|
|
1333
1445
|
checks = [
|
|
1334
1446
|
check
|
|
1335
1447
|
for result in results
|
|
@@ -1338,9 +1450,20 @@ def render_html_report(
|
|
|
1338
1450
|
for check in step.hard_checks
|
|
1339
1451
|
]
|
|
1340
1452
|
passed_checks = sum(check.get("passed", False) for check in checks)
|
|
1341
|
-
|
|
1342
|
-
|
|
1453
|
+
error_cases = sum(1 for result in results if result.status == "error")
|
|
1454
|
+
evaluated_cases = len(results) - error_cases
|
|
1455
|
+
passed_cases = sum(result.passed for result in results if result.status != "error")
|
|
1456
|
+
failed_cases = evaluated_cases - passed_cases
|
|
1457
|
+
if failed_cases:
|
|
1458
|
+
overall_status = "fail"
|
|
1459
|
+
elif error_cases:
|
|
1460
|
+
overall_status = "error"
|
|
1461
|
+
else:
|
|
1462
|
+
overall_status = "pass" if results else "fail"
|
|
1343
1463
|
total_usage = combine_usage(result.usage() for result in results)
|
|
1464
|
+
total_duration = combine_duration_ms(
|
|
1465
|
+
result.request_duration_ms() for result in results
|
|
1466
|
+
)
|
|
1344
1467
|
usage_card = (
|
|
1345
1468
|
f'<strong>{total_usage["total_tokens"]:,}</strong>'
|
|
1346
1469
|
f'<span class="usage-sub">{_text(_usage_split(total_usage))}</span>'
|
|
@@ -1352,17 +1475,16 @@ def render_html_report(
|
|
|
1352
1475
|
_render_case(case, result) for case, result in zip(cases, results, strict=True)
|
|
1353
1476
|
)
|
|
1354
1477
|
body = f"""<section class="summary-grid" aria-label="Summary">
|
|
1355
|
-
<div class="summary-card"><span>
|
|
1356
|
-
<div class="summary-card"><span>
|
|
1357
|
-
<div class="summary-card"><span>
|
|
1358
|
-
<div class="summary-card"><span>LLM tokens</span>{usage_card}</div>
|
|
1478
|
+
<div class="summary-card"><span>CASES PASSED</span><strong>{passed_cases}/{len(results)}</strong></div>
|
|
1479
|
+
<div class="summary-card"><span>CASES ERRORS</span><strong>{error_cases}/{len(results)}</strong></div>
|
|
1480
|
+
<div class="summary-card"><span>LLM TOKENS</span>{usage_card}</div>
|
|
1359
1481
|
</section>
|
|
1360
1482
|
{rendered_cases or '<p>No cases were included in this report.</p>'}"""
|
|
1361
1483
|
return render_page(
|
|
1362
1484
|
title="Yama Eval Report",
|
|
1363
1485
|
header_note_html=f"Generated {_text(generated_at)}",
|
|
1364
1486
|
overall_html=(
|
|
1365
|
-
_status(
|
|
1487
|
+
_status(overall_status, kind="stamp", size="lg", seed="overall")
|
|
1366
1488
|
+ "<span>Overall result</span>"
|
|
1367
1489
|
),
|
|
1368
1490
|
body_html=body,
|
|
@@ -1370,14 +1492,22 @@ def render_html_report(
|
|
|
1370
1492
|
"generator": "yama",
|
|
1371
1493
|
"kind": "report",
|
|
1372
1494
|
"generated_at": generated_at,
|
|
1373
|
-
"passed":
|
|
1495
|
+
"passed": overall_status == "pass",
|
|
1496
|
+
"status": overall_status,
|
|
1374
1497
|
"cases_passed": passed_cases,
|
|
1498
|
+
"cases_evaluated": evaluated_cases,
|
|
1499
|
+
"cases_error": error_cases,
|
|
1375
1500
|
"cases_total": len(results),
|
|
1376
1501
|
"runs_passed": passed_runs,
|
|
1502
|
+
"runs_evaluated": evaluated_runs,
|
|
1503
|
+
"runs_error": error_runs,
|
|
1504
|
+
"llm_errors": llm_errors,
|
|
1505
|
+
"framework_errors": framework_errors,
|
|
1377
1506
|
"runs_total": total_runs,
|
|
1378
1507
|
"checks_passed": passed_checks,
|
|
1379
1508
|
"checks_total": len(checks),
|
|
1380
1509
|
"total_tokens": total_usage["total_tokens"] if total_usage else None,
|
|
1510
|
+
"llm_request_duration_ms": total_duration,
|
|
1381
1511
|
},
|
|
1382
1512
|
)
|
|
1383
1513
|
|
yama/runner.py
CHANGED
|
@@ -4,12 +4,13 @@ import asyncio
|
|
|
4
4
|
import inspect
|
|
5
5
|
import json
|
|
6
6
|
import shutil
|
|
7
|
+
import time
|
|
7
8
|
import traceback
|
|
8
9
|
from copy import deepcopy
|
|
9
10
|
from dataclasses import dataclass, field
|
|
10
11
|
from datetime import datetime, timezone
|
|
11
12
|
from pathlib import Path
|
|
12
|
-
from typing import Any, Callable, Iterable, Mapping
|
|
13
|
+
from typing import Any, Callable, Iterable, Literal, Mapping
|
|
13
14
|
|
|
14
15
|
import yaml
|
|
15
16
|
|
|
@@ -22,7 +23,7 @@ from .assertions import (
|
|
|
22
23
|
run_judge,
|
|
23
24
|
)
|
|
24
25
|
from .tools.bash.fs import case_workspace_root, cleanup_session
|
|
25
|
-
from .llm import LLMClient
|
|
26
|
+
from .llm import LLMClient, LLMError
|
|
26
27
|
from .mocks import (
|
|
27
28
|
MockToolRegistry,
|
|
28
29
|
ToolMockContext,
|
|
@@ -33,6 +34,51 @@ from .mocks import (
|
|
|
33
34
|
from .models import ResolvedCase, StepResult, ToolCallRecord, sanitize_case_key
|
|
34
35
|
|
|
35
36
|
|
|
37
|
+
ResultStatus = Literal["pass", "fail", "error"]
|
|
38
|
+
ResultErrorKind = Literal["llm", "framework"]
|
|
39
|
+
_RESULT_STATUSES = {"pass", "fail", "error"}
|
|
40
|
+
_RESULT_ERROR_KINDS = {"llm", "framework"}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _status_from_passed(passed: bool) -> ResultStatus:
|
|
44
|
+
return "pass" if passed else "fail"
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _normalize_status(status: str | None, passed: bool) -> ResultStatus:
|
|
48
|
+
if status is None:
|
|
49
|
+
return _status_from_passed(passed)
|
|
50
|
+
if status not in _RESULT_STATUSES:
|
|
51
|
+
raise ValueError(f"unknown result status: {status!r}")
|
|
52
|
+
return status # type: ignore[return-value]
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def _status_passed(status: ResultStatus) -> bool:
|
|
56
|
+
return status == "pass"
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _normalize_error_kind(error_kind: str | None) -> ResultErrorKind | None:
|
|
60
|
+
if error_kind is None:
|
|
61
|
+
return None
|
|
62
|
+
if error_kind not in _RESULT_ERROR_KINDS:
|
|
63
|
+
raise ValueError(f"unknown result error kind: {error_kind!r}")
|
|
64
|
+
return error_kind # type: ignore[return-value]
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def _run_error_kind(exc: Exception) -> ResultErrorKind:
|
|
68
|
+
if isinstance(exc, (LLMError, TimeoutError)):
|
|
69
|
+
return "llm"
|
|
70
|
+
return "framework"
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def _case_status_from_runs(runs: Iterable["RunResult"]) -> ResultStatus:
|
|
74
|
+
statuses = [run.status for run in runs]
|
|
75
|
+
if any(status == "fail" for status in statuses):
|
|
76
|
+
return "fail"
|
|
77
|
+
if any(status == "error" for status in statuses):
|
|
78
|
+
return "error"
|
|
79
|
+
return "pass"
|
|
80
|
+
|
|
81
|
+
|
|
36
82
|
def _tool_result_content(result: Any) -> str:
|
|
37
83
|
"""Render a mock tool result as the `content` of a `role: tool` message.
|
|
38
84
|
|
|
@@ -82,6 +128,22 @@ def combine_usage(items: Iterable[Any]) -> dict[str, int] | None:
|
|
|
82
128
|
return total
|
|
83
129
|
|
|
84
130
|
|
|
131
|
+
def combine_duration_ms(items: Iterable[Any]) -> float | None:
|
|
132
|
+
"""Sum numeric millisecond durations while preserving "no data".
|
|
133
|
+
|
|
134
|
+
Request timing is advisory diagnostic data; missing values from older
|
|
135
|
+
artifacts should render as absent instead of as a misleading zero.
|
|
136
|
+
"""
|
|
137
|
+
total = 0.0
|
|
138
|
+
seen = False
|
|
139
|
+
for item in items:
|
|
140
|
+
if isinstance(item, bool) or not isinstance(item, (int, float)):
|
|
141
|
+
continue
|
|
142
|
+
seen = True
|
|
143
|
+
total += float(item)
|
|
144
|
+
return total if seen else None
|
|
145
|
+
|
|
146
|
+
|
|
85
147
|
@dataclass(frozen=True)
|
|
86
148
|
class RunSpec:
|
|
87
149
|
"""One planned run of a case: its 1-based index across the whole plan,
|
|
@@ -172,6 +234,8 @@ class MaxToolRoundsExceeded(RuntimeError):
|
|
|
172
234
|
class RunResult:
|
|
173
235
|
run_index: int
|
|
174
236
|
passed: bool
|
|
237
|
+
status: ResultStatus | None = None
|
|
238
|
+
error_kind: ResultErrorKind | None = None
|
|
175
239
|
steps: list[StepResult] = field(default_factory=list)
|
|
176
240
|
error: str | None = None
|
|
177
241
|
traceback: str | None = None
|
|
@@ -183,6 +247,19 @@ class RunResult:
|
|
|
183
247
|
model: dict[str, Any] = field(default_factory=dict)
|
|
184
248
|
tag_summary: dict[str, dict[str, Any]] = field(default_factory=dict)
|
|
185
249
|
|
|
250
|
+
def __post_init__(self) -> None:
|
|
251
|
+
self.status = _normalize_status(self.status, self.passed)
|
|
252
|
+
expected_passed = _status_passed(self.status)
|
|
253
|
+
if self.passed != expected_passed:
|
|
254
|
+
raise ValueError(
|
|
255
|
+
f"RunResult passed={self.passed!r} conflicts with status={self.status!r}"
|
|
256
|
+
)
|
|
257
|
+
self.error_kind = _normalize_error_kind(self.error_kind)
|
|
258
|
+
if self.status != "error" and self.error_kind is not None:
|
|
259
|
+
raise ValueError(
|
|
260
|
+
f"RunResult status={self.status!r} cannot carry error_kind={self.error_kind!r}"
|
|
261
|
+
)
|
|
262
|
+
|
|
186
263
|
def usage(self) -> dict[str, int] | None:
|
|
187
264
|
"""Token usage of every LLM call this run made: the step tool-loop
|
|
188
265
|
requests plus judge calls (which bypass `requests` and land their
|
|
@@ -196,15 +273,23 @@ class RunResult:
|
|
|
196
273
|
]
|
|
197
274
|
)
|
|
198
275
|
|
|
276
|
+
def request_duration_ms(self) -> float | None:
|
|
277
|
+
return combine_duration_ms(
|
|
278
|
+
request.get("duration_ms") for request in self.requests
|
|
279
|
+
)
|
|
280
|
+
|
|
199
281
|
def to_dict(self) -> dict[str, Any]:
|
|
200
282
|
return {
|
|
201
283
|
"run_index": self.run_index,
|
|
202
284
|
"label": self.label,
|
|
203
285
|
"model": self.model,
|
|
204
286
|
"passed": self.passed,
|
|
287
|
+
"status": self.status,
|
|
288
|
+
"error_kind": self.error_kind,
|
|
205
289
|
"steps": [step.to_dict() for step in self.steps],
|
|
206
290
|
"error": self.error,
|
|
207
291
|
"usage": self.usage(),
|
|
292
|
+
"request_duration_ms": self.request_duration_ms(),
|
|
208
293
|
"mock_events": self.mock_events,
|
|
209
294
|
"mock_state": self.mock_state,
|
|
210
295
|
"requests": self.requests,
|
|
@@ -217,11 +302,21 @@ class RunResult:
|
|
|
217
302
|
|
|
218
303
|
|
|
219
304
|
def _thresholds_from_outcome(outcome: Mapping[str, Any]) -> dict[str, float]:
|
|
220
|
-
|
|
305
|
+
require = outcome.get("require", {})
|
|
306
|
+
if not isinstance(require, Mapping):
|
|
307
|
+
require = {}
|
|
308
|
+
hard_checks = require.get("hard_checks", {})
|
|
309
|
+
threshold_path = "outcome.require.hard_checks.tags"
|
|
310
|
+
raw_thresholds = None
|
|
311
|
+
if isinstance(hard_checks, Mapping):
|
|
312
|
+
raw_thresholds = hard_checks.get("tags")
|
|
313
|
+
if raw_thresholds is None:
|
|
314
|
+
raw_thresholds = require.get("tags", {})
|
|
315
|
+
threshold_path = "outcome.require.tags"
|
|
221
316
|
if raw_thresholds is None:
|
|
222
317
|
raw_thresholds = {}
|
|
223
318
|
if not isinstance(raw_thresholds, Mapping):
|
|
224
|
-
raise AssertionConfigurationError("
|
|
319
|
+
raise AssertionConfigurationError(f"{threshold_path} must be an object")
|
|
225
320
|
thresholds = dict(HARD_ASSERTION_TAG_THRESHOLDS)
|
|
226
321
|
for tag, value in raw_thresholds.items():
|
|
227
322
|
if tag not in HARD_ASSERTION_TAG_THRESHOLDS:
|
|
@@ -231,16 +326,16 @@ def _thresholds_from_outcome(outcome: Mapping[str, Any]) -> dict[str, float]:
|
|
|
231
326
|
)
|
|
232
327
|
if isinstance(value, bool) or not isinstance(value, (int, float)):
|
|
233
328
|
raise AssertionConfigurationError(
|
|
234
|
-
f"
|
|
329
|
+
f"{threshold_path}[{tag!r}] must be a number in [0, 1], got {value!r}"
|
|
235
330
|
)
|
|
236
331
|
threshold = float(value)
|
|
237
332
|
if not 0.0 <= threshold <= 1.0:
|
|
238
333
|
raise AssertionConfigurationError(
|
|
239
|
-
f"
|
|
334
|
+
f"{threshold_path}[{tag!r}] must be a number in [0, 1], got {value!r}"
|
|
240
335
|
)
|
|
241
336
|
if tag == DEFAULT_HARD_ASSERTION_TAG and threshold != 1.0:
|
|
242
337
|
raise AssertionConfigurationError(
|
|
243
|
-
"
|
|
338
|
+
f"{threshold_path}['must_pass'] is fixed at 1.0"
|
|
244
339
|
)
|
|
245
340
|
thresholds[tag] = threshold
|
|
246
341
|
return thresholds
|
|
@@ -310,19 +405,31 @@ class CaseResult:
|
|
|
310
405
|
runs: list[RunResult]
|
|
311
406
|
pass_rate: float
|
|
312
407
|
description: str = ""
|
|
313
|
-
|
|
408
|
+
status: ResultStatus | None = None
|
|
409
|
+
|
|
410
|
+
def __post_init__(self) -> None:
|
|
411
|
+
self.status = _normalize_status(self.status, self.passed)
|
|
412
|
+
expected_passed = _status_passed(self.status)
|
|
413
|
+
if self.passed != expected_passed:
|
|
414
|
+
raise ValueError(
|
|
415
|
+
f"CaseResult passed={self.passed!r} conflicts with status={self.status!r}"
|
|
416
|
+
)
|
|
314
417
|
|
|
315
418
|
def usage(self) -> dict[str, int] | None:
|
|
316
419
|
return combine_usage(run.usage() for run in self.runs)
|
|
317
420
|
|
|
421
|
+
def request_duration_ms(self) -> float | None:
|
|
422
|
+
return combine_duration_ms(run.request_duration_ms() for run in self.runs)
|
|
423
|
+
|
|
318
424
|
def to_dict(self) -> dict[str, Any]:
|
|
319
425
|
return {
|
|
320
426
|
"case_key": self.case_key,
|
|
321
427
|
"description": self.description,
|
|
322
428
|
"passed": self.passed,
|
|
429
|
+
"status": self.status,
|
|
323
430
|
"pass_rate": self.pass_rate,
|
|
324
431
|
"usage": self.usage(),
|
|
325
|
-
"
|
|
432
|
+
"request_duration_ms": self.request_duration_ms(),
|
|
326
433
|
"runs": [run.to_dict() for run in self.runs],
|
|
327
434
|
}
|
|
328
435
|
|
|
@@ -366,14 +473,17 @@ class YamaRunner:
|
|
|
366
473
|
)
|
|
367
474
|
self._clean_case_dirs(case)
|
|
368
475
|
runs = [await self._run_once(case, spec, total=len(plan)) for spec in plan]
|
|
369
|
-
|
|
476
|
+
evaluated_runs = [run for run in runs if run.status != "error"]
|
|
477
|
+
passed_count = sum(run.passed for run in evaluated_runs)
|
|
478
|
+
status = _case_status_from_runs(runs)
|
|
479
|
+
denominator = len(evaluated_runs)
|
|
370
480
|
result = CaseResult(
|
|
371
481
|
case_key=case.case_key,
|
|
372
482
|
description=case.description,
|
|
373
|
-
passed=
|
|
483
|
+
passed=status == "pass",
|
|
484
|
+
status=status,
|
|
374
485
|
runs=runs,
|
|
375
|
-
pass_rate=passed_count /
|
|
376
|
-
tag_summary=case_tag_summary(runs),
|
|
486
|
+
pass_rate=passed_count / denominator if denominator else 0.0,
|
|
377
487
|
)
|
|
378
488
|
self._emit("case_end", result=result)
|
|
379
489
|
return result
|
|
@@ -426,6 +536,9 @@ class YamaRunner:
|
|
|
426
536
|
except MaxToolRoundsExceeded as exc:
|
|
427
537
|
messages[:] = transcript_before
|
|
428
538
|
step_result = self._max_tool_rounds_step_result(case, step, exc)
|
|
539
|
+
step_result.tag_summary = tag_pass_summary(
|
|
540
|
+
[step_result], case.outcome
|
|
541
|
+
)
|
|
429
542
|
steps.append(step_result)
|
|
430
543
|
self._emit(
|
|
431
544
|
"step_end",
|
|
@@ -447,6 +560,7 @@ class YamaRunner:
|
|
|
447
560
|
step_result.hard_pass = all(
|
|
448
561
|
check["passed"] for check in step_result.hard_checks
|
|
449
562
|
)
|
|
563
|
+
step_result.tag_summary = tag_pass_summary([step_result], case.outcome)
|
|
450
564
|
judge_config = assertion_config.get("judge")
|
|
451
565
|
if judge_config and (
|
|
452
566
|
step_result.hard_pass
|
|
@@ -462,6 +576,7 @@ class YamaRunner:
|
|
|
462
576
|
transcript_before_step=transcript_before,
|
|
463
577
|
default_model=case.model,
|
|
464
578
|
)
|
|
579
|
+
self._apply_judge_overall_requirement(case, step_result)
|
|
465
580
|
steps.append(step_result)
|
|
466
581
|
self._emit(
|
|
467
582
|
"step_end",
|
|
@@ -484,9 +599,12 @@ class YamaRunner:
|
|
|
484
599
|
tag_summary=tag_summary,
|
|
485
600
|
)
|
|
486
601
|
except Exception as exc:
|
|
602
|
+
status: ResultStatus = "error"
|
|
487
603
|
run = RunResult(
|
|
488
604
|
run_index=run_index,
|
|
489
|
-
passed=
|
|
605
|
+
passed=status == "pass",
|
|
606
|
+
status=status,
|
|
607
|
+
error_kind=_run_error_kind(exc),
|
|
490
608
|
steps=steps,
|
|
491
609
|
error=f"{type(exc).__name__}: {exc}",
|
|
492
610
|
traceback=traceback.format_exc(),
|
|
@@ -599,6 +717,7 @@ class YamaRunner:
|
|
|
599
717
|
"request_index": request_index,
|
|
600
718
|
}
|
|
601
719
|
requests.append(request_record)
|
|
720
|
+
started = time.perf_counter()
|
|
602
721
|
try:
|
|
603
722
|
response = await self.llm.complete(
|
|
604
723
|
messages=request_messages,
|
|
@@ -615,6 +734,9 @@ class YamaRunner:
|
|
|
615
734
|
resolved_provider = getattr(self.llm, "last_provider", None)
|
|
616
735
|
if resolved_provider is not None:
|
|
617
736
|
request_record["resolved_provider"] = deepcopy(resolved_provider)
|
|
737
|
+
request_record["duration_ms"] = round(
|
|
738
|
+
(time.perf_counter() - started) * 1000, 3
|
|
739
|
+
)
|
|
618
740
|
assistant = response.assistant_message()
|
|
619
741
|
request_record["response"] = deepcopy(assistant)
|
|
620
742
|
if response.usage is not None:
|
|
@@ -743,10 +865,8 @@ class YamaRunner:
|
|
|
743
865
|
if judge_requirement and not judge_results:
|
|
744
866
|
return False
|
|
745
867
|
if "overall_gte" in judge_requirement:
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
)
|
|
749
|
-
if overall < judge_requirement["overall_gte"]:
|
|
868
|
+
threshold = judge_requirement["overall_gte"]
|
|
869
|
+
if any(result["overall"] < threshold for result in judge_results):
|
|
750
870
|
return False
|
|
751
871
|
if "each_dimension_gte" in judge_requirement:
|
|
752
872
|
threshold = judge_requirement["each_dimension_gte"]
|
|
@@ -757,6 +877,27 @@ class YamaRunner:
|
|
|
757
877
|
return False
|
|
758
878
|
return True
|
|
759
879
|
|
|
880
|
+
def _apply_judge_overall_requirement(
|
|
881
|
+
self, case: ResolvedCase, step: StepResult
|
|
882
|
+
) -> None:
|
|
883
|
+
judge = step.judge_result
|
|
884
|
+
if judge is None:
|
|
885
|
+
return
|
|
886
|
+
judge_requirement = case.outcome.get("require", {}).get("judge", {})
|
|
887
|
+
if "overall_gte" not in judge_requirement:
|
|
888
|
+
return
|
|
889
|
+
threshold = judge_requirement["overall_gte"]
|
|
890
|
+
if not isinstance(threshold, (int, float)):
|
|
891
|
+
return
|
|
892
|
+
overall = judge.get("overall")
|
|
893
|
+
if not isinstance(overall, (int, float)):
|
|
894
|
+
return
|
|
895
|
+
dimensions_passed = bool(judge.get("passed", False))
|
|
896
|
+
judge["dimensions_passed"] = dimensions_passed
|
|
897
|
+
judge["overall_required"] = threshold
|
|
898
|
+
judge["overall_passed"] = overall >= threshold
|
|
899
|
+
judge["passed"] = dimensions_passed and judge["overall_passed"]
|
|
900
|
+
|
|
760
901
|
def _clean_case_dirs(self, case: ResolvedCase) -> None:
|
|
761
902
|
"""Drop leftovers of earlier executions before the first run starts.
|
|
762
903
|
|
yama/thread_case.py
CHANGED
|
@@ -20,7 +20,9 @@ _PROD_DSL_SSH_HOST = "1.1.1.1" # TODO: replace with the real prod SSH host
|
|
|
20
20
|
_DEV_STAGING_DSL_REMOTE_BASE_DIR = "/work/aion-runtime-v2-dev"
|
|
21
21
|
_PROD_DSL_REMOTE_BASE_DIR = "/work/aion-runtime-v2-prod"
|
|
22
22
|
|
|
23
|
-
_FIXED_OUTCOME: dict[str, Any] = {
|
|
23
|
+
_FIXED_OUTCOME: dict[str, Any] = {
|
|
24
|
+
"require": {"hard_checks": {"tags": {"must_pass": 1.0}}}
|
|
25
|
+
}
|
|
24
26
|
|
|
25
27
|
|
|
26
28
|
class ThreadCaseError(RuntimeError):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|