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): keep negative controls out of missed-activation advice (#466)
Narendran Raghavan8ba7f785a76b
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 5692b35d..16192c15 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -410,6 +410,11 @@ All notable changes to SkillEvaluator are documented in this file.use schema 1.1; valid schema 1.0 snapshots retain their original datasets andintegrity checks, with corrected summaries projected without rewriting files.+- Tier 3 improvement recommendations respect each case's expected skill routing:+ passing negative controls no longer inherit activation-loss advice from positive+ cases, while failed negatives retain task, environment, and run-error diagnostics.+ The dataset snapshot is read once per recommendation pass across all cases and agents.+- Tier 2 includes qualifying shell comment blocks at end of file in contextdeduplication. Previously those blocks disappeared unless a blank line orcode followed them, which could hide repeated guidance across shell files.diff --git a/src/skillevaluator/tier3/case_summary.py b/src/skillevaluator/tier3/case_summary.pyindex 4337a8ee..bb5f1419 100644--- a/src/skillevaluator/tier3/case_summary.py+++ b/src/skillevaluator/tier3/case_summary.py@@ -24,6 +24,7 @@ from rich.text import Textfrom skillevaluator.reporting.summary_copy import pass_at_k_summaryfrom skillevaluator.reporting.terminal_styles import AMBERfrom skillevaluator.tier3.attempt_verdict import attempt_verdict, scored_goal_accuracy+from skillevaluator.tier3.eval_core.checks import resolve_should_triggerfrom skillevaluator.tier3.harbor.progress import redact_progress_detail, secret_values_from_environmentfrom skillevaluator.utils.redaction import redact_sensitive_textfrom skillevaluator.utils.secret_redaction import Redactor@@ -874,14 +875,23 @@ def _run_error(trial_dir: Path, run_dir: Path) -> str:def _diagnose_agent_case(- run_dir: Path, agent_name: str, agent: Mapping[str, Any], case_id: str+ run_dir: Path,+ agent_name: str,+ agent: Mapping[str, Any],+ case_id: str,+ *,+ entry: Mapping[str, Any] | None = None,) -> list[dict[str, Any]]:with_case = _cases(agent, "with_skill").get(case_id)with_marks, without_marks = _marks(with_case), _marks(_cases(agent, "without_skill").get(case_id))wp, wn = _attempt_rate(with_marks)bp, bn = _attempt_rate(without_marks)errors = with_marks.count(ERROR)- not_used = _never_activated(agent)+ # Negative controls must avoid the skill; an agent-wide positive miss does not apply to them.+ if entry is None:+ entry = _dataset_entries(run_dir).get(case_id, {})+ should_trigger = resolve_should_trigger(dict(entry))+ not_used = should_trigger is not False and _never_activated(agent)failed_trials = []for attempt in with_case.get("attempts", []) if isinstance(with_case, Mapping) else []:if isinstance(attempt, Mapping) and attempt.get("passed") is not True:@@ -932,7 +942,7 @@ def _diagnose_agent_case(elif finals and all(_ASKS_FOR_INPUT.search(f) for f in finals):kind = "missing input"what = f'the agent stopped to ask for input the case does not provide: "{_short(finals[0], 140)}"'- elif activations and all(a is False for a in activations):+ elif should_trigger is not False and activations and all(a is False for a in activations):kind, what = "skill not used", "the agent never loaded the skill in the failed attempts"if reasons:what += f"; {reasons.most_common(1)[0][0]}"@@ -1160,10 +1170,11 @@ def what_to_fix() -> list[dict[str, Any]]:"""Rank failed test cases across agents by attempts lost and attach one fix each."""agents = {str(k): v for k, v in (result.get("agents") or {}).items() if isinstance(v, Mapping)}+ dataset = _dataset_entries(run_dir)grouped: dict[tuple[str, str], list[dict[str, Any]]] = {}for case_id in _case_ids(agents):for name, agent in agents.items():- for issue in _diagnose_agent_case(run_dir, name, agent, case_id):+ for issue in _diagnose_agent_case(run_dir, name, agent, case_id, entry=dataset.get(case_id, {})):grouped.setdefault((case_id, issue["kind"]), []).append(issue)issues = []for items in grouped.values():@@ -1181,7 +1192,6 @@ def what_to_fix(env_errors=list(dict.fromkeys(e for item in items for e in item["env_errors"])),)issues.append(merged)- dataset = _dataset_entries(run_dir)description = _skill_description(skill_path)for issue in issues:entry = dataset.get(issue["case"], {})diff --git a/tests/test_nvidia_build_bridge.py b/tests/test_nvidia_build_bridge.pyindex fcfd98bb..61ec3bc2 100644--- a/tests/test_nvidia_build_bridge.py+++ b/tests/test_nvidia_build_bridge.py@@ -1133,14 +1133,21 @@ def test_dynamic_bridge_ignores_prebound_old_port_and_checker_authenticates_healtext=True,)deadline = time.monotonic() + 5- while not ready_file.exists() and process.poll() is None and time.monotonic() < deadline:- time.sleep(0.025)+ ready_origin = None+ while process.poll() is None and time.monotonic() < deadline:+ try:+ ready_origin = bridge.check_ready_file(ready_file)+ except (OSError, RuntimeError):+ time.sleep(0.025)+ else:+ breakassert process.poll() is None, process.communicate(timeout=1)- assert ready_file.exists()+ assert ready_origin is not None, "bridge did not pass its authenticated readiness check"ready = json.loads(ready_file.read_text(encoding="utf-8"))origin = ready["origin"]readiness_token = ready["readiness_token"]+ assert origin == ready_originassert origin != "http://127.0.0.1:18080"assert _request("http://127.0.0.1:18080/healthz")[0] == 200assert _request(f"{origin}/healthz")[0] == 403diff --git a/tests/test_tier3_case_summary.py b/tests/test_tier3_case_summary.pyindex 3fe8f45e..b25eb79c 100644--- a/tests/test_tier3_case_summary.py+++ b/tests/test_tier3_case_summary.py@@ -6,6 +6,7 @@import jsonfrom pathlib import Path+import pytestfrom rich.console import Consolefrom skillevaluator.tier3.case_summary import render_case_summary, verdict, what_to_fix@@ -405,6 +406,158 @@ def test_never_activated_scores_do_not_claim_a_skill_effect(tmp_path: Path) -> Nassert "inconclusive" in output+ "negative_routing",+ [{"expected_skill": None}, {"should_trigger": False, "expected_skill": "release-review"}],+)+def test_mixed_activation_miss_does_not_blame_passing_negative(tmp_path: Path, negative_routing: dict) -> None:+ from skillevaluator.tier3.harbor.activation import summarize_skill_activation+ from skillevaluator.tier3.harbor.metrics import DEFAULT_METRICS++ negative = {+ **dict.fromkeys(DEFAULT_METRICS, 1.0),+ "_trial_name": "n0",+ "details": {"skill_execution": {"should_trigger": False, "negative_check": {"passed": True}}},+ }+ positive = {+ **dict.fromkeys(DEFAULT_METRICS, 0.2),+ "_trial_name": "p0",+ "details": {"skill_execution": {"should_trigger": True, "activation": {"passed": False, "score": 0.0}}},+ }+ agent = _agent(+ {"negative": _case(True, prefix="n"), "positive": _case(False, prefix="p")},+ {"negative": _case(True), "positive": _case(False)},+ )+ agent["skill_activation"] = summarize_skill_activation([negative, positive])+ (tmp_path / "dataset_snapshot.json").write_text(+ json.dumps(+ {+ "dataset": [+ {"id": "negative", **negative_routing},+ {"id": "positive", "expected_skill": "release-review"},+ ]+ }+ )+ )+ _trial(tmp_path, "a", "n0", negative)+ _trial(tmp_path, "a", "p0", positive)++ [fix] = what_to_fix({"agents": {"a": agent}}, run_dir=tmp_path, use_llm=False)++ assert (fix["case"], fix["kind"], fix["attempts_lost"]) == ("positive", "skill not used", 1)+ assert "frontmatter description" in fix["action"]+ console = Console(record=True, width=160)+ render_case_summary({"agents": {"a": agent}}, console=console, fixes=[fix])+ advice = console.export_text().split("How to improve", 1)[1]+ assert "positive" in advice and "negative" not in advice++[email protected]("activation_status", ["never_activated", "unknown"])[email protected]("failure_kind", ["skill", "environment", "run error"])+def test_failed_negative_keeps_task_diagnostics(tmp_path: Path, activation_status: str, failure_kind: str) -> None:+ case = _case(missing=1) if failure_kind == "run error" else _case(False)+ agent = _agent({"negative": case}, {})+ agent["skill_activation"] = {"status": activation_status}+ (tmp_path / "dataset_snapshot.json").write_text(+ json.dumps({"dataset": [{"id": "negative", "should_trigger": False, "expected_skill": "release-review"}]})+ )+ if failure_kind == "run error":+ trial = tmp_path / "a" / "with-skill" / "trials" / "negative__attempt1"+ trial.mkdir(parents=True)+ (trial / "failure.json").write_text(json.dumps({"error": {"type": "AgentTimeoutError", "message": "900s"}}))+ else:+ reward = _reward(False, "the answer omitted the requested total")+ reward["details"]["skill_execution"]["should_trigger"] = False+ observation = "ModuleNotFoundError: No module named 'pypdf'" if failure_kind == "environment" else ""+ _trial(tmp_path, "a", "t0", reward, observation)++ [fix] = what_to_fix({"agents": {"a": agent}}, run_dir=tmp_path, use_llm=False)++ assert (fix["case"], fix["kind"], fix["attempts_lost"]) == ("negative", failure_kind, 1)+ assert "frontmatter description" not in fix["action"]+ if failure_kind == "environment":+ assert "No module named 'pypdf'" in fix["what"]+ elif failure_kind == "run error":+ assert "AgentTimeoutError" in fix["what"]+ else:+ assert "omitted the requested total" in fix["what"]++[email protected]("snapshot", [None, "{broken", '{"dataset": [{"id": "c"}]}'])[email protected]("activation_status", ["never_activated", "unknown"])+def test_unlabeled_snapshot_preserves_legacy_activation_diagnosis(+ tmp_path: Path, snapshot: str | None, activation_status: str+) -> None:+ agent = _agent({"c": _case(True)}, {})+ agent["skill_activation"] = {"status": activation_status}+ if snapshot is not None:+ (tmp_path / "dataset_snapshot.json").write_text(snapshot)++ fixes = what_to_fix({"agents": {"a": agent}}, run_dir=tmp_path, use_llm=False)++ if activation_status == "never_activated":+ [fix] = fixes+ assert (fix["case"], fix["kind"], fix["attempts_lost"]) == ("c", "skill not used", 1)+ else:+ assert fixes == []++[email protected]("case_count", [20, 100])[email protected]("agent_count", [1, 2])[email protected]("scenario", ["passing", "mixed negative", "empty snapshot"])+def test_case_advice_reads_snapshot_once(+ tmp_path: Path, monkeypatch: pytest.MonkeyPatch, case_count: int, agent_count: int, scenario: str+) -> None:+ from skillevaluator.utils.secure_fs import SecureRoot++ case_ids = [f"case-{i:03d}" for i in range(case_count)]+ entries = [+ {"id": case_id, "should_trigger": bool(i % 2), "expected_skill": "release-review"}+ for i, case_id in enumerate(case_ids)+ ]+ (tmp_path / "dataset_snapshot.json").write_text(+ json.dumps({"dataset": [] if scenario == "empty snapshot" else entries})+ )+ cases = {case_id: _case(scenario != "mixed negative" or i % 2 == 0) for i, case_id in enumerate(case_ids)}+ agents = {f"agent-{i}": _agent(cases, {}) for i in range(agent_count)}+ for agent in agents.values():+ agent["skill_activation"] = {"status": "unknown" if scenario == "passing" else "never_activated"}+ snapshot_reads = 0+ read_bytes = SecureRoot.read_bytes++ def count_reads(self, path, *args, **kwargs):+ nonlocal snapshot_reads+ if str(path) == "dataset_snapshot.json":+ snapshot_reads += 1+ return read_bytes(self, path, *args, **kwargs)++ monkeypatch.setattr(SecureRoot, "read_bytes", count_reads)++ fixes = what_to_fix({"agents": agents}, run_dir=tmp_path, use_llm=False)++ if scenario == "passing":+ assert fixes == []+ else:+ [fix] = fixes+ expected_cases = case_ids[1::2] if scenario == "mixed negative" else case_ids+ assert fix["cases"] == expected_cases+ assert fix["kind"] == "skill not used"+ assert fix["attempts_lost"] == len(expected_cases) * agent_count+ assert snapshot_reads == 1+++def test_direct_case_diagnosis_still_loads_snapshot(tmp_path: Path) -> None:+ from skillevaluator.tier3.case_summary import _diagnose_agent_case++ (tmp_path / "dataset_snapshot.json").write_text(+ json.dumps({"dataset": [{"id": "negative", "should_trigger": False, "expected_skill": "release-review"}]})+ )+ agent = _agent({"negative": _case(True)}, {})+ agent["skill_activation"] = {"status": "never_activated"}++ assert _diagnose_agent_case(tmp_path, "a", agent, "negative") == []++def test_truncated_attempts_cannot_produce_a_complete_effect_or_clean_bill(tmp_path: Path) -> None:case = {**_case(True), "attempt_details_total": 2, "attempt_details_truncated": True}agent = _agent({"c": case}, {"c": _case(False, False)})