Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitleaksignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
08b38a1d499d894b009a761a5db04b818ef1af70:tests/reporting/test_tier3_failure_reasons.py:curl-auth-user:581
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ All notable changes to SkillEvaluator are documented in this file.

### Changed

- Write Tier 3 accuracy deductions as plain-language reasons, identify findings
without trajectory evidence, and include expected/observed text only when
both values are recorded.

- Tier 3 LLM suggestions and insight recommendations now keep only evidence
references the run recorded (cited references that don't resolve are
dropped rather than shown as evidence) and keep one copy of a repeated
Expand All @@ -121,15 +125,13 @@ All notable changes to SkillEvaluator are documented in this file.
pass threshold, are dropped. Both prompts ask for distinct actions and
label untested causes, such as switching to a different model, as
hypotheses or experiments.

- Tier 3 reports missing skill runtime dependencies as environment problems,
with declaration and custom Dockerfile guidance. Unrecovered environment
failures leave the trial UNSCORED instead of reducing the skill's score;
recovered environment failures carry no deduction.

- Document per-arm Tier 3 dimension applicability and test how N/A baseline
metrics are handled in Overall scores and Skill Lift comparisons.

- Run GitLab Tier 2 without Docker-in-Docker while keeping TLS-protected Docker
for Tier 3. Both native tiers retain shared caller timeout and runner-tag
overrides, advisory outcomes, and aggregate artifacts; local mode still
Expand Down
5 changes: 4 additions & 1 deletion docs/reports.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ lift data that `view` and `compare` read back later.
evaluation framework that runs those Tier 3 trials. SkillEvaluator collects its
job artifacts into the results tree described on this page.

Tier 3 findings describe failed accuracy criteria in plain language and mark
when trajectory evidence is unavailable. Expected and observed text appears
only when both values were recorded in the result.

Tier 3 results include a `dataset_sufficiency` policy assessment in `result.json`.
The status is sufficient only when coverage, pass-rate reliability, and paired
lift-comparison requirements are met; otherwise it is provisional and does not
change the evaluation verdict.

## Retained three-tier CI evidence

The opt-in all-tier workflows retain one aggregate artifact for 14 days. GitHub
Expand Down
63 changes: 50 additions & 13 deletions src/skillevaluator/evaluation/tier3_findings.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from __future__ import annotations

import re
from collections.abc import Iterator
from collections.abc import Collection, Iterator
from itertools import islice
from typing import Any

Expand Down Expand Up @@ -160,14 +160,21 @@ def _failed_check_reason(key: str, value: dict[str, Any]) -> str:
if isinstance(text, str) and text.strip():
return text
label = key.replace("_", " ").replace("-", " ").strip()
if not label:
return "Check failed"
return f"{label[0].upper()}{label[1:]} failed"
return f"Check `{label}` did not pass; no reason was recorded"


def _reason_candidates(detail: dict[str, Any], *, include_results: bool) -> Iterator[str]:
def _reason_candidates(
detail: dict[str, Any],
*,
include_results: bool,
metric: str | None,
reward: dict[str, Any] | None,
) -> Iterator[str]:
"""Yield candidate reason strings across the known grader detail shapes."""
from skillevaluator.tier3.harbor.report import _applicable_accuracy_criteria
from skillevaluator.tier3.harbor.report import (
_applicable_accuracy_criteria,
_expected_observed_suffix,
)

for field in ("reason", "message"):
if isinstance(detail.get(field), str):
Expand All @@ -193,12 +200,15 @@ def _reason_candidates(detail: dict[str, Any], *, include_results: bool) -> Iter
# excluded from the score (such as skill identification when no skill is
# expected) did not fail it.
criteria = _applicable_accuracy_criteria(detail)
failed_criteria = sorted(
str(name)[:128] for name, passed in islice(criteria.items(), _MAX_DETAIL_ITEMS) if passed is False
)
failed_criteria = [str(name) for name, passed in islice(criteria.items(), _MAX_DETAIL_ITEMS) if passed is False]
if failed_criteria:
yield f"Failed criteria: {', '.join(failed_criteria)}"

if metric in ("accuracy", "goal_accuracy"):
suffix = _expected_observed_suffix(detail, reward)
if suffix:
yield suffix

# Other graders nest one dict per named check.
for key, value in islice(detail.items(), _MAX_DETAIL_ITEMS):
if key not in _STRUCTURED_DETAIL_KEYS and _failed(value):
Expand All @@ -210,7 +220,14 @@ def _reason_candidates(detail: dict[str, Any], *, include_results: bool) -> Iter
yield detail["attribution_explanation"]


def failure_reason(detail: object, *, include_results: bool = True) -> str:
def failure_reason(
detail: object,
*,
include_results: bool = True,
metric: str | None = None,
reward: dict[str, Any] | None = None,
omit: Collection[str] = (),
) -> str:
"""Return one short, deduplicated, redacted reason for a failing metric.

``include_results=False`` leaves out failing behavior results, for evaluator
Expand All @@ -219,13 +236,26 @@ def failure_reason(detail: object, *, include_results: bool = True) -> str:
if not isinstance(detail, dict):
return ""
parts: list[str] = []
omitted_texts: set[str] = set()
for text in omit:
cleaned = sanitize_grader_text(text)
if cleaned:
omitted_texts.add(cleaned)
omitted_texts.update(part for part in cleaned.split("; ") if part)
# Only non-blank candidates count toward the cap, so entries without text
# cannot crowd out the criteria, checks, or attribution that follow them.
candidates = (
candidate for candidate in _reason_candidates(detail, include_results=include_results) if candidate.strip()
cleaned
for candidate in _reason_candidates(
detail,
include_results=include_results,
metric=metric,
reward=reward,
)
if (cleaned := sanitize_grader_text(candidate))
and not any(cleaned == omitted or cleaned in omitted for omitted in omitted_texts)
)
for candidate in islice(candidates, _MAX_REASON_CANDIDATES):
cleaned = sanitize_grader_text(candidate)
for cleaned in islice(candidates, _MAX_REASON_CANDIDATES):
if cleaned and cleaned not in parts:
parts.append(cleaned)
if len(parts) >= _MAX_REASON_PARTS:
Expand All @@ -235,6 +265,13 @@ def failure_reason(detail: object, *, include_results: bool = True) -> str:
return sanitize_grader_text("; ".join(parts)[: 4 * MAX_REASON_CHARS], MAX_REASON_CHARS)


def evidence_unavailable_reason(reward: dict[str, Any]) -> str:
failure = sanitize_grader_text(reward.get("trajectory_detail") or reward.get("error"), MAX_REASON_CHARS)
if failure:
return f"Trajectory evidence could not be loaded: {failure}"
return "No trajectory evidence was recorded for this metric"


def failure_excerpt(detail: object) -> str:
"""Return a short, redacted excerpt of the artifact that triggered the failure."""
if not isinstance(detail, dict):
Expand Down
31 changes: 21 additions & 10 deletions src/skillevaluator/evaluation/tier3_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -1417,9 +1417,7 @@ def refresh_signal() -> None:
container[key] = value
refresh_signal()
omitted_reasons = (
strip_failure_reason_text(payload)
if _serialized_payload_size(payload) > _MAX_EMBEDDED_REPORT_BYTES
else 0
strip_failure_reason_text(payload) if _serialized_payload_size(payload) > _MAX_EMBEDDED_REPORT_BYTES else 0
)
report_budget.omit("failure_reasons", omitted_reasons)
refresh_signal()
Expand Down Expand Up @@ -2583,6 +2581,7 @@ def _metric_evidence(
report_budget: _ReportBudget,
sampling: dict[str, Any] | None = None,
) -> list[dict[str, Any]]:
from skillevaluator.tier3.eval_core.atif_helpers import _METRIC_EVIDENCE_REF_METRICS
from skillevaluator.tier3.harbor.metrics import DEFAULT_METRICS, metric_set_for_reward

if report_budget.evidence_remaining <= 0:
Expand Down Expand Up @@ -2614,7 +2613,8 @@ def _metric_evidence(
score_failed = raw_score is not None and raw_score < TRIAL_PASS_THRESHOLD

notes: list[str] = []
reason = sanitize_grader_text(detail.get("reason"))
raw_grader_reason = detail.get("reason")
reason = sanitize_grader_text(raw_grader_reason)
if reason:
notes.append(reason[:512])

Expand Down Expand Up @@ -2643,6 +2643,10 @@ def _metric_evidence(
"checks": checks,
"evidence_refs": _compact_evidence_refs(detail.get("evidence_refs")),
}
if score_failed and metric in _METRIC_EVIDENCE_REF_METRICS and not entry["evidence_refs"]:
from skillevaluator.evaluation.tier3_findings import evidence_unavailable_reason

entry["evidence_unavailable_reason"] = evidence_unavailable_reason(reward)
# The built reason and excerpt are not part of the fingerprint: attempts
# of one case often quote different commands under the same grader
# reason, and they still collapse into one entry with ``occurrences``.
Expand All @@ -2664,11 +2668,18 @@ def _metric_evidence(
output_truncated = True
continue
if score_failed:
# Graders that record only a message, findings, or failed criteria
# still explain a failing score. The built reason stays separate from
# the grader's own notes so size limits can drop it first, and leaves
# out failing results, which the card already lists as ``failures``.
if not notes and (fallback_reason := failure_reason(detail, include_results=False)):
# Graders that record only findings or failed criteria still explain
# a failing score. Notes already show the grader's own reason, so the
# separate built reason omits that text and leaves out failing
# results, which the card already lists as ``failures``.
omitted_reasons = (raw_grader_reason, *notes) if isinstance(raw_grader_reason, str) else tuple(notes)
if fallback_reason := failure_reason(
detail,
include_results=False,
metric=metric,
reward=reward,
omit=omitted_reasons,
):
entry["reason"] = fallback_reason
if excerpt := failure_excerpt(detail):
entry["excerpt"] = excerpt
Expand Down Expand Up @@ -3177,7 +3188,7 @@ def _trial_score_reasons(
continue
if lowest is not None and row_score >= lowest[0]:
continue
reason = failure_reason(_metric_detail(row, metric))
reason = failure_reason(_metric_detail(row, metric), metric=metric, reward=row)
if reason:
lowest = (row_score, reason)
if lowest is not None:
Expand Down
23 changes: 21 additions & 2 deletions src/skillevaluator/reporting/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,8 +800,13 @@ def _sanitize_tier3_pass_at_k(value: object) -> dict[str, Any]:
return pass_at_k


def _sanitize_tier3_evaluator_card(value: dict[str, Any]) -> dict[str, Any] | None:
def _sanitize_tier3_evaluator_card(
value: dict[str, Any],
*,
include_evidence_unavailable_default: bool = False,
) -> dict[str, Any] | None:
from skillevaluator.evaluation.tier3_findings import FAILURE_REASON_EVIDENCE_KEYS
from skillevaluator.tier3.eval_core.atif_helpers import _METRIC_EVIDENCE_REF_METRICS

card = dict(value)
card["with_skill"] = _finite_number(card.get("with_skill"), minimum=0.0, maximum=1.0)
Expand All @@ -824,6 +829,20 @@ def _sanitize_tier3_evaluator_card(value: dict[str, Any]) -> dict[str, Any] | No
for key in FAILURE_REASON_EVIDENCE_KEYS:
if not (isinstance(entry.get(key), str) and entry[key]):
entry.pop(key, None)
if (
include_evidence_unavailable_default
and card.get("id") in _METRIC_EVIDENCE_REF_METRICS
and entry["score"] is not None
and entry["score"] < 0.8
and not entry["evidence_refs"]
):
unavailable_reason = entry.get("evidence_unavailable_reason")
if isinstance(unavailable_reason, str) and unavailable_reason:
entry["evidence_unavailable_reason"] = unavailable_reason[:512]
else:
entry["evidence_unavailable_reason"] = "No trajectory evidence was recorded for this metric"
else:
entry.pop("evidence_unavailable_reason", None)
evidence.append(entry)
card["evidence"] = evidence
sampling = card.get("evidence_sampling") if isinstance(card.get("evidence_sampling"), dict) else {}
Expand Down Expand Up @@ -862,7 +881,7 @@ def _sanitize_tier3_agent(value: dict[str, Any]) -> dict[str, Any]:
agent["evaluator_cards"] = [
card
for item in _dict_list(agent.get("evaluator_cards"))
if (card := _sanitize_tier3_evaluator_card(item)) is not None
if (card := _sanitize_tier3_evaluator_card(item, include_evidence_unavailable_default=True)) is not None
]
agent["findings"] = [_sanitize_tier3_dimension(item) for item in _dict_list(agent.get("findings"))]
agent["pass_at_k"] = _sanitize_tier3_pass_at_k(agent.get("pass_at_k"))
Expand Down
15 changes: 9 additions & 6 deletions src/skillevaluator/reporting/templates/report.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -3492,25 +3492,27 @@
{% set eid = ev.entry_id or 'trial' %}
{% if eid not in dedup_map %}
{% set _ = dedup_order.append(eid) %}
{% set _ = dedup_map.update({eid: {'count': 0, 'sum': 0.0, 'with_score': 0, 'notes': [], 'failures': [], 'checks': [], 'evidence_refs': [], 'excerpt': none, 'reason_score': none}}) %}
{% set _ = dedup_map.update({eid: {'count': 0, 'sum': 0.0, 'with_score': 0, 'notes': [], 'failures': [], 'checks': [], 'evidence_refs': [], 'evidence_unavailable_reason': none, 'excerpt': none, 'reason': none, 'reason_score': none}}) %}
{% endif %}
{% set entry = dedup_map[eid] %}
{% set ev_occurrences = ev.occurrences or 1 %}
{% set _ = entry.update({'count': entry.count + ev_occurrences}) %}
{% if ev.score is not none %}
{% set _ = entry.update({'sum': entry.sum + (ev.score * ev_occurrences), 'with_score': entry.with_score + ev_occurrences}) %}
{% endif %}
{# A built reason stands in for grader notes when the grader recorded none. #}
{% set ev_notes = ev.notes or ([ev.reason] if ev.reason else []) %}
{% if (ev_notes or ev.failures or ev.excerpt) and ev.score is not none and (entry.reason_score is none or ev.score < entry.reason_score) %}
{% set _ = entry.update({'notes': ev_notes, 'failures': ev.failures or [], 'excerpt': ev.excerpt or none, 'reason_score': ev.score}) %}
{# Keep built reasons separate from the bounded grader notes. #}
{% set ev_notes = ev.notes or [] %}
{% if (ev_notes or ev.reason or ev.failures or ev.excerpt) and ev.score is not none and (entry.reason_score is none or ev.score < entry.reason_score) %}
{% set _ = entry.update({'notes': ev_notes, 'reason': ev.reason or none, 'failures': ev.failures or [], 'excerpt': ev.excerpt or none, 'reason_score': ev.score}) %}
{% elif entry.reason_score is none %}
{% if ev_notes and not entry.notes %}{% set _ = entry.update({'notes': ev_notes}) %}{% endif %}
{% if ev.reason and not entry.reason %}{% set _ = entry.update({'reason': ev.reason}) %}{% endif %}
{% if ev.failures and not entry.failures %}{% set _ = entry.update({'failures': ev.failures}) %}{% endif %}
{% if ev.excerpt and not entry.excerpt %}{% set _ = entry.update({'excerpt': ev.excerpt}) %}{% endif %}
{% endif %}
{% if ev.checks and not entry.checks %}{% set _ = entry.update({'checks': ev.checks}) %}{% endif %}
{% if ev.evidence_refs and not entry.evidence_refs %}{% set _ = entry.update({'evidence_refs': ev.evidence_refs}) %}{% endif %}
{% if ev.evidence_unavailable_reason and not entry.evidence_unavailable_reason %}{% set _ = entry.update({'evidence_unavailable_reason': ev.evidence_unavailable_reason}) %}{% endif %}
{% endfor %}
{% set evidence_totals = namespace(trials=0) %}
{% for ev in card.evidence %}
Expand All @@ -3533,14 +3535,15 @@
{% if ev.notes %}{{ (ev.notes[:2] | join('; '))[:160] }}{% endif %}
{% if ev.failures %}<span style="color:var(--danger-color);">{{ (ev.failures[:2] | join('; '))[:120] }}</span>{% endif %}
{% if not ev.notes and not ev.failures and ev.checks %}{{ (ev.checks | length) }} checks{% endif %}
{% if ev.evidence_refs %}<span class="t3-ev-refs">Evidence: {{ ev.evidence_refs[:3] | join('; ') }}</span>{% endif %}
{% if ev.evidence_refs %}<span class="t3-ev-refs">Evidence: {{ ev.evidence_refs[:3] | join('; ') }}</span>{% elif ev.evidence_unavailable_reason %}<span class="t3-ev-refs">Evidence unavailable — {{ ev.evidence_unavailable_reason }}</span>{% endif %}
</span>
<span class="t3-ev-count">×{{ ev.count }}</span>
{% if avg_score is not none %}
<span class="t3-bar-value" style="color:{{ ev_color }};">{{ "%.2f" | format(avg_score) }}</span>
{% else %}
<span class="t3-bar-value" style="color:var(--text-secondary);">N/A</span>
{% endif %}
{% if ev.reason %}<div class="t3-ev-detail t3-ev-reason">{{ ev.reason }}</div>{% endif %}
{% if ev.excerpt %}<div class="t3-ev-detail"><code class="t3-ev-excerpt">{{ ev.excerpt }}</code></div>{% endif %}
</li>
{% endfor %}
Expand Down
7 changes: 7 additions & 0 deletions src/skillevaluator/tier3/eval_core/llm_judge.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,13 @@ def invoke(call_prompt: str) -> tuple[Any, str | None, dict[str, Any], str | Non
"if the response gives an answer and false if it gives none.",
),
)
_ACCURACY_DEDUCTION_SENTENCES = {
"ACTION_CORRECT": "The agent did not take the action the expected answer calls for",
"FACTUALLY_ACCURATE": "The answer's facts do not match the expected answer",
"TASK_ADDRESSED": "The answer does not address what the user asked",
"ACTIONABLE": "The answer does not give the user a result they can act on",
"FORMAT_FOLLOWED": "The answer does not follow the output format the question requires",
}
_ACCURACY_CRITERIA_KEYS = frozenset(key for key, _question in _ACCURACY_CRITERIA)

ACCURACY_JSON_SCHEMA: dict[str, Any] = {
Expand Down
Loading
Loading