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(tier3): report budget-denied arms as not run instead of empty Harbor failures (#616)

Christopher Kevin686174a59dda
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e4a1e75c..cc496dd1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -283,6 +283,11 @@ All notable changes to SkillEvaluator are documented in this file.
### Fixed
+- Arms fully denied by a run budget are reported as not run instead of failed
+ empty Harbor jobs. Budget-partial runs remain incomplete without an execution
+ error when all admitted attempts succeed, including stop-on-pass runs. Reused
+ baselines are not promoted to overall scores when with-skill attempts are
+ budget-denied. Explicit non-budget omissions still fail attempt coverage checks.
- Copilot CLI `harness` results flag an empty or whitespace-only `description`
(`CP-DESC-EMPTY`): Copilot lists the skill with a blank description, so the
model sees only its name.
diff --git a/docs/tier3-live-evaluation.mdx b/docs/tier3-live-evaluation.mdx
index 12bd0aa0..aa8ceecb 100644
--- a/docs/tier3-live-evaluation.mdx
+++ b/docs/tier3-live-evaluation.mdx
@@ -1024,6 +1024,17 @@ also identifies estimate-based exhaustion. The budget summary shows measured
usage and the estimated next unit, rather than implying usage reached the cap.
Attempt-count limits and stopping on unknown bounded usage are unchanged.
+If every attempt for an agent arm is denied by the budget, no Harbor job is
+created for that arm. It is reported as skipped with `skip_reason:
+budget_exhausted`, zero expected and scored attempts, and no execution error.
+The run remains incomplete because the budget left planned attempts not run.
+An empty Harbor job that was expected to execute attempts still fails validation.
+This also applies with `--stop-on-pass`: every planned case and attempt must have
+an explicit budget denial before an arm is considered not run. A reused baseline
+remains baseline evidence when the with-skill arm is denied; it does not become
+the run's overall score. Records with an explicit non-budget reason do not reduce
+the required attempt coverage.
+
Reservation reduces but does not eliminate in-flight overshoot. Estimates can
grow, an attempt can exceed its estimate, and the calibration unit is
unestimated. A run can also stop below its cap because of an estimate. Caps
diff --git a/src/skillevaluator/evaluation/tier3_report.py b/src/skillevaluator/evaluation/tier3_report.py
index 69960749..1742e121 100644
--- a/src/skillevaluator/evaluation/tier3_report.py
+++ b/src/skillevaluator/evaluation/tier3_report.py
@@ -910,7 +910,9 @@ def build_agent_eval_payload(
str(error) for agent in agent_payloads.values() for error in agent.get("execution_errors", []) if error
)
)
- statuses = [agent.get("execution_status") for agent in agent_payloads.values()]
+ statuses = [
+ agent.get("execution_status") for agent in agent_payloads.values() if agent.get("execution_status") != "skipped"
+ ]
if statuses and all(status == "succeeded" for status in statuses):
execution_status = "succeeded"
elif any(status == "failed" for status in statuses):
@@ -1206,7 +1208,7 @@ def build_agent_eval_payload(
"metric_labels": metric_labels,
"attempt_policy": policy,
"budget": budget_metadata,
- "budget_summary": budget_line(budget_metadata) if isinstance(budget_metadata, dict) else None,
+ "budget_summary": budget_line(budget_metadata, agents=agents) if isinstance(budget_metadata, dict) else None,
"dataset": public_dataset,
"case_diagnostics": case_diagnostics,
"provenance": _build_provenance(
@@ -4754,7 +4756,11 @@ def _evaluation_mode(agents: dict[str, dict[str, Any]]) -> str:
for info in agents.values():
conditions = info.get("conditions")
arm = conditions.get(condition) if isinstance(conditions, dict) else None
- statuses.append(arm.get("execution_status") if isinstance(arm, dict) else None)
+ statuses.append(
+ ("not_run" if arm.get("skip_reason") == "budget_exhausted" else arm.get("execution_status"))
+ if isinstance(arm, dict)
+ else None
+ )
return statuses
with_statuses = arm_statuses("with_skill")
diff --git a/src/skillevaluator/reporting/benchmark.py b/src/skillevaluator/reporting/benchmark.py
index c20ebb1a..b577e3e6 100644
--- a/src/skillevaluator/reporting/benchmark.py
+++ b/src/skillevaluator/reporting/benchmark.py
@@ -287,7 +287,7 @@ class BenchmarkReporter(ReporterBase):
if budget_reason and self.report_scope != "tier3":
lines.extend([tier3_callout, ""])
if isinstance(budget, dict):
- lines.extend([f"> {budget_line(budget)}", ""])
+ lines.extend([f"> {budget_line(budget, agents=ae.get('agents'))}", ""])
tolerated_lines = []
for tolerated in tolerated_baseline_agents(ae):
diff --git a/src/skillevaluator/tier3/harbor/collector.py b/src/skillevaluator/tier3/harbor/collector.py
index 5daee0be..075f6e9a 100644
--- a/src/skillevaluator/tier3/harbor/collector.py
+++ b/src/skillevaluator/tier3/harbor/collector.py
@@ -7517,12 +7517,16 @@ def collect_harbor_results(
def budget_expectations(
agent: str,
arm: str,
- ) -> tuple[int | None, list[str] | None, int | None, dict[str, int] | None]:
+ ) -> tuple[int | None, list[str] | None, int | None, dict[str, int] | None, bool]:
matching = [
- item for item in budget_not_run if item.get("agent") == agent and item.get("arm") in {arm, f"{arm}_skill"}
+ item
+ for item in budget_not_run
+ if item.get("agent") == agent
+ and item.get("arm") in {arm, f"{arm}_skill"}
+ and item.get("reason") in {None, "budget_exhausted"}
]
if not matching:
- return expected_trials, expected_case_ids, expected_cases, None
+ return expected_trials, expected_case_ids, expected_cases, None, False
attempts_by_case: dict[str, int] = {}
for item in matching:
selector = str(item.get("case_id") or "")
@@ -7541,7 +7545,28 @@ def collect_harbor_results(
case_id: max(0, n_attempts - count) for case_id, count in attempts_by_case.items() if count < n_attempts
}
actual_trials = None if expected_trials is None else max(0, expected_trials - len(matching))
- return actual_trials, active_case_ids, active_cases, attempt_counts
+ denied_slots = {
+ (
+ (case_id_by_task_selector or {}).get(str(item.get("case_id") or ""), str(item.get("case_id") or "")),
+ attempt,
+ )
+ for item in matching
+ if item.get("reason") == "budget_exhausted"
+ and type(attempt := item.get("attempt")) is int
+ and 1 <= attempt <= n_attempts
+ }
+ denied_cases = {
+ case_id
+ for case_id, _ in denied_slots
+ if case_id and all((case_id, attempt) in denied_slots for attempt in range(1, n_attempts + 1))
+ }
+ if expected_case_ids:
+ budget_denied = set(expected_case_ids) <= denied_cases
+ elif expected_cases is not None:
+ budget_denied = expected_cases > 0 and len(denied_cases) == expected_cases
+ else:
+ budget_denied = bool(expected_trials and len(denied_cases) * n_attempts == expected_trials)
+ return actual_trials, active_case_ids, active_cases, attempt_counts, budget_denied
# Unscored conditions keep the requested grading policy instead of
# falling back to the default metric set, which custom_only never grades.
@@ -7577,12 +7602,20 @@ def collect_harbor_results(
tolerance_rejected: dict[str, str] = {}
for agent in agents:
- with_expected_trials, with_expected_case_ids, with_expected_cases, with_expected_attempts = budget_expectations(
- agent, "with"
- )
- without_expected_trials, without_expected_case_ids, without_expected_cases, without_expected_attempts = (
- budget_expectations(agent, "without")
- )
+ (
+ with_expected_trials,
+ with_expected_case_ids,
+ with_expected_cases,
+ with_expected_attempts,
+ with_budget_denied,
+ ) = budget_expectations(agent, "with")
+ (
+ without_expected_trials,
+ without_expected_case_ids,
+ without_expected_cases,
+ without_expected_attempts,
+ without_budget_denied,
+ ) = budget_expectations(agent, "without")
if skip_baseline:
agent_expected_case_ids = with_expected_case_ids
elif with_expected_case_ids is not None and without_expected_case_ids is not None:
@@ -7598,7 +7631,7 @@ def collect_harbor_results(
with_job_name = f"{skill_name}-{agent}-with"
# A skipped arm never adopts a stale job left in a reused jobs directory.
- with_job_dir = None if skip_with_skill else _find_job_dir(jobs_dir, with_job_name)
+ with_job_dir = None if skip_with_skill or with_budget_denied else _find_job_dir(jobs_dir, with_job_name)
with_collected_rewards: list[dict[str, Any]] = []
with_rewards: list[dict[str, Any]] = []
@@ -7762,7 +7795,7 @@ def collect_harbor_results(
len(with_logical_rewards),
with_scores,
)
- elif not skip_with_skill:
+ elif not skip_with_skill and not with_budget_denied:
with_job_failure = f"No Harbor job found for {with_job_name}"
logger.warning("No Harbor job found for %s (with-skill)", with_job_name)
prefix = f"{agent} with-skill Harbor run failed: "
@@ -7780,10 +7813,12 @@ def collect_harbor_results(
n_attempts=n_attempts,
job_failure=with_job_failure,
runtime_failures=with_runtime_failures,
- skipped=skip_with_skill,
+ skipped=skip_with_skill or with_budget_denied,
stop_on_pass=stop_on_pass,
pass_threshold=pass_threshold,
)
+ if with_budget_denied:
+ with_execution["skip_reason"] = "budget_exhausted"
# A skipped with-skill arm still writes its summary: report loading keys
# agent presence on it, and its "skipped" status marks a baseline-only run.
# A with-skill job that never started records the requested grading
@@ -7841,7 +7876,7 @@ def collect_harbor_results(
without_job_dir: Path | None = None
without_slots: dict[str, dict[str, Any]] = {}
without_identity: dict[str, Any] = {}
- if not skip_baseline:
+ if not skip_baseline and not without_budget_denied:
without_job_name = f"{skill_name}-{agent}-without"
without_job_dir = (
reused_baseline_dir / agent / "without-skill"
@@ -8042,11 +8077,13 @@ def collect_harbor_results(
n_attempts=n_attempts,
job_failure=without_job_failure,
runtime_failures=without_runtime_failures,
- skipped=skip_baseline,
+ skipped=skip_baseline or without_budget_denied,
stop_on_pass=stop_on_pass,
pass_threshold=pass_threshold,
expected_attempts_by_case=without_expected_attempts,
)
+ if without_budget_denied:
+ without_execution["skip_reason"] = "budget_exhausted"
if not skip_baseline and without_job_dir is None:
summary_dir = agent_dir / "without-skill"
summary_dir.mkdir(parents=True, exist_ok=True)
diff --git a/src/skillevaluator/tier3/harbor/report_data.py b/src/skillevaluator/tier3/harbor/report_data.py
index 848942bf..5dbae24d 100644
--- a/src/skillevaluator/tier3/harbor/report_data.py
+++ b/src/skillevaluator/tier3/harbor/report_data.py
@@ -953,6 +953,9 @@ def load_agent_data(
)
condition_execution[key] = {
"execution_status": status,
+ **(
+ {"skip_reason": "budget_exhausted"} if data.get("skip_reason") == "budget_exhausted" else {}
+ ),
"execution_errors": condition_errors,
**_execution_error_details(data, len(condition_errors)),
"expected_cases": _nonnegative_counter(data.get("expected_cases")),
diff --git a/src/skillevaluator/tier3/harbor/run_budget.py b/src/skillevaluator/tier3/harbor/run_budget.py
index f2b21896..d7e10923 100644
--- a/src/skillevaluator/tier3/harbor/run_budget.py
+++ b/src/skillevaluator/tier3/harbor/run_budget.py
@@ -461,7 +461,7 @@ def budget_incomplete_reason(metadata: object) -> str | None:
)
-def budget_line(metadata: dict[str, Any]) -> str:
+def budget_line(metadata: dict[str, Any], *, agents: dict[str, Any] | None = None) -> str:
# Recompute from usage and limits: cached observations may be absent or stale.
overruns, incomplete, configured = _budget_observations(metadata)
observations = "; ".join(
@@ -520,4 +520,28 @@ def budget_line(metadata: dict[str, Any]) -> str:
limits = metadata.get("limits")
if isinstance(limits, dict) and limits.get("max_cost_usd") is not None:
line += "; agent inference only (user-supplied rates; provider-cost fallback), not billed spend"
+ rows = metadata.get("not_run")
+ denied = {
+ (row.get("agent"), row.get("arm"))
+ for row in (rows if isinstance(rows, list) else [])
+ if isinstance(row, dict)
+ and row.get("reason") == "budget_exhausted"
+ and isinstance(row.get("agent"), str)
+ and isinstance(row.get("arm"), str)
+ }
+ for agent, data in (agents if isinstance(agents, dict) else {}).items():
+ if not isinstance(agent, str) or len(agent) > 64 or not agent.replace("-", "").replace("_", "").isalnum():
+ continue
+ conditions = data.get("conditions", {}) if isinstance(data, dict) else {}
+ if not isinstance(conditions, dict):
+ continue
+ for arm in ("with", "without"):
+ condition = conditions.get(f"{arm}_skill", {})
+ if (
+ isinstance(condition, dict)
+ and condition.get("execution_status") == "skipped"
+ and condition.get("expected_attempts") == 0
+ and ((agent, arm) in denied or (agent, f"{arm}_skill") in denied)
+ ):
+ line += f"; {agent} {arm}-skill not run due to budget"
return line
diff --git a/src/skillevaluator/tier3/harbor/runner.py b/src/skillevaluator/tier3/harbor/runner.py
index b6122ded..78f65afc 100644
--- a/src/skillevaluator/tier3/harbor/runner.py
+++ b/src/skillevaluator/tier3/harbor/runner.py
@@ -4881,6 +4881,8 @@ def _run_budgeted_variants(
for future in as_completed(futures):
future.result()
for variant, _, _ in jobs:
+ if not attempt_job_dirs[variant]:
+ continue
_merge_attempt_jobs(
[attempt_job_dirs[variant][key] for key in sorted(attempt_job_dirs[variant])],
jobs_dir / f"{skill_name}-{agent}-{variant}",
@@ -6786,6 +6788,7 @@ def _run_harbor_eval_impl(
from skillevaluator.evaluation.tier3_report import (
_agent_score_policy,
_build_agent,
+ _evaluation_mode,
)
from skillevaluator.evaluation.tier3_report import (
_pick_best_agent as _pick_canonical_best_agent,
@@ -6815,18 +6818,7 @@ def _run_harbor_eval_impl(
if agent_results:
best_agent = _pick_best_agent(agent_results)
if best_agent not in agent_results:
- conditions = [
- agent.get("conditions", {}).get("with_skill", {}).get("execution_status")
- if isinstance(agent, dict)
- and isinstance(agent.get("conditions"), dict)
- and isinstance(agent["conditions"].get("with_skill"), dict)
- else None
- for agent in agent_results.values()
- ]
- baseline_only = bool(agent_results) and (
- skip_with_skill
- or (len(conditions) == len(agent_results) and all(status == "skipped" for status in conditions))
- )
+ baseline_only = _evaluation_mode(agent_results) == "baseline_only"
# Canonical agent payloads carry the baseline-only score as "baseline".
score_field = "baseline" if baseline_only else "with_skill"
canonical_agents = {
diff --git a/src/skillevaluator/tier3/result_display.py b/src/skillevaluator/tier3/result_display.py
index ac5ea79c..b63590ed 100644
--- a/src/skillevaluator/tier3/result_display.py
+++ b/src/skillevaluator/tier3/result_display.py
@@ -1113,7 +1113,7 @@ def render_evaluation_result(
):
from skillevaluator.tier3.harbor.run_budget import budget_line
- console.print(budget_line(dict(budget)))
+ console.print(budget_line(dict(budget), agents=result.get("agents")))
from skillevaluator.tier3.harbor.run_budget import budget_incomplete_reason
budget_reason = budget_incomplete_reason(dict(budget)) if isinstance(budget, Mapping) else None
diff --git a/tests/tier3/test_budget_denied_arms.py b/tests/tier3/test_budget_denied_arms.py
new file mode 100644
index 00000000..58ce4043
--- /dev/null
+++ b/tests/tier3/test_budget_denied_arms.py
@@ -0,0 +1,146 @@
+# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0
+
+import shutil
+
+import pytest
+from tests.tier3.test_baseline_timeouts import SCORES, _arm, _attempt_job
+
+from skillevaluator.evaluation.tier3_report import build_agent_eval_payload
+from skillevaluator.tier3.harbor import collector, runner
+from skillevaluator.tier3.harbor.report_data import load_agent_data
+from skillevaluator.tier3.harbor.run_budget import BudgetController
+
+
+def _collect(tmp_path, agents, budget, **kwargs):
+ options = {"n_attempts": 2, "expected_trials": None, "expected_cases": 1, "expected_case_ids": ["case"]}
+ options.update(kwargs)
+ return collector.collect_harbor_results(
+ skill_name="demo",
+ agents=agents,
+ output_dir=tmp_path / "results",
+ jobs_dir=tmp_path / "jobs",
+ case_id_by_task_selector={"case": "case"},
+ budget_not_run=budget.not_run,
+ **options,
+ )
+
+
[email protected]("admit_first", [False, True], ids=["zero-cap", "second-agent-denied"])
+def test_stop_on_pass_fully_budget_denied_arms(monkeypatch, tmp_path, admit_first):
+ def harbor(*, job_name, jobs_dir, **kwargs):
+ source = _attempt_job(tmp_path / "physical", job_name, "with", "case", 1, "pass")
+ shutil.copytree(source, jobs_dir / job_name)
+ return True, ""
+
+ monkeypatch.setattr(runner, "_run_harbor", harbor)
+ expected = []
+ validate = collector.validate_harbor_job_result
+
+ def record_validation(path, **kwargs):
+ if "expected_trials" in kwargs:
+ expected.append(kwargs["expected_trials"])
+ return validate(path, **kwargs)
+
+ monkeypatch.setattr(collector, "validate_harbor_job_result", record_validation)
+ agents = ["first", "denied"] if admit_first else ["denied"]
+ budget = BudgetController(max_attempts_total=2 if admit_first else 0, planned=4 * len(agents))
+ for agent in agents:
+ errors = runner._run_budgeted_variants(
+ skill_name="demo",
+ agent=agent,
+ jobs=[("with", tmp_path / "with", None), ("without", tmp_path / "without", None)],
+ task_names=["case"],
+ env_mode="docker",
+ model="model",
+ jobs_dir=tmp_path / "jobs",
+ run_env={},
+ n_attempts=2,
+ pass_threshold=0.5,
+ stop_on_pass=True,
+ timeout_multiplier=1,
+ override_cpus=None,
+ override_memory_mb=None,
+ override_storage_mb=None,
+ budget=budget,
+ n_concurrent=1,
+ )
+ assert not any(errors.values())
+ results = _collect(tmp_path, agents, budget, stop_on_pass=True)
+ for arm in results["agents"]["denied"]["conditions"].values():
+ assert arm["execution_status"] == "skipped"
+ assert arm["skip_reason"] == "budget_exhausted"
+ assert arm["expected_attempts"] == arm["scored_attempts"] == 0
+ assert not results["execution_errors"]
+ assert expected == ([None, None] if admit_first else [])
+ payload = build_agent_eval_payload(
+ "demo", load_agent_data(tmp_path / "results"), run_config={"budget": budget.metadata()}
+ )
+ assert payload["verdict"] == "incomplete"
+ if admit_first:
+ assert results["agents"]["first"]["execution_status"] == "succeeded"
+
+
+def test_reused_baseline_is_not_the_score_of_a_budget_denied_run(tmp_path):
+ source = tmp_path / "source"
+ for arm in ("with", "without"):
+ _arm(source / "jobs", "agent", arm, [("case", "scored")], scores=dict.fromkeys(SCORES, 0.8))
+ _collect(source, ["agent"], BudgetController(), n_attempts=1, expected_trials=1)
+ budget = BudgetController(max_attempts_total=0, planned=1)
+ assert not budget.admit(agent="agent", arm="with", case_id="case", attempt=1)
+ _collect(tmp_path, ["agent"], budget, n_attempts=1, expected_trials=1, reused_baseline_dir=source / "results")
+ payload = build_agent_eval_payload(
+ "demo", load_agent_data(tmp_path / "results"), run_config={"budget": budget.metadata()}
+ )
+ assert payload["mode"] != "baseline_only"
+ assert payload["overall_score"] is None
+ assert payload["verdict"] == "incomplete"
+ assert payload["agents"]["agent"]["baseline"] == pytest.approx(0.8)
+
+
[email protected]("reason", ["execution_failed", "budget_exhausted", None])
+def test_only_budget_or_legacy_omissions_reduce_expected_attempts(tmp_path, reason):
+ for arm in ("with", "without"):
+ _arm(tmp_path / "jobs", "agent", arm, [("case", "scored")])
+ budget = BudgetController()
+ for arm in ("with", "without"):
+ row = {"agent": "agent", "arm": arm, "case_id": "case", "attempt": 2, "status": "not_run"}
+ if reason is not None:
+ row["reason"] = reason
+ budget.not_run.append(row)
+ results = _collect(tmp_path, ["agent"], budget, expected_trials=2)
+ assert results["execution_status"] == ("failed" if reason == "execution_failed" else "succeeded")
+ condition = results["agents"]["agent"]["conditions"]["with_skill"]
+ assert condition["expected_attempts"] == (2 if reason == "execution_failed" else 1)
+ if reason == "execution_failed":
+ assert any("Missing scored attempts" in error for error in results["execution_errors"])
+
+
[email protected]("attempts", [[1], [1, 1], [1, 3], [0, 2]])
+def test_full_budget_denial_requires_every_planned_slot(tmp_path, attempts):
+ budget = BudgetController()
+ budget.not_run.extend(
+ {
+ "agent": "agent",
+ "arm": arm,
+ "case_id": "case",
+ "attempt": attempt,
+ "status": "not_run",
+ "reason": "budget_exhausted",
+ }
+ for arm in ("with", "without")
+ for attempt in attempts
+ )
+ results = _collect(tmp_path, ["agent"], budget, stop_on_pass=True)
+ assert results["execution_status"] == "failed"
+ assert all("skip_reason" not in arm for arm in results["agents"]["agent"]["conditions"].values())
+
+
+def test_full_budget_denial_can_use_the_planned_case_count(tmp_path):
+ budget = BudgetController(max_attempts_total=0, planned=4)
+ for arm in ("with", "without"):
+ for attempt in (1, 2):
+ assert not budget.admit(agent="agent", arm=arm, case_id="case", attempt=attempt)
+ results = _collect(tmp_path, ["agent"], budget, stop_on_pass=True, expected_case_ids=None)
+ assert results["agents"]["agent"]["execution_status"] == "skipped"
+ assert not results["execution_errors"]
diff --git a/tests/tier3/test_run_budget.py b/tests/tier3/test_run_budget.py
index 4087484d..f43495c1 100644
--- a/tests/tier3/test_run_budget.py
+++ b/tests/tier3/test_run_budget.py
@@ -11,6 +11,7 @@ from skillevaluator.tier3.harbor.run_budget import (
BudgetController,
Price,
PriceBook,
+ budget_incomplete_reason,
budget_line,
planned_attempts,
)
@@ -322,7 +323,8 @@ def test_budget_admits_both_arms_as_one_case_attempt(monkeypatch, tmp_path):
assert budget.metadata()["attempts_not_run"] == 2
-def test_partial_budget_run_collects_real_harbor_results(monkeypatch, tmp_path):
[email protected]("denial_mode", ["partial", "agent", "baseline"])
+def test_partial_budget_run_collects_real_harbor_results(monkeypatch, tmp_path, denial_mode):
import shutil
from datetime import UTC, datetime
from uuid import UUID
@@ -330,8 +332,14 @@ def test_partial_budget_run_collects_real_harbor_results(monkeypatch, tmp_path):
from harbor.models.job.result import JobResult, JobStats
from harbor.models.trial.result import TrialResult
+ from skillevaluator.evaluation.tier3_report import build_agent_eval_payload
+ from skillevaluator.models.result import ValidationResult
+ from skillevaluator.reporting import HTMLReporter
+ from skillevaluator.reporting.benchmark import BenchmarkReporter
from skillevaluator.tier3.harbor.collector import _extract_rewards, collect_harbor_results
from skillevaluator.tier3.harbor.metrics import DEFAULT_METRIC_SET, DEFAULT_METRICS
+ from skillevaluator.tier3.harbor.report_data import load_agent_data
+ from skillevaluator.tier3.result_display import render_evaluation_result
jobs_dir = tmp_path / "jobs"
starts = []
@@ -419,11 +427,18 @@ def test_partial_budget_run_collects_real_harbor_results(monkeypatch, tmp_path):
monkeypatch.setattr(runner, "_run_harbor", fake_harbor)
monkeypatch.setattr(runner, "_merge_attempt_jobs", merge_attempts)
- budget = BudgetController(max_agent_tokens=2500, planned=12)
+ budget = (
+ BudgetController(max_attempts_total=6, planned=12)
+ if denial_mode == "baseline"
+ else BudgetController(max_agent_tokens=2500, planned=24 if denial_mode == "agent" else 12)
+ )
+ jobs = [("with", tmp_path / "with", None)]
+ if denial_mode != "baseline":
+ jobs.append(("without", tmp_path / "without", None))
errors = runner._run_budgeted_variants(
skill_name="skill",
agent="agent",
- jobs=[("with", tmp_path / "with", None), ("without", tmp_path / "without", None)],
+ jobs=jobs,
task_names=["case-1", "case-2", "case-3"],
env_mode="docker",
model="fixture-model",
@@ -440,14 +455,45 @@ def test_partial_budget_run_collects_real_harbor_results(monkeypatch, tmp_path):
n_concurrent=1,
)
assert not any(errors.values())
+ if denial_mode != "partial":
+ denied_agent = "denied" if denial_mode == "agent" else "agent"
+ denied_jobs = (
+ [("with", tmp_path / "with", None), ("without", tmp_path / "without", None)]
+ if denial_mode == "agent"
+ else [("without", tmp_path / "without", None)]
+ )
+ runner._run_budgeted_variants(
+ skill_name="skill",
+ agent=denied_agent,
+ jobs=denied_jobs,
+ task_names=["case-1", "case-2", "case-3"],
+ env_mode="docker",
+ model="fixture-model",
+ jobs_dir=jobs_dir,
+ run_env={},
+ n_attempts=2,
+ pass_threshold=0.5,
+ stop_on_pass=False,
+ timeout_multiplier=1,
+ override_cpus=None,
+ override_memory_mb=None,
+ override_storage_mb=None,
+ budget=budget,
+ n_concurrent=1,
+ )
+ for arm, _, _ in denied_jobs:
+ assert not (jobs_dir / f"skill-{denied_agent}-{arm}").exists()
+ stale_job = jobs_dir / f"skill-{denied_agent}-{arm}"
+ stale_job.mkdir(parents=True)
+ (stale_job / "result.json").write_text(json.dumps({"n_total_trials": 0, "stats": {}}))
collected = _extract_rewards(
jobs_dir / "skill-agent-with",
{case_id: case_id for case_id in ("case-1", "case-2", "case-3")},
)
- assert len(collected) == 2, collected
+ assert len(collected) == (6 if denial_mode == "baseline" else 2), collected
results = collect_harbor_results(
"skill",
- ["agent"],
+ ["agent", "denied"] if denial_mode == "agent" else ["agent"],
tmp_path / "results",
jobs_dir,
n_attempts=2,
@@ -460,9 +506,78 @@ def test_partial_budget_run_collects_real_harbor_results(monkeypatch, tmp_path):
agent_result = results["agents"]["agent"]
assert results["partial"] is True
assert agent_result["execution_status"] == "succeeded", agent_result.get("execution_errors") or agent_result
- assert agent_result["num_trials_with"] == 2
- assert len(starts) == 4
- assert all(row["basis"] == "estimate" for row in budget.not_run)
+ assert agent_result["num_trials_with"] == (6 if denial_mode == "baseline" else 2)
+ assert len(starts) == (6 if denial_mode == "baseline" else 4)
+ if denial_mode != "baseline":
+ assert all(row["basis"] == "estimate" for row in budget.not_run)
+ if denial_mode != "partial":
+ denied = results["agents"][denied_agent]
+ for arm, _, _ in denied_jobs:
+ condition = denied["conditions"][f"{arm}_skill"]
+ assert condition["execution_status"] == "skipped"
+ assert condition["skip_reason"] == "budget_exhausted"
+ assert condition["expected_attempts"] == condition["scored_attempts"] == 0
+ assert condition["execution_errors"] == []
+ assert denied["execution_status"] == ("skipped" if denial_mode == "agent" else "succeeded")
+ assert results["execution_errors"] == []
+ assert budget_incomplete_reason(budget.metadata())
+ assert f"{denied_agent} {denied_jobs[0][0]}-skill not run due to budget" in budget_line(
+ budget.metadata(), agents=results["agents"]
+ )
+ payload = build_agent_eval_payload(
+ "skill", load_agent_data(tmp_path / "results"), run_config={"budget": budget.metadata()}
+ )
+ assert payload["verdict"] == "incomplete"
+ validation = ValidationResult(validator_name="AGENT_EVAL", validator_description="Live evaluation")
+ validation.metadata["agent_eval"] = payload
+ html = HTMLReporter(include_timestamp=False).render_all([validation])
+ benchmark = BenchmarkReporter(report_scope="tier3").render_all([validation])
+ console = Console(record=True, width=300)
+ render_evaluation_result({**results, "budget": budget.metadata()}, console=console)
+ for report in (html, benchmark, console.export_text()):
+ assert f"{denied_agent} {denied_jobs[0][0]}-skill not run due to budget" in report
+ assert "Harbor completed with zero trials" not in report
+
+
+def test_zero_trial_job_with_expected_work_still_fails(tmp_path):
+ from skillevaluator.tier3.harbor.collector import validate_harbor_job_result
+
+ result = tmp_path / "result.json"
+ result.write_text(json.dumps({"n_total_trials": 0, "stats": {}}))
+ assert validate_harbor_job_result(result, expected_trials=1) == (False, "Harbor completed with zero trials")
+
+
[email protected]("reason", [None, "execution_failed"])
+def test_zero_trial_job_requires_explicit_budget_denial_to_skip(tmp_path, reason):
+ from skillevaluator.tier3.harbor.collector import collect_harbor_results
+
+ not_run = []
+ for arm in ("with", "without"):
+ job = tmp_path / "jobs" / f"skill-agent-{arm}"
+ job.mkdir(parents=True)
+ (job / "result.json").write_text(json.dumps({"n_total_trials": 0, "stats": {}}))
+ item = {"agent": "agent", "arm": arm, "case_id": "case", "attempt": 1, "status": "not_run"}
+ if reason is not None:
+ item["reason"] = reason
+ not_run.append(item)
+
+ results = collect_harbor_results(
+ skill_name="skill",
+ agents=["agent"],
+ output_dir=tmp_path / "results",
+ jobs_dir=tmp_path / "jobs",
+ n_attempts=1,
+ expected_trials=1,
+ expected_cases=1,
+ expected_case_ids=["case"],
+ budget_not_run=not_run,
+ )
+
+ assert results["execution_status"] == "failed"
+ assert any("Harbor completed with zero trials" in error for error in results["execution_errors"])
+ for condition in results["agents"]["agent"]["conditions"].values():
+ assert condition["execution_status"] == "failed"
+ assert "skip_reason" not in condition
def test_fake_attempt_runner_stops_after_token_budget(monkeypatch, tmp_path):