Skip to content

Multi-tier framework for evaluating AI agent skills and plugins with quality gates, security scanning, harness compatibility checks, semantic overlap detection, synthetic evaluation dataset generation, and live agent evaluation that measures how skills affect agent behavior. Ships reusable CI templates that bring every check to any repository.

Fix judge-aware lift review edge cases

YMuskrat8cc9dcd9d96c
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1ba799b8..537cfdb0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -147,7 +147,9 @@ All notable changes to SkillEvaluator are documented in this file.
- Tier 3 reports preserve judge-model exclusions when calculating dimension and
overall lift. Native multi-step results also retain the judge provenance needed
for those comparisons, so fallback judges cannot turn a regression into an
- apparent improvement.
+ apparent improvement. Judge-free cases retain valid lift, bounded report loads
+ use the collector's recorded comparisons, and FINAL-strategy trials use only
+ the final step's judges. The CLI displays unavailable comparisons as `n/a`.
- Tier 3 reports an inconclusive result when every observed positive with-skill
trial has zero activation, and omits skill-lift comparisons for that agent.
Activation counts are reported separately; negative controls and missing
diff --git a/src/skillevaluator/evaluation/tier3_report.py b/src/skillevaluator/evaluation/tier3_report.py
index 711bee93..d5206b1a 100644
--- a/src/skillevaluator/evaluation/tier3_report.py
+++ b/src/skillevaluator/evaluation/tier3_report.py
@@ -1561,18 +1561,18 @@ def _judge_aware_lift(
without_scores: dict[str, Any],
score_policy: str,
) -> dict[str, Any] | None:
- """Rebuild judge exclusions from complete trial evidence, never cached deltas."""
+ """Rebuild judge exclusions, falling back to recorded lift for incomplete loads."""
from skillevaluator.tier3.harbor.collector import (
_LLM_JUDGE_METRICS,
_compute_lift,
_logical_attempt_rewards,
_reward_judge_models,
)
- from skillevaluator.tier3.harbor.metrics import metric_value
from skillevaluator.tier3.harbor.report_data import logical_trial_reward_groups
recorded = info.get("lift")
- recorded_mixed = recorded.get("judge_mixed_cases") if isinstance(recorded, dict) else None
+ recorded = recorded if isinstance(recorded, dict) else {}
+ recorded_mixed = recorded.get("judge_mixed_cases")
mixed = (
{
metric: count
@@ -1582,6 +1582,7 @@ def _judge_aware_lift(
if isinstance(recorded_mixed, dict)
else {}
)
+ recorded_counts = mixed.copy()
if not mixed and not any(
_reward_judge_models(row, metric)
for rows in (info.get("rewards"), info.get("rewards_baseline"))
@@ -1624,19 +1625,18 @@ def _judge_aware_lift(
mixed[metric] = max(count, mixed.get(metric, 0))
if not mixed:
return None
- unsupported_exclusions.update(
- metric
- for metric in mixed
- if any(
- metric_value(row, metric) is not None and not _reward_judge_models(row, metric)
- for rows in conditions
- for row in rows
- )
- )
if not complete:
- # A bounded or incomplete reward load cannot reconstruct the retained
- # cohort. Preserve unavailable instead of undoing the exclusion.
- return {"judge_mixed_cases": mixed}
+ # The collector already excluded mixed judges from the full cohort;
+ # a partial load must not replace its recorded comparison.
+ covered = {metric for metric, count in mixed.items() if recorded_counts.get(metric, 0) >= count}
+ if covered == mixed.keys():
+ covered.add("overall")
+ for metric in (*mixed, "overall"):
+ rebuilt.pop(metric, None)
+ if all(clean_scores) and metric in covered and metric in recorded:
+ rebuilt[metric] = recorded[metric]
+ rebuilt["judge_mixed_cases"] = mixed
+ return rebuilt
rebuilt["judge_mixed_cases"] = mixed
for metric in unsupported_exclusions:
rebuilt.pop(metric, None)
diff --git a/src/skillevaluator/reporting/cli.py b/src/skillevaluator/reporting/cli.py
index 89de3fea..af2c1fd0 100644
--- a/src/skillevaluator/reporting/cli.py
+++ b/src/skillevaluator/reporting/cli.py
@@ -381,16 +381,16 @@ class CLIReporter(ReporterBase):
ws = scores.get("with_skill", 0.0)
bl = scores.get("baseline", 0.0)
lift = scores.get("lift", 0.0)
- lc = (
- "green"
- if lift is not None and lift > 0.01
- else ("red" if lift is not None and lift < -0.01 else "dim")
- )
+ if lift is None:
+ lift_text = "n/a"
+ else:
+ lc = "green" if lift > 0.01 else ("red" if lift < -0.01 else "dim")
+ lift_text = f"[{lc}]{lift:+.2f}[/{lc}]"
table.add_row(
escape_markup(str(name).replace("_", " ").title()),
f"{ws:.2f}",
- f"{bl:.2f}",
- f"[{lc}]{lift:+.2f}[/{lc}]" if lift is not None else "N/A",
+ f"{bl:.2f}" if bl is not None else "n/a",
+ lift_text,
)
console.print(table)
diff --git a/src/skillevaluator/tier3/harbor/collector.py b/src/skillevaluator/tier3/harbor/collector.py
index 42ec7ebd..71019cdb 100644
--- a/src/skillevaluator/tier3/harbor/collector.py
+++ b/src/skillevaluator/tier3/harbor/collector.py
@@ -3140,8 +3140,10 @@ def _standard_aggregate_matches_harbor_strategy(
root_rewards: dict[str, Any],
step_results: list[dict[str, Any]],
root_metrics: tuple[str, ...],
+ *,
+ strategy: str | None = None,
) -> bool:
- """Recognize Harbor's FINAL or missing-as-zero MEAN aggregate semantics."""
+ """Match FINAL, missing-as-zero MEAN, or either when the strategy is unknown."""
root_values = {metric: metric_value(root_rewards, metric) for metric in root_metrics}
if any(value is None for value in root_values.values()):
return False
@@ -3152,12 +3154,18 @@ def _standard_aggregate_matches_harbor_strategy(
candidate = final_verifier.get("rewards") if isinstance(final_verifier, dict) else None
if isinstance(candidate, dict):
final_rewards = candidate
- if final_rewards is not None and all(
- (value := metric_value(final_rewards, metric)) is not None
- and math.isclose(value, root_values[metric], rel_tol=1e-9, abs_tol=1e-9)
- for metric in root_metrics
+ if (
+ strategy != "mean"
+ and final_rewards is not None
+ and all(
+ (value := metric_value(final_rewards, metric)) is not None
+ and math.isclose(value, root_values[metric], rel_tol=1e-9, abs_tol=1e-9)
+ for metric in root_metrics
+ )
):
return True
+ if strategy == "final":
+ return False
verifier_rewards: list[dict[str, Any]] = []
for step in step_results:
@@ -4952,13 +4960,50 @@ def _pass_summary(
_LLM_JUDGE_METRICS = ("accuracy", "goal_accuracy", "behavior_check")
+def _harbor_multi_step_reward_strategy(result: dict[str, Any]) -> str | None:
+ """Read the task's strategy when its staged configuration is still available."""
+ config = result.get("config")
+ task = config.get("task") if isinstance(config, dict) else None
+ paths = {
+ value["path"].strip()
+ for value in (result.get("task_id"), task)
+ if isinstance(value, dict) and isinstance(value.get("path"), str) and value["path"].strip()
+ }
+ if len(paths) != 1:
+ return None
+ task_toml = Path(paths.pop()) / "task.toml"
+ if task_toml.is_symlink() or not task_toml.is_file():
+ return None
+ raw_toml = _read_bounded_text(task_toml)
+ if raw_toml is None:
+ return None
+ try:
+ import tomllib
+
+ strategy = tomllib.loads(raw_toml).get("multi_step_reward_strategy", "mean")
+ except (ValueError, TypeError):
+ return None
+ return strategy if isinstance(strategy, str) and strategy in {"final", "mean"} else None
+
+
def _merge_constituent_judge_models(data: dict[str, Any], result: dict[str, Any], trial_root: Path) -> None:
- """Keep step judge provenance without replacing Harbor's aggregate scores."""
+ """Keep the scoring steps' judges without replacing Harbor's aggregate scores."""
names = _valid_step_result_names(result.get("step_results"))
if names is None:
return
+ steps = result["step_results"]
+ strategy = _harbor_multi_step_reward_strategy(result)
+ metrics = _standard_reward_metrics(data)
+ # Older artifacts can omit task configuration. Infer FINAL only when the
+ # authoritative scores distinguish it from MEAN; retain all judges otherwise.
+ if strategy is None and metrics:
+ matches = _standard_aggregate_matches_harbor_strategy
+ if matches(data, steps, metrics, strategy="final") and not matches(data, steps, metrics, strategy="mean"):
+ strategy = "final"
+ if strategy == "final":
+ names, steps = names[-1:], steps[-1:]
models: dict[str, set[str]] = {metric: set() for metric in _LLM_JUDGE_METRICS}
- for name, step in zip(names, result["step_results"], strict=True):
+ for name, step in zip(names, steps, strict=True):
verifier = step.get("verifier_result")
embedded = verifier.get("rewards") if isinstance(verifier, dict) else None
row = dict(embedded) if isinstance(embedded, dict) else {}
diff --git a/tests/reporting/test_reporters.py b/tests/reporting/test_reporters.py
index e7058e12..8f3635ec 100644
--- a/tests/reporting/test_reporters.py
+++ b/tests/reporting/test_reporters.py
@@ -214,6 +214,38 @@ class TestCLIReporter:
assert "Required validations passed" in output
assert "live evaluation skipped" in output
+ @pytest.mark.parametrize(
+ ("baseline", "lift", "expected_baseline", "expected_lift"),
+ [
+ (0.6, None, "0.60", "n/a"),
+ (None, None, "n/a", "n/a"),
+ (0.6, 0.2, "0.60", "+0.20"),
+ (0.9, -0.1, "0.90", "-0.10"),
+ ],
+ )
+ def test_render_agent_eval_with_unavailable_comparison(
+ self,
+ baseline: float | None,
+ lift: float | None,
+ expected_baseline: str,
+ expected_lift: str,
+ ) -> None:
+ result = ValidationResult(validator_name="AGENT_EVAL", validator_description="Live evaluation")
+ result.metadata["agent_eval"] = {
+ "evaluators": {"goal_accuracy": {"with_skill": 0.8, "baseline": baseline, "lift": lift}},
+ }
+
+ output = CLIReporter().render(result)
+ plain_output = re.sub(r"\x1b\[[0-9;]*m", "", output)
+ row = next(line for line in plain_output.splitlines() if "Goal Accuracy" in line)
+
+ assert [cell.strip() for cell in row.split("│")[1:-1]] == [
+ "Goal Accuracy",
+ "0.80",
+ expected_baseline,
+ expected_lift,
+ ]
+
def test_render_failure_escapes_markup_in_finding_fields(self) -> None:
"""Dynamic finding text should not be parsed as Rich markup."""
result = ValidationResult(
diff --git a/tests/test_harbor_collector_judge_strategy.py b/tests/test_harbor_collector_judge_strategy.py
new file mode 100644
index 00000000..33ad12e4
--- /dev/null
+++ b/tests/test_harbor_collector_judge_strategy.py
@@ -0,0 +1,117 @@
+# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0
+
+"""Native multi-step judge provenance follows Harbor's scoring strategy."""
+
+from __future__ import annotations
+
+import json
+from pathlib import Path
+
+import pytest
+
+from skillevaluator.evaluation.tier3_report import agent_eval_result_from_directory
+from skillevaluator.tier3.harbor.collector import collect_harbor_results
+from skillevaluator.tier3.harbor.metrics import DEFAULT_METRICS
+
+
+def _write_native_job(job: Path, *, strategy: str | None, equal_scores: bool, with_skill: bool) -> None:
+ trial_name = "case-1__trial"
+ trial = job / trial_name
+ final_accuracy = 1.0 if with_skill else 0.6
+ initial_accuracy = final_accuracy if equal_scores else 0.0 if with_skill else 0.4
+ steps = []
+ for name, accuracy in (("prepare", initial_accuracy), ("finish", final_accuracy)):
+ scores = {**dict.fromkeys(DEFAULT_METRICS, 0.5), "accuracy": accuracy}
+ verifier = trial / "steps" / name / "verifier"
+ verifier.mkdir(parents=True)
+ (verifier / "reward.json").write_text(json.dumps(scores), encoding="utf-8")
+ (verifier / "skill_evaluator_reward.json").write_text(
+ json.dumps(
+ {
+ **scores,
+ "details": {
+ "accuracy": {"judge_model_used": "fallback" if with_skill and name == "prepare" else "primary"}
+ },
+ }
+ ),
+ encoding="utf-8",
+ )
+ steps.append({"step_name": name, "verifier_result": {"rewards": scores}})
+ root_accuracy = (initial_accuracy + final_accuracy) / 2 if strategy == "mean" else final_accuracy
+ result = {
+ "trial_name": trial_name,
+ "task_name": "case-1",
+ "verifier_result": {"rewards": {**dict.fromkeys(DEFAULT_METRICS, 0.5), "accuracy": root_accuracy}},
+ "step_results": steps,
+ }
+ if strategy is not None:
+ task = job / "task" / "case-1"
+ task.mkdir(parents=True)
+ (task / "task.toml").write_text(f'multi_step_reward_strategy = "{strategy}"\n', encoding="utf-8")
+ result["config"] = {"task": {"path": str(task)}}
+ (trial / "result.json").write_text(json.dumps(result), encoding="utf-8")
+ (job / "result.json").write_text(
+ json.dumps(
+ {
+ "n_total_trials": 1,
+ "stats": {
+ "n_completed_trials": 1,
+ "n_errored_trials": 0,
+ "n_running_trials": 0,
+ "n_pending_trials": 0,
+ "n_cancelled_trials": 0,
+ "n_retries": 0,
+ "evals": {
+ "agent__model___tasks": {
+ "n_trials": 1,
+ "n_errors": 0,
+ "reward_stats": {"overall": {"0.5": [trial_name]}},
+ }
+ },
+ },
+ }
+ ),
+ encoding="utf-8",
+ )
+
+
+ ("strategy", "equal_scores", "final_only"),
+ [
+ ("final", False, True),
+ ("final", True, True),
+ (None, False, True),
+ ("mean", False, False),
+ ("mean", True, False),
+ (None, True, False),
+ ],
+ ids=("declared-final", "equal-final", "inferred-final", "declared-mean", "equal-mean", "ambiguous"),
+)
+def test_native_judge_provenance_uses_only_scoring_steps(
+ tmp_path: Path, strategy: str | None, equal_scores: bool, final_only: bool
+) -> None:
+ jobs = tmp_path / "jobs"
+ for arm in ("with", "without"):
+ _write_native_job(
+ jobs / f"demo-codex-{arm}", strategy=strategy, equal_scores=equal_scores, with_skill=arm == "with"
+ )
+ run = tmp_path / "run"
+ collected = collect_harbor_results("demo", ["codex"], run, jobs, expected_case_ids=["case-1"], expected_trials=1)
+
+ assert collected["execution_status"] == "succeeded"
+ reward_file = next((run / "codex" / "with-skill" / "trials").glob("*/reward.json"))
+ reward = json.loads(reward_file.read_text(encoding="utf-8"))
+ expected_judges = ["primary"] if final_only else ["fallback", "primary"]
+ assert reward["details"]["accuracy"]["judge_models"] == expected_judges
+ lift = collected["agents"]["codex"]["lift"]
+ if final_only:
+ assert lift["accuracy"]["delta"] == pytest.approx(0.4)
+ assert "judge_mixed_cases" not in lift
+ else:
+ assert lift["judge_mixed_cases"] == {"accuracy": 1}
+ assert "accuracy" not in lift
+ report = agent_eval_result_from_directory(tmp_path / "demo", run, use_llm_judge=False).metadata["agent_eval"]
+ agent = report["agents"]["codex"]
+ assert agent["evaluators"]["accuracy"]["lift"] == (pytest.approx(0.4) if final_only else None)
+ assert agent["lift"] == (pytest.approx(0.08) if final_only else None)
diff --git a/tests/test_judge_lift_integrity.py b/tests/test_judge_lift_integrity.py
index 38e51666..d1f901d2 100644
--- a/tests/test_judge_lift_integrity.py
+++ b/tests/test_judge_lift_integrity.py
@@ -20,14 +20,21 @@ def _write_json(path: Path, payload: dict) -> None:
path.write_text(json.dumps(payload), encoding="utf-8")
-def _write_job(job: Path, accuracies: list[float], judges: list[tuple[str, ...]], *, native: bool) -> None:
+def _write_job(
+ job: Path,
+ accuracies: list[float],
+ judges: list[tuple[str | None, ...]],
+ *,
+ native: bool,
+ judge_metric: str = "accuracy",
+) -> None:
trials = []
for index, (accuracy, step_judges) in enumerate(zip(accuracies, judges, strict=True), 1):
case = f"case-{index}"
trial_name = f"{case}__trial"
trials.append(trial_name)
trial = job / trial_name
- scores = {**dict.fromkeys(DEFAULT_METRICS, 0.5), "accuracy": accuracy}
+ scores = {**dict.fromkeys(DEFAULT_METRICS, 0.5), judge_metric: accuracy}
steps = []
for step_index, judge in enumerate(step_judges):
name = f"step-{step_index}"
@@ -37,7 +44,7 @@ def _write_job(job: Path, accuracies: list[float], judges: list[tuple[str, ...]]
"entry_id": case,
"metric_set": DEFAULT_METRIC_SET,
"score_policy": DEFAULT_SCORE_POLICY,
- "details": {"accuracy": {"score": accuracy, "judge_model_used": judge}},
+ "details": {judge_metric: {"score": accuracy, "judge_model_used": judge}} if judge else {},
}
_write_json(verifier / "reward.json", scores if native else rich)
if native:
@@ -76,17 +83,45 @@ def _write_job(job: Path, accuracies: list[float], judges: list[tuple[str, ...]]
)
-def _collect(root: Path, *, native: bool = False, all_mixed: bool = False) -> tuple[dict, Path]:
- judges_with = [("primary", "fallback"), ("primary", "fallback" if all_mixed else "primary")]
- judges_without = [("primary", "primary"), ("primary", "primary")]
+def _collect(
+ root: Path,
+ *,
+ native: bool = False,
+ all_mixed: bool = False,
+ judge_free: bool = False,
+ cases: int = 2,
+ judge_metric: str = "accuracy",
+) -> tuple[dict, Path]:
+ judges_with = [("primary", "fallback" if index == 0 or all_mixed else "primary") for index in range(cases)]
+ judges_without = [("primary", "primary")] * cases
+ accuracies_with = [1.0, *([0.0] * (cases - 1))]
+ accuracies_without = [0.0, *([0.4] * (cases - 1))]
+ if judge_free:
+ judges_with.append((None, None))
+ judges_without.append((None, None))
+ accuracies_with.append(1.0)
+ accuracies_without.append(1.0)
if not native:
judges_with = [(row[-1],) for row in judges_with]
judges_without = [(row[-1],) for row in judges_without]
- _write_job(root / "jobs" / "demo-codex-with", [1.0, 0.0], judges_with, native=native)
- _write_job(root / "jobs" / "demo-codex-without", [0.0, 0.4], judges_without, native=native)
+ _write_job(
+ root / "jobs" / "demo-codex-with", accuracies_with, judges_with, native=native, judge_metric=judge_metric
+ )
+ _write_job(
+ root / "jobs" / "demo-codex-without",
+ accuracies_without,
+ judges_without,
+ native=native,
+ judge_metric=judge_metric,
+ )
run = root / "run"
collected = collect_harbor_results(
- "demo", ["codex"], run, root / "jobs", expected_case_ids=["case-1", "case-2"], expected_trials=2
+ "demo",
+ ["codex"],
+ run,
+ root / "jobs",
+ expected_case_ids=[f"case-{index + 1}" for index in range(len(accuracies_with))],
+ expected_trials=len(accuracies_with),
)
assert collected["execution_status"] == "succeeded"
return collected, run
@@ -153,8 +188,8 @@ def test_all_mixed_judges_leave_metric_dimension_and_overall_unavailable(tmp_pat
@pytest.mark.parametrize(
"missing_evidence", ["reward", "judge_metadata", "partial_judge_metadata", "retained_judge_metadata"]
)
-def test_exclusions_cannot_be_reconstructed_from_incomplete_evidence(tmp_path: Path, missing_evidence: str) -> None:
- _, run = _collect(tmp_path, all_mixed=missing_evidence == "partial_judge_metadata")
+def test_report_handles_incomplete_judge_evidence(tmp_path: Path, missing_evidence: str) -> None:
+ collected, run = _collect(tmp_path, all_mixed=missing_evidence == "partial_judge_metadata")
reward = next((run / "codex" / "with-skill" / "trials").glob("*/reward.json"))
if missing_evidence == "reward":
reward.unlink()
@@ -169,6 +204,66 @@ def test_exclusions_cannot_be_reconstructed_from_incomplete_evidence(tmp_path: P
payload.pop("details", None)
_write_json(reward, payload)
report = _report(run)
+ lift = collected["agents"]["codex"]["lift"]
+ available = missing_evidence in {"reward", "retained_judge_metadata"}
+ assert report["overall_lift"] == (lift["overall"]["delta"] if available else None)
+ assert report["agents"]["codex"]["evaluators"]["accuracy"]["lift"] == (
+ lift["accuracy"]["delta"] if available else None
+ )
+
+
[email protected]("native", [False, True])
+def test_judge_free_cases_retain_collector_lift(tmp_path: Path, native: bool) -> None:
+ collected, run = _collect(tmp_path, native=native, judge_free=True)
+ lift = collected["agents"]["codex"]["lift"]
+ assert lift["judge_mixed_cases"] == {"accuracy": 1}
+ assert lift["accuracy"]["delta"] == -0.2
+ assert lift["overall"]["delta"] == -0.04
+ report = _report(run)
+ agent = report["agents"]["codex"]
+ assert report["overall_lift"] == agent["lift"] == lift["overall"]["delta"]
+ assert agent["evaluators"]["accuracy"]["lift"] == lift["accuracy"]["delta"]
+ correctness = next(dim for dim in agent["dimensions"] if dim["id"] == "correctness")
+ assert correctness["lift"] == lift["accuracy"]["delta"]
+
+
[email protected]("recorded_lift", [True, False])
+ ("metric", "dimension", "dimension_lift"),
+ [("accuracy", "correctness", -0.4), ("goal_accuracy", "effectiveness", -0.2)],
+)
+def test_capped_report_uses_recorded_lift_when_available(
+ tmp_path: Path, recorded_lift: bool, metric: str, dimension: str, dimension_lift: float
+) -> None:
+ collected, run = _collect(tmp_path, cases=513, judge_metric=metric)
+ lift = collected["agents"]["codex"]["lift"]
+ assert lift["judge_mixed_cases"] == {metric: 1}
+ assert lift[metric]["delta"] == -0.4
+ assert lift["overall"]["delta"] == dimension_lift / 5
+ if not recorded_lift:
+ (run / "codex" / "lift.json").unlink()
+ report = _report(run)
+ agent = report["agents"]["codex"]
+ assert len(agent["trials"]) == 512
+ assert report["overall_lift"] == agent["lift"] == (lift["overall"]["delta"] if recorded_lift else None)
+ assert agent["evaluators"][metric]["lift"] == (lift[metric]["delta"] if recorded_lift else None)
+ dimension = next(dim for dim in agent["dimensions"] if dim["id"] == dimension)
+ assert dimension["lift"] == (dimension_lift if recorded_lift else None)
+
+
[email protected]("recorded_mixed", [None, {"accuracy": 0}, {"accuracy": True}])
+def test_partial_load_does_not_trust_lift_without_recorded_exclusions(
+ tmp_path: Path, monkeypatch: pytest.MonkeyPatch, recorded_mixed: dict | None
+) -> None:
+ from skillevaluator.tier3.harbor import report_data
+
+ _, run = _collect(tmp_path)
+ path = run / "codex" / "lift.json"
+ lift = json.loads(path.read_text())
+ lift["judge_mixed_cases"] = recorded_mixed
+ _write_json(path, lift)
+ monkeypatch.setattr(report_data, "_MAX_TRIALS_PER_CONDITION", 1)
+ report = _report(run)
assert report["overall_lift"] is None
assert report["agents"]["codex"]["evaluators"]["accuracy"]["lift"] is None