gooddata-eval 1.80.1.dev1__py3-none-any.whl → 1.80.1.dev3__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.
Files changed (38) hide show
  1. gooddata_eval/cli/agentic_runner.py +16 -3
  2. gooddata_eval/cli/main.py +2 -2
  3. gooddata_eval/core/agentic/_failed_runs.py +53 -19
  4. gooddata_eval/core/agentic/_failure_message.py +198 -0
  5. gooddata_eval/core/agentic/_filters.py +50 -0
  6. gooddata_eval/core/agentic/_gate.py +10 -3
  7. gooddata_eval/core/agentic/_langfuse.py +3 -3
  8. gooddata_eval/core/agentic/_outcome.py +198 -3
  9. gooddata_eval/core/agentic/_trace_linker.py +5 -4
  10. gooddata_eval/core/agentic/alert_skill.py +30 -5
  11. gooddata_eval/core/agentic/anomaly_detection.py +40 -15
  12. gooddata_eval/core/agentic/conversation.py +9 -3
  13. gooddata_eval/core/agentic/dashboard_skill.py +265 -72
  14. gooddata_eval/core/agentic/document_skill.py +332 -27
  15. gooddata_eval/core/agentic/general_question.py +30 -7
  16. gooddata_eval/core/agentic/guardrail.py +30 -7
  17. gooddata_eval/core/agentic/kda_skill.py +38 -6
  18. gooddata_eval/core/agentic/metric_skill.py +41 -5
  19. gooddata_eval/core/agentic/visualization.py +133 -14
  20. gooddata_eval/core/agentic/what_if.py +42 -17
  21. gooddata_eval/core/chat/sse_client.py +39 -12
  22. gooddata_eval/core/dataset/from_insights.py +2 -2
  23. gooddata_eval/core/evaluators/_llm_judge.py +4 -0
  24. gooddata_eval/core/evaluators/visualization.py +197 -3
  25. gooddata_eval/core/langfuse/client.py +2 -2
  26. gooddata_eval/core/langfuse/observations.py +2 -2
  27. gooddata_eval/core/langfuse/otlp.py +3 -3
  28. gooddata_eval/core/langfuse/sink.py +2 -2
  29. gooddata_eval/core/models.py +31 -5
  30. gooddata_eval/core/outcome.py +159 -0
  31. gooddata_eval/core/reporting/html_report.py +2 -2
  32. gooddata_eval/core/reporting/json_report.py +3 -0
  33. gooddata_eval/core/runner.py +13 -3
  34. {gooddata_eval-1.80.1.dev1.dist-info → gooddata_eval-1.80.1.dev3.dist-info}/METADATA +46 -4
  35. {gooddata_eval-1.80.1.dev1.dist-info → gooddata_eval-1.80.1.dev3.dist-info}/RECORD +38 -35
  36. {gooddata_eval-1.80.1.dev1.dist-info → gooddata_eval-1.80.1.dev3.dist-info}/WHEEL +0 -0
  37. {gooddata_eval-1.80.1.dev1.dist-info → gooddata_eval-1.80.1.dev3.dist-info}/entry_points.txt +0 -0
  38. {gooddata_eval-1.80.1.dev1.dist-info → gooddata_eval-1.80.1.dev3.dist-info}/licenses/LICENSE.txt +0 -0
@@ -6,7 +6,7 @@ from __future__ import annotations
6
6
  import sys
7
7
  import time
8
8
  from concurrent.futures import ThreadPoolExecutor, as_completed
9
- from datetime import datetime, timezone
9
+ from datetime import UTC, datetime
10
10
  from typing import Any, TypedDict
11
11
 
12
12
  from gooddata_eval.core.agentic._gate import DEFAULT_GATE, EvalGate, normalize_gate
@@ -404,6 +404,16 @@ def _apply_run_counts(item_report: ItemReport, source: Any) -> None:
404
404
  item_report.runs_ungraded = unscored
405
405
 
406
406
 
407
+ def _apply_labels(item_report: ItemReport, source: Any) -> None:
408
+ """Copy the item's harness label and shadow verdict off an outcome or a failure, if set."""
409
+ harness_error = getattr(source, "harness_error", None)
410
+ if isinstance(harness_error, dict):
411
+ item_report.harness_error = harness_error
412
+ shadow = getattr(source, "shadow", None)
413
+ if isinstance(shadow, dict):
414
+ item_report.shadow = shadow
415
+
416
+
407
417
  def _apply_failed_runs(item_report: ItemReport, source: Any) -> None:
408
418
  """Copy the per-run failure records off an outcome or a failure, if the kind built any.
409
419
 
@@ -496,7 +506,7 @@ def run_agentic_items(
496
506
  # latency. Drained below before this function returns, so every score is written
497
507
  # before the caller renders a report or decides an exit code.
498
508
  linker = BackgroundTraceLinker()
499
- report.started_at = datetime.now(timezone.utc)
509
+ report.started_at = datetime.now(UTC)
500
510
  _t0 = time.perf_counter()
501
511
 
502
512
  def _process_item(index: int, item: DatasetItem) -> ItemReport:
@@ -555,6 +565,7 @@ def run_agentic_items(
555
565
  _apply_best_run_latency(item_report, outcome)
556
566
  _apply_run_counts(item_report, outcome)
557
567
  _apply_failed_runs(item_report, outcome)
568
+ _apply_labels(item_report, outcome)
558
569
  _apply_run_latencies(item_report, outcome)
559
570
  except AssertionError as exc:
560
571
  item_report.gate_passed = False if gated else None
@@ -567,6 +578,7 @@ def run_agentic_items(
567
578
  _apply_best_run_latency(item_report, exc)
568
579
  _apply_run_counts(item_report, exc)
569
580
  _apply_failed_runs(item_report, exc)
581
+ _apply_labels(item_report, exc)
570
582
  _apply_run_latencies(item_report, exc)
571
583
  # Read off the counts, not off the gate: pass^K fails items where runs did pass,
572
584
  # and reporting those as pass_at_k False would contradict the Langfuse score of
@@ -588,6 +600,7 @@ def run_agentic_items(
588
600
  _apply_timings(item_report, getattr(exc, "timings", None))
589
601
  _apply_run_counts(item_report, exc)
590
602
  _apply_failed_runs(item_report, exc)
603
+ _apply_labels(item_report, exc)
591
604
  _apply_run_latencies(item_report, exc)
592
605
  # Every run ungraded, by definition of this error -- said explicitly rather than
593
606
  # left to _apply_run_counts, whose source is detail["unscored_runs"] and which a
@@ -692,7 +705,7 @@ def run_agentic_items(
692
705
  flush=True,
693
706
  )
694
707
  report.wall_clock_s = time.perf_counter() - _t0
695
- report.finished_at = datetime.now(timezone.utc)
708
+ report.finished_at = datetime.now(UTC)
696
709
 
697
710
  if langfuse is not None:
698
711
  try:
gooddata_eval/cli/main.py CHANGED
@@ -5,7 +5,7 @@ import argparse
5
5
  import os
6
6
  import sys
7
7
  import threading
8
- from datetime import datetime, timezone
8
+ from datetime import UTC, datetime
9
9
  from pathlib import Path
10
10
  from typing import Any, get_args
11
11
 
@@ -516,7 +516,7 @@ def _run(config: RunConfig) -> int:
516
516
  _reject_power_gate_on_ungated_items(config, items)
517
517
  _warn_if_local_dataset_cannot_link(config, agentic_items)
518
518
  models = config.models or []
519
- run_ts = datetime.now(timezone.utc).strftime("%Y-%m-%d-%H-%M")
519
+ run_ts = datetime.now(UTC).strftime("%Y-%m-%d-%H-%M")
520
520
  n_models = len(models) if models else 1
521
521
 
522
522
  controller = WorkspaceModelController(config.host, config.token, config.workspace_id)
@@ -25,17 +25,28 @@ from __future__ import annotations
25
25
  from collections.abc import Callable, Sequence
26
26
  from typing import Any
27
27
 
28
+ from gooddata_eval.core.agentic._failure_message import cap_failed_checks
29
+ from gooddata_eval.core.agentic._outcome import RunLabels, run_exit_reason, run_outcome
28
30
  from gooddata_eval.core.models import build_tool_calls
31
+ from gooddata_eval.core.outcome import OutcomeStatus
29
32
 
30
33
 
31
34
  def build_failed_runs(
32
35
  run_results: Sequence[Any],
33
36
  *,
34
- passed: Callable[[Any], bool],
35
37
  detail: Callable[[Any], dict],
38
+ labels: RunLabels | None = None,
39
+ passed: Callable[[Any], bool] | None = None,
40
+ failed_checks: Callable[[Any], list[dict]] | None = None,
36
41
  ) -> list[dict]:
37
42
  """One record per run that did not pass, in the order the runs happened.
38
43
 
44
+ A kind that labels its runs passes its ``labels`` (from ``label_runs``, in run order):
45
+ they say which runs did not pass and are the ``outcome`` of each record, so the records,
46
+ the failure message and the Langfuse ``eval_error`` marker read one set of labels. A kind
47
+ that does not label its runs passes ``passed`` instead, and each record's ``outcome`` is
48
+ worked out here from the run alone. Exactly one of the two is given.
49
+
39
50
  ``passed`` and ``detail`` are supplied by the caller because neither is uniform across
40
51
  kinds: guardrail reads ``run.passed`` while visualization reads
41
52
  ``run.eval_result.strict_pass``, and each kind's diagnostic dict is its own. Everything
@@ -45,28 +56,51 @@ def build_failed_runs(
45
56
  ``ToolCallEvent``s, so a run that has the list must hold real events in it.
46
57
 
47
58
  A run the judge could not grade is recorded like any other non-passing run, with its
48
- ``error`` set. That matches ``core/runner.py``, which also records ungraded runs; the
49
- verdict-level accounting of ungraded runs stays with the caller's ``unscored_runs``.
59
+ ``error`` set to the run's ``judge_error``. That matches ``core/runner.py``, which also
60
+ records ungraded runs; the verdict-level accounting of ungraded runs stays with the
61
+ caller's ``unscored_runs``.
62
+
63
+ ``exit_reason`` is the run's ``LoopExit`` value, or null for a kind whose loop records
64
+ none, and ``outcome`` its ``core.outcome.Outcome`` record: ERROR when the harness failed
65
+ (its simulated user, or its judge when the judge's verdict was the one still open), FAIL
66
+ otherwise. ``error`` and ``outcome`` can differ: a run that failed a fixed check and whose
67
+ judge also broke has ``error`` set and is a FAIL. The label decides nothing; the run counts
68
+ as not passed either way.
69
+
70
+ ``failed_checks`` is written only when the caller supplies it: a missing key means the
71
+ kind does not name its failing checks, while an empty list would claim the run failed
72
+ none. Its expected/actual values are capped in size; the run's ``detail`` keeps them whole.
50
73
  """
74
+ if (labels is None) == (passed is None):
75
+ raise ValueError("build_failed_runs takes exactly one of labels and passed")
76
+ if labels is not None and len(labels.outcomes) != len(run_results):
77
+ raise ValueError(f"{len(labels.outcomes)} labels for {len(run_results)} runs")
51
78
  records: list[dict] = []
52
79
  for run_index, run in enumerate(run_results, start=1):
53
- if passed(run):
80
+ if labels is not None:
81
+ outcome = labels.outcomes[run_index - 1]
82
+ else:
83
+ outcome = run_outcome(run, passed=passed is not None and passed(run))
84
+ if outcome.status is OutcomeStatus.PASS:
54
85
  continue
55
86
  tool_calls = list(getattr(run, "tool_call_events", None) or [])
56
87
  reasoning_steps = list(getattr(run, "reasoning_steps", None) or [])
57
- records.append(
58
- {
59
- "run_index": run_index,
60
- "passed": False,
61
- "error": getattr(run, "judge_error", None),
62
- "detail": detail(run),
63
- "conversation_id": getattr(run, "conversation_id", None),
64
- "response_id": getattr(run, "response_id", None),
65
- "reasoning_step_count": len(reasoning_steps),
66
- "reasoning_steps": reasoning_steps,
67
- "tool_call_count": len(tool_calls),
68
- "tool_names": [getattr(e, "function_name", None) for e in tool_calls],
69
- "tool_calls": build_tool_calls(tool_calls),
70
- }
71
- )
88
+ record: dict[str, Any] = {
89
+ "run_index": run_index,
90
+ "passed": False,
91
+ "error": getattr(run, "judge_error", None),
92
+ "detail": detail(run),
93
+ "conversation_id": getattr(run, "conversation_id", None),
94
+ "response_id": getattr(run, "response_id", None),
95
+ "reasoning_step_count": len(reasoning_steps),
96
+ "reasoning_steps": reasoning_steps,
97
+ "tool_call_count": len(tool_calls),
98
+ "tool_names": [getattr(e, "function_name", None) for e in tool_calls],
99
+ "tool_calls": build_tool_calls(tool_calls),
100
+ "exit_reason": run_exit_reason(run),
101
+ "outcome": outcome.as_record(),
102
+ }
103
+ if failed_checks is not None:
104
+ record["failed_checks"] = cap_failed_checks(failed_checks(run))
105
+ records.append(record)
72
106
  return records
@@ -0,0 +1,198 @@
1
+ # (C) 2026 GoodData Corporation
2
+ """The head of an agentic kind's failure message: the gate result, then every failing run.
3
+
4
+ Each kind's assertion message describes its BEST run, which on a partial gate failure (some
5
+ of the K runs passed) is a passing run: every check reads True and the reason the item
6
+ failed is nowhere in the message. This module renders the part that is missing -- for each
7
+ failing run its index, why its loop stopped and the checks it failed, with expected/actual
8
+ where the kind knows them -- from the same ``failed_runs`` records the item reports, so the
9
+ message and the triage data cannot disagree about which runs failed or why.
10
+
11
+ One renderer for every kind that labels its runs, on purpose: the readers of these messages
12
+ (people and the triage tooling) look for one shape, whatever the capability under test.
13
+ """
14
+
15
+ from __future__ import annotations
16
+
17
+ import json
18
+ from collections.abc import Iterable, Mapping, Sequence
19
+ from dataclasses import dataclass
20
+ from enum import Enum
21
+ from typing import Any
22
+
23
+ from gooddata_eval.core.outcome import UNKNOWN_REASON, OutcomeStatus
24
+
25
+ __all__ = [
26
+ "FailedCheck",
27
+ "cap_failed_checks",
28
+ "failed_check_records",
29
+ "failed_checks_from",
30
+ "failing_runs_note",
31
+ "failure_head",
32
+ "judge_failed_checks",
33
+ ]
34
+
35
+ # A value longer than this is cut: the message is one line per run, and the whole value is in
36
+ # the run's detail anyway.
37
+ _MAX_VALUE_CHARS = 160
38
+
39
+ # The failing runs together are cut past this, at a run boundary: K runs of a kind with a dozen
40
+ # checks would otherwise put tens of thousands of characters into one assertion message. Every
41
+ # run is in ``failed_runs`` whatever the message shows.
42
+ _MAX_FAILING_RUNS_CHARS = 2000
43
+
44
+
45
+ class _Unset(Enum):
46
+ UNSET = "unset"
47
+
48
+
49
+ _UNSET = _Unset.UNSET
50
+
51
+
52
+ @dataclass(frozen=True)
53
+ class FailedCheck:
54
+ """One check a run failed, with the expected/actual pair when the kind knows it.
55
+
56
+ ``part`` narrows the check when one name covers several parts, e.g. the ``date`` part of
57
+ ``filters_correct``.
58
+ """
59
+
60
+ name: str
61
+ expected: Any = _UNSET
62
+ actual: Any = _UNSET
63
+ part: str | None = None
64
+
65
+ def as_record(self) -> dict[str, Any]:
66
+ """The JSON-ready form written into a failing run's ``failed_checks``."""
67
+ record: dict[str, Any] = {"name": self.name}
68
+ if self.part is not None:
69
+ record["part"] = self.part
70
+ if self.expected is not _UNSET:
71
+ record["expected"] = self.expected
72
+ if self.actual is not _UNSET:
73
+ record["actual"] = self.actual
74
+ return record
75
+
76
+
77
+ def failed_check_records(checks: Iterable[FailedCheck]) -> list[dict[str, Any]]:
78
+ """``checks`` as the records ``failed_runs[].failed_checks`` holds."""
79
+ return [check.as_record() for check in checks]
80
+
81
+
82
+ def failed_checks_from(checks: Mapping[str, bool], *, prerequisite: str | None = None) -> list[dict[str, Any]]:
83
+ """The records of the checks in ``checks`` that read False, by name, in their order.
84
+
85
+ ``prerequisite`` names the check every other one depends on, e.g. ``alert_created``. When it
86
+ failed, the others read False only because there was nothing to check, so it alone is named.
87
+ """
88
+ if prerequisite is not None and checks.get(prerequisite) is False:
89
+ return failed_check_records([FailedCheck(prerequisite)])
90
+ return failed_check_records(FailedCheck(name) for name, ok in checks.items() if not ok)
91
+
92
+
93
+ def judge_failed_checks(name: str, *, passed: bool, judge_error: str | None, reasoning: Any) -> list[dict[str, Any]]:
94
+ """The judge's verdict ``name`` on a run it failed, with its reasoning as the actual value.
95
+
96
+ Empty when the judge passed the run, or could not grade it: a run with no verdict failed no
97
+ judge check.
98
+ """
99
+ if judge_error is not None or passed:
100
+ return []
101
+ return failed_check_records([FailedCheck(name, part="judge", actual=reasoning)])
102
+
103
+
104
+ def _text(value: Any) -> str:
105
+ text = value if isinstance(value, str) else json.dumps(value, default=str, ensure_ascii=False, sort_keys=True)
106
+ return " ".join(text.split())
107
+
108
+
109
+ def _value(value: Any) -> str:
110
+ if value is None or value == [] or value == {} or value == "":
111
+ return "none"
112
+ text = _text(value)
113
+ return text if len(text) <= _MAX_VALUE_CHARS else text[: _MAX_VALUE_CHARS - 3] + "..."
114
+
115
+
116
+ def cap_failed_checks(records: Sequence[Mapping[str, Any]]) -> list[dict[str, Any]]:
117
+ """``records`` with every expected/actual value cut to what the message shows of it.
118
+
119
+ A check's values can be whole filter or bucket structures, repeated for every failing run
120
+ of every item; the record keeps the same ``_MAX_VALUE_CHARS`` the message does. A value
121
+ that fits stays as it is, JSON and all; a longer one becomes its cut text. The run's
122
+ ``detail`` holds the full values.
123
+ """
124
+ capped: list[dict[str, Any]] = []
125
+ for record in records:
126
+ entry = dict(record)
127
+ for key in ("expected", "actual"):
128
+ if key in entry and len(_text(entry[key])) > _MAX_VALUE_CHARS:
129
+ entry[key] = _value(entry[key])
130
+ capped.append(entry)
131
+ return capped
132
+
133
+
134
+ def _render_check(record: Mapping[str, Any]) -> str:
135
+ name = str(record.get("name", "?"))
136
+ parts: list[str] = []
137
+ if "expected" in record:
138
+ parts.append(f"expected {_value(record['expected'])}")
139
+ if "actual" in record:
140
+ parts.append(f"actual {_value(record['actual'])}")
141
+ part = record.get("part")
142
+ if not parts and part is None:
143
+ return name
144
+ inner = ", ".join(parts)
145
+ if part is not None:
146
+ inner = f"{part}: {inner}" if inner else str(part)
147
+ return f"{name}[{inner}]"
148
+
149
+
150
+ def _render_run(record: Mapping[str, Any], runs_total: int) -> str:
151
+ outcome = record.get("outcome")
152
+ head = f"run {record.get('run_index', '?')}/{runs_total}"
153
+ exit_reason = record.get("exit_reason")
154
+ errored = isinstance(outcome, Mapping) and outcome.get("status") == OutcomeStatus.ERROR.value
155
+ if errored:
156
+ # A harness error: the reason (simulated_user_failed, judge_failed) is the diagnosis.
157
+ # Its checks are still listed: the simulated user is also asked after an answer that
158
+ # was already final, and what that answer missed is the only way to tell.
159
+ head += f" ERROR ({outcome.get('reason') or UNKNOWN_REASON})"
160
+ else:
161
+ head += " FAIL" + (f" (loop exit: {exit_reason})" if exit_reason else "")
162
+ checks = record.get("failed_checks")
163
+ if checks:
164
+ return f"{head}: {', '.join(_render_check(c) for c in checks)}"
165
+ if checks is not None and not errored:
166
+ return f"{head}: no failing check recorded"
167
+ return head
168
+
169
+
170
+ def failing_runs_note(failed_runs: Sequence[Mapping[str, Any]], runs_total: int) -> str:
171
+ """Every failing run, joined with ``; ``. Empty when no run failed.
172
+
173
+ Past ``_MAX_FAILING_RUNS_CHARS`` the runs left are counted instead of rendered. The first
174
+ run is always shown, cut to that length if it alone is longer.
175
+ """
176
+ shown: list[str] = []
177
+ length = 0
178
+ for index, record in enumerate(failed_runs):
179
+ text = _render_run(record, runs_total)
180
+ if shown and length + len("; ") + len(text) > _MAX_FAILING_RUNS_CHARS:
181
+ more = len(failed_runs) - index
182
+ shown.append(f"{more} more failing run(s) in failed_runs")
183
+ break
184
+ if not shown and len(text) > _MAX_FAILING_RUNS_CHARS:
185
+ text = text[: _MAX_FAILING_RUNS_CHARS - 3] + "..."
186
+ shown.append(text)
187
+ length += len(text) + (len("; ") if len(shown) > 1 else 0)
188
+ return "; ".join(shown)
189
+
190
+
191
+ def failure_head(gate_note: str, failed_runs: Sequence[Mapping[str, Any]], runs_total: int) -> str:
192
+ """``gate_note`` followed by the failing runs, ready to start a kind's assertion message.
193
+
194
+ Returns ``gate_note`` unchanged when there is no failing run to list, which is the whole
195
+ head of a kind that builds no ``failed_runs``.
196
+ """
197
+ note = failing_runs_note(failed_runs, runs_total)
198
+ return f"{gate_note} Failing runs: {note}." if note else gate_note
@@ -0,0 +1,50 @@
1
+ # (C) 2026 GoodData Corporation
2
+ """Attribute filter selections and filter values, shared by the dashboard and document graders.
3
+
4
+ Both read a selection with ``selection_of``. Only the document grader compares two selections with
5
+ ``same_selection``, ignoring the order of their values; the dashboard grader compares them as read.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+
11
+ def selection_of(attribute_filter: dict) -> tuple[str, list] | None:
12
+ """The elements an attribute filter restricts to, or ``None`` when it restricts nothing.
13
+
14
+ An unrestricted filter is spelled as the absence of a selection, and an empty list means
15
+ the same thing, so both read as "all".
16
+ """
17
+ state = attribute_filter.get("state") or {}
18
+ for kind in ("include", "exclude"):
19
+ values = state.get(kind)
20
+ if values:
21
+ return kind, list(values)
22
+ return None
23
+
24
+
25
+ def describe_selection(selection: tuple[str, list] | None) -> str:
26
+ return "all" if selection is None else f"{selection[0]} {selection[1]!r}"
27
+
28
+
29
+ def same_selection(actual: tuple[str, list] | None, expected: tuple[str, list] | None) -> bool:
30
+ """Whether two selections restrict to the same elements: an include or exclude list is a set, not a sequence."""
31
+ if actual is None or expected is None:
32
+ return actual is None and expected is None
33
+ return actual[0] == expected[0] and same_unordered_values(expected[1], actual[1])
34
+
35
+
36
+ def same_unordered_values(want: list, got: list) -> bool:
37
+ """One-to-one match in any order, with each pair of the same type.
38
+
39
+ Not sorted: AAC allows `null` among the values, and Python cannot order it with strings.
40
+ Not stringified: `1` and `"1"` are different values.
41
+ """
42
+ remaining = list(got)
43
+ for expected in want:
44
+ index = next(
45
+ (i for i, actual in enumerate(remaining) if type(actual) is type(expected) and actual == expected), None
46
+ )
47
+ if index is None:
48
+ return False
49
+ del remaining[index]
50
+ return not remaining
@@ -29,20 +29,27 @@ def gate_label(gate: str | None, k: int) -> str:
29
29
  return f"pass^{k}" if normalize_gate(gate) == "power" else f"pass@{k}"
30
30
 
31
31
 
32
- def gate_failure_note(gate: str | None, runs_passed: int, runs_total: int, runs_ungraded: int = 0) -> str:
32
+ def gate_failure_note(
33
+ gate: str | None, runs_passed: int, runs_total: int, runs_ungraded: int = 0, *, runs_errored: int = 0
34
+ ) -> str:
33
35
  """Gate and how many runs met it, for the assertion message.
34
36
 
35
37
  Needed because the message body describes the BEST run, which under pass^K can be a run
36
38
  that passed — so the reported detail on its own looks like a pass.
37
39
 
38
40
  An ungraded run counts in runs_total but can never count in runs_passed, so the remainder
39
- is not evidence of instability — saying so would blame the agent for a judge outage.
41
+ is not evidence of instability — saying so would blame the agent for a judge outage. A run
42
+ the harness failed (``runs_errored``, labelled ERROR in ``core/outcome.py``) is no evidence
43
+ of instability either, so it is named rather than called one. A pass^K item with a passing
44
+ run and a run the agent itself failed is unstable all the same, whatever else errored.
40
45
  """
41
46
  label = gate_label(gate, runs_total)
42
47
  note = f"Gate {label} failed: {runs_passed}/{runs_total} runs passed"
43
48
  if runs_ungraded:
44
49
  return f"{note}, {runs_ungraded} ungraded."
45
- if normalize_gate(gate) == "power" and runs_passed:
50
+ if runs_errored:
51
+ note = f"{note}, {runs_errored} harness error(s)"
52
+ if normalize_gate(gate) == "power" and runs_passed and runs_passed + runs_errored < runs_total:
46
53
  return f"{note} — unstable, not a clean failure."
47
54
  return f"{note}."
48
55
 
@@ -11,7 +11,7 @@ import threading
11
11
  import time
12
12
  from collections.abc import Iterator
13
13
  from contextlib import contextmanager
14
- from datetime import datetime, timedelta, timezone
14
+ from datetime import UTC, datetime, timedelta
15
15
  from typing import TYPE_CHECKING, Any
16
16
 
17
17
  from gooddata_eval.core.agentic._trace_linker import link_cancel_event, linking_is_inline, warn_from_worker
@@ -268,7 +268,7 @@ def find_traces_per_conversation(
268
268
  return dict.fromkeys(conversation_ids)
269
269
 
270
270
  by_conv: dict[str, Any] = dict.fromkeys(conversation_ids)
271
- window_end = window_end or datetime.now(timezone.utc)
271
+ window_end = window_end or datetime.now(UTC)
272
272
  pad = timedelta(seconds=_WINDOW_PADDING_SEC)
273
273
 
274
274
  # One budget for the whole item. Per conversation it would multiply by --runs, and the
@@ -322,7 +322,7 @@ def _span_window(trace: Any, window: tuple[datetime, datetime] | None) -> tuple[
322
322
  return start, end
323
323
  if window is not None:
324
324
  return window
325
- now = datetime.now(timezone.utc)
325
+ now = datetime.now(UTC)
326
326
  return now, now
327
327
 
328
328