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.
Python agent-evaluationagent-pluginsagent-securityagent-skillsagentic-aibenchmarkci-templatesclaude-codecodexevaluateevaluationharnesspluginplugin-evaluationsecurity-scannerskill-evalskill-evaluationskill-evaluatorskill-gap-analysisskills
fix(tier3): honor --n-concurrent with --stop-on-pass (#275)
Narendran Raghavan3ad28385b9eb
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 216f8398..891ec395 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -393,6 +393,13 @@ All notable changes to SkillEvaluator are documented in this file.timeout, and each retry warning ends with the failed command's output.Platform probe and transport errors are not retried, and local mode stillchecks the installed CLI once.+- Tier 3 `--stop-on-pass` (or `harbor.stop_on_pass: true`) no longer ignores+ `--n-concurrent`. Every case and attempt previously ran one at a time, so+ large evaluations took several times longer than the configured concurrency+ allowed. Up to `n_concurrent` cases now run at once per agent. A case's+ attempts still run one after another and stop after its first pass, the+ with-skill and without-skill arms still run one after the other, and the+ merged arm results keep dataset order.- Tier 2 caps every intra-skill embedding chunk at 3,000 characters, preservesmeaningful short tails and actual Python docstring source ranges, and avoidscounting pieces of one original chunk as duplicates of each other. Oversizeddiff --git a/docs/tier3-live-evaluation.mdx b/docs/tier3-live-evaluation.mdxindex 365a03ba..1d5482ac 100644--- a/docs/tier3-live-evaluation.mdx+++ b/docs/tier3-live-evaluation.mdx@@ -584,6 +584,13 @@ The high-signal flags, with defaults:| `--copy-repo` | off | Copy the surrounding repository into the task environment || `--include-skills` | none | Stage additional skill directories; requires `--skill-workspace-mode group` |+With `--stop-on-pass`, `--n-concurrent` still limits concurrent eval cases per+agent. Each case's attempts run one after another and stop after the first+passing score. The with-skill and without-skill arms run one after the other,+and each uses the full `--n-concurrent` budget. For example, two agents with+`--n-concurrent 4` run up to eight trials at once, fewer when fewer cases+remain.+Every `tier3 evaluate` flag, including resource overrides and Dockerfilemodes, is in the [CLI Reference](cli-reference.mdx).diff --git a/src/skillevaluator/tier3/harbor/runner.py b/src/skillevaluator/tier3/harbor/runner.pyindex d1c5e46a..3c8c46d1 100644--- a/src/skillevaluator/tier3/harbor/runner.py+++ b/src/skillevaluator/tier3/harbor/runner.py@@ -4583,13 +4583,23 @@ def _run_stop_on_pass_variant(agent_import_path: str | None = None,verifier_env: Mapping[str, str] | None = None,environment_kwargs: Mapping[str, Any] | None = None,+ n_concurrent: int = 1,cancellation: _HarborRunCancellation | None = None,) -> list[str]:- """Run each case one attempt at a time, stopping its attempts on first pass."""- errors: list[tuple[Path, str]] = []- attempt_job_dirs: list[Path] = []- for task_name in task_names:+ """Run up to ``n_concurrent`` cases at once, stopping each case's attempts on first pass.++ A case launches its next attempt only after the previous one scored, so+ attempts of one case stay sequential. Attempt jobs are merged in dataset+ order rather than completion order, keeping the aggregate deterministic.+ """+ stop_launching = threading.Event()++ def _run_case(task_name: str) -> tuple[list[str], list[Path]]:+ case_errors: list[tuple[Path, str]] = []+ case_job_dirs: list[Path] = []for attempt in range(1, n_attempts + 1):+ if stop_launching.is_set():+ breakjob_name = f"{skill_name}-{agent}-{variant}-{task_name}-attempt{attempt:03d}"ok, detail = _run_harbor(dataset=dataset,@@ -4613,23 +4623,54 @@ def _run_stop_on_pass_variant(cancellation=cancellation,)job_dir = jobs_dir / job_name- attempt_job_dirs.append(job_dir)+ case_job_dirs.append(job_dir)if not ok:- errors.append(+ case_errors.append((job_dir, f"{agent} {variant}-skill Harbor run failed: {task_name} attempt {attempt}: {detail}"))continue- errors = [+ # A recovered timeout matches only an earlier attempt of the same+ # task, so filtering this case's own errors is enough.+ case_errors = [(failed_dir, detail)- for failed_dir, detail in errors+ for failed_dir, detail in case_errorsif not detail.endswith(": Harbor job did not complete successfully: 1 errored")or not failed_dir.is_dir()or not harbor_timeout_job_recovered(failed_dir, job_dir)]if _job_passed(job_dir, pass_threshold):break+ return [detail for _, detail in case_errors], case_job_dirs++ def _run_case_or_stop(task_name: str) -> tuple[list[str], list[Path]]:+ try:+ return _run_case(task_name)+ except BaseException:+ # As in a serial loop, an unexpected failure stops later launches.+ stop_launching.set()+ raise++ errors: list[str] = []+ attempt_job_dirs: list[Path] = []+ if task_names:+ with ThreadPoolExecutor(max_workers=min(n_concurrent, len(task_names))) as executor:+ futures = [executor.submit(_run_case_or_stop, task_name) for task_name in task_names]+ try:+ # Surface an unexpected case failure without waiting on earlier cases.+ for future in as_completed(futures):+ future.result()+ except BaseException:+ # Queued cases never start; running cases finish only their current attempt.+ stop_launching.set()+ for future in futures:+ future.cancel()+ raise+ for future in futures:+ case_errors, case_job_dirs = future.result()+ errors.extend(case_errors)+ attempt_job_dirs.extend(case_job_dirs)_merge_attempt_jobs(attempt_job_dirs, jobs_dir / f"{skill_name}-{agent}-{variant}")- return [detail for _, detail in errors]+ return errorsdef _private_runtime_hooks() -> Any:@@ -4729,8 +4770,9 @@ def _run_agent_pair(return []if stop_on_pass:- # A later attempt is launched only after the previous one scored, so- # stop-on-pass runs each condition sequentially, one attempt at a time.+ # A case's later attempt is launched only after its previous one+ # scored. Up to n_concurrent cases run at once, and the conditions run+ # one after another, so each gets the full per-agent budget.sequential_errors: list[str] = []for variant, dataset, job_import_path in jobs:try:@@ -4753,6 +4795,7 @@ def _run_agent_pair(agent_import_path=job_import_path,verifier_env=verifier_env,environment_kwargs=environment_kwargs,+ n_concurrent=n_concurrent,cancellation=cancellation,)except Exception as exc:diff --git a/tests/test_harbor_stop_on_pass_concurrency.py b/tests/test_harbor_stop_on_pass_concurrency.pynew file mode 100644index 00000000..e43e45d8--- /dev/null+++ b/tests/test_harbor_stop_on_pass_concurrency.py@@ -0,0 +1,265 @@+# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.+# SPDX-License-Identifier: Apache-2.0++"""Stop-on-pass runs cases concurrently while each case's attempts stay sequential."""++from __future__ import annotations++import json+import threading+import time+from datetime import UTC, datetime+from pathlib import Path+from uuid import uuid4++import pytest++pytest.importorskip("harbor")++from harbor.models.job.result import JobResult, JobStats+from harbor.models.trial.result import TrialResult++from skillevaluator.tier3.harbor import runner++_CASES = ("a", "b", "c", "d")+# a and c pass first time, b passes on its second attempt, d never passes.+_EXPECTED_ATTEMPTS = {"a": 1, "b": 2, "c": 1, "d": 3}+++def _write_attempt_job(job_dir: Path, *, agent: str, case: str, score: float) -> None:+ trial_name = f"{case}__attempt"+ trial_dir = job_dir / trial_name+ trial_dir.mkdir(parents=True)+ now = datetime(2026, 1, 1, tzinfo=UTC)+ task_path = str(job_dir.parent / "tasks" / case)+ trial = TrialResult.model_validate(+ {+ "id": uuid4(),+ "task_name": case,+ "trial_name": trial_name,+ "trial_uri": trial_dir.as_uri(),+ "task_id": {"path": task_path},+ "task_checksum": "stop-on-pass-concurrency",+ "config": {"task": {"path": task_path}, "trial_name": trial_name, "trials_dir": str(job_dir)},+ "agent_info": {"name": agent, "version": "test", "model_info": {"name": "test-model"}},+ "agent_result": {},+ "verifier_result": {"rewards": {"overall": score}},+ "started_at": now,+ "finished_at": now,+ }+ )+ (trial_dir / "result.json").write_text(trial.model_dump_json(indent=2), encoding="utf-8")+ job = JobResult(+ id=uuid4(),+ started_at=now,+ updated_at=now,+ finished_at=now,+ n_total_trials=1,+ stats=JobStats.from_trial_results([trial], n_total_trials=1),+ trial_results=[trial],+ )+ (job_dir / "result.json").write_text(job.model_dump_json(indent=2), encoding="utf-8")++[email protected]("concurrency", [1, 2, 4])+def test_stop_on_pass_runs_cases_concurrently_with_serial_attempts(+ monkeypatch: pytest.MonkeyPatch,+ tmp_path: Path,+ concurrency: int,+) -> None:+ # Fails if cases are serialized (the rendezvous times out), if the pool+ # exceeds n_concurrent, or if a case retries in parallel or after a pass.+ rendezvous = threading.Barrier(concurrency)+ lock = threading.Lock()+ active: set[tuple[str, str]] = set()+ peak = 0+ attempts: dict[tuple[str, str], int] = {}+ launches: list[tuple[str, str, str]] = []+ rendezvous_failed: list[tuple[str, str]] = []+ overlapping_attempts: list[tuple[str, str]] = []+ jobs_dir = tmp_path / "jobs"++ def fake_run_harbor(**kwargs: object) -> tuple[bool, str]:+ nonlocal peak+ dataset = kwargs["dataset"]+ assert isinstance(dataset, Path)+ assert kwargs["n_attempts"] == kwargs["n_concurrent"] == kwargs["expected_trials"] == 1+ include = kwargs["include_task_names"]+ assert isinstance(include, list) and len(include) == 1+ case = include[0]+ key = (dataset.name, case)+ with lock:+ if key in active:+ overlapping_attempts.append(key)+ active.add(key)+ peak = max(peak, len(active))+ attempts[key] = attempts.get(key, 0) + 1+ attempt = attempts[key]+ launches.append((dataset.name, case, str(kwargs["job_name"])))+ if attempt == 1:+ try:+ rendezvous.wait(timeout=10)+ except threading.BrokenBarrierError:+ rendezvous_failed.append(key)+ # Finish later cases first so completion order differs from dataset order.+ time.sleep(0.02 * (len(_CASES) - _CASES.index(case)))+ passed = case in ("a", "c") or (case == "b" and attempt == 2)+ _write_attempt_job(+ jobs_dir / str(kwargs["job_name"]),+ agent=str(kwargs["agent"]),+ case=case,+ score=1.0 if passed else 0.0,+ )+ with lock:+ active.discard(key)+ return True, ""++ monkeypatch.setattr(runner, "_run_harbor", fake_run_harbor)++ errors = runner._run_agent_pair(+ skill_name="demo",+ agent="opencode",+ model="test-model",+ env_mode="docker",+ with_skill=tmp_path / "with",+ baseline=tmp_path / "without",+ jobs_dir=jobs_dir,+ run_env={},+ n_attempts=3,+ n_concurrent=concurrency,+ timeout_multiplier=1.0,+ override_cpus=None,+ override_memory_mb=None,+ override_storage_mb=None,+ expected_trials=len(_CASES) * 3,+ stop_on_pass=True,+ pass_threshold=0.5,+ task_names=list(_CASES),+ )++ assert errors == []+ assert rendezvous_failed == []+ assert overlapping_attempts == []+ assert peak == concurrency+ assert not active+ # Conditions stay sequential: every with-skill launch precedes the baseline.+ variants = [variant for variant, _case, _job in launches]+ assert variants == ["with"] * 7 + ["without"] * 7+ for variant in ("with", "without"):+ assert {case: attempts[(variant, case)] for case in _CASES} == _EXPECTED_ATTEMPTS+ for case in _CASES:+ case_jobs = [+ job for launched, launched_case, job in launches if (launched, launched_case) == (variant, case)+ ]+ assert case_jobs == [+ f"demo-opencode-{variant}-{case}-attempt{attempt:03d}"+ for attempt in range(1, _EXPECTED_ATTEMPTS[case] + 1)+ ]+ aggregate = json.loads((jobs_dir / f"demo-opencode-{variant}" / "result.json").read_text(encoding="utf-8"))+ assert aggregate["n_total_trials"] == 7+ # Merged in dataset order, independent of which case finished first.+ assert [trial["task_name"] for trial in aggregate["trial_results"]] == [+ case for case in _CASES for _attempt in range(_EXPECTED_ATTEMPTS[case])+ ]+++def test_stop_on_pass_failed_attempts_retry_only_their_case_in_dataset_order(+ monkeypatch: pytest.MonkeyPatch,+ tmp_path: Path,+) -> None:+ jobs_dir = tmp_path / "jobs"+ launched: list[str] = []+ lock = threading.Lock()++ def fake_run_harbor(**kwargs: object) -> tuple[bool, str]:+ job_name = str(kwargs["job_name"])+ include = kwargs["include_task_names"]+ assert isinstance(include, list)+ case = include[0]+ with lock:+ launched.append(job_name)+ if case in ("a", "c") and job_name.endswith("-attempt001"):+ if case == "a":+ # Report the later case's failure first.+ time.sleep(0.05)+ return False, "harbor run exited 1"+ _write_attempt_job(jobs_dir / job_name, agent="opencode", case=case, score=1.0)+ return True, ""++ monkeypatch.setattr(runner, "_run_harbor", fake_run_harbor)++ errors = runner._run_stop_on_pass_variant(+ skill_name="demo",+ agent="opencode",+ variant="with",+ dataset=tmp_path / "with",+ task_names=["a", "b", "c"],+ env_mode="docker",+ model="test-model",+ jobs_dir=jobs_dir,+ run_env={},+ n_attempts=3,+ pass_threshold=0.5,+ timeout_multiplier=1.0,+ override_cpus=None,+ override_memory_mb=None,+ override_storage_mb=None,+ n_concurrent=3,+ )++ assert errors == [+ "opencode with-skill Harbor run failed: a attempt 1: harbor run exited 1",+ "opencode with-skill Harbor run failed: c attempt 1: harbor run exited 1",+ ]+ assert sorted(launched) == [+ "demo-opencode-with-a-attempt001",+ "demo-opencode-with-a-attempt002",+ "demo-opencode-with-b-attempt001",+ "demo-opencode-with-c-attempt001",+ "demo-opencode-with-c-attempt002",+ ]+++def test_stop_on_pass_unexpected_case_error_stops_queued_cases(+ monkeypatch: pytest.MonkeyPatch,+ tmp_path: Path,+) -> None:+ launched: list[str] = []+ merged: list[object] = []++ def fake_run_harbor(**kwargs: object) -> tuple[bool, str]:+ include = kwargs["include_task_names"]+ assert isinstance(include, list)+ launched.append(include[0])+ if include[0] == "a":+ raise KeyError("unexpected launcher failure")+ return True, ""++ monkeypatch.setattr(runner, "_run_harbor", fake_run_harbor)+ monkeypatch.setattr(runner, "_job_passed", lambda *_args, **_kwargs: False)+ monkeypatch.setattr(runner, "_merge_attempt_jobs", lambda *args, **_kwargs: merged.append(args))++ with pytest.raises(KeyError, match="unexpected launcher failure"):+ runner._run_stop_on_pass_variant(+ skill_name="demo",+ agent="opencode",+ variant="with",+ dataset=tmp_path / "with",+ task_names=["a", "b", "c"],+ env_mode="docker",+ model="test-model",+ jobs_dir=tmp_path / "jobs",+ run_env={},+ n_attempts=3,+ pass_threshold=0.5,+ timeout_multiplier=1.0,+ override_cpus=None,+ override_memory_mb=None,+ override_storage_mb=None,+ n_concurrent=1,+ )++ # As in the former serial loop, no case launches after the failure and no+ # partial aggregate is merged.+ assert launched == ["a"]+ assert merged == []diff --git a/tests/test_tier3_public_runtime.py b/tests/test_tier3_public_runtime.pyindex 25ffa657..10c9ce0c 100644--- a/tests/test_tier3_public_runtime.py+++ b/tests/test_tier3_public_runtime.py@@ -2734,10 +2734,10 @@ def test_native_harbor_metadata_entry_id_seam_across_runner_collector_and_dataseassert results["execution_status"] == "succeeded"# stop_on_pass passes physical task directory names to Harbor CLI --include-task-name- # With-skill passes on attempt 1 (1.0 >= 0.50), baseline runs 2 attempts per task (0.25 < 0.50)- assert seen_include_task_names == [- ["physical-case"],- ["zero-case"],+ # With-skill passes on attempt 1 (1.0 >= 0.50), baseline runs 2 attempts per task (0.25 < 0.50).+ # Cases run concurrently within a condition, so only the per-condition launches are ordered.+ assert sorted(seen_include_task_names[:2]) == [["physical-case"], ["zero-case"]]+ assert sorted(seen_include_task_names[2:]) == [["physical-case"],["physical-case"],["zero-case"],