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): score unrecovered failures and align recovery verdicts (#217)

priyadarshnisundararajan82094b4f7eea
diff --git a/src/skillevaluator/tier3/eval_core/checks.py b/src/skillevaluator/tier3/eval_core/checks.py
index 01938d04..8460acee 100644
--- a/src/skillevaluator/tier3/eval_core/checks.py
+++ b/src/skillevaluator/tier3/eval_core/checks.py
@@ -5287,6 +5287,7 @@ def check_error_recovery(
return any(kw in obs_lower for kw in skill_fault_keywords)
corrections: list[dict[str, Any]] = []
+ failures: list[dict[str, Any]] = []
seen_fail_indices: set[int] = set()
for i, (orig_idx, call) in enumerate(exec_calls):
@@ -5297,12 +5298,22 @@ def check_error_recovery(
cmd = _cmd_text(call)
obs = str(call.get("observation", ""))
+ fault = "skill" if _is_skill_fault(obs) else "agent"
+ # Record every observed failure, whether or not it is later recovered.
+ # Previously only recovered failures (corrections) were tracked, so an
+ # unrecovered failure was silently scored as first-attempt clean.
+ failure: dict[str, Any] = {
+ "failed_cmd": cmd[:200],
+ "error": obs[:300],
+ "fault": fault,
+ "recovered": False,
+ }
+ failures.append(failure)
for j in range(i + 1, min(i + 6, len(exec_calls))):
retry_idx, retry_call = exec_calls[j]
retry_cmd = _cmd_text(retry_call)
if _commands_similar(cmd, retry_cmd) and not _is_failure(retry_call):
- fault = "skill" if _is_skill_fault(obs) else "agent"
corrections.append(
{
"failed_cmd": cmd[:200],
@@ -5312,16 +5323,22 @@ def check_error_recovery(
"steps_to_fix": retry_idx - orig_idx,
}
)
+ failure["recovered"] = True
seen_fail_indices.add(orig_idx)
break
- first_attempt_clean = len(corrections) == 0
+ first_attempt_clean = len(failures) == 0
skill_faults = sum(1 for c in corrections if c["fault"] == "skill")
agent_faults = sum(1 for c in corrections if c["fault"] == "agent")
+ unrecovered_failures = [f for f in failures if not f["recovered"]]
if first_attempt_clean:
score = 1.0
reason = "All commands succeeded on first attempt"
+ elif unrecovered_failures:
+ score = 0.0
+ unrecovered_cmds = ", ".join(f["failed_cmd"][:60] for f in unrecovered_failures[:3])
+ reason = f"{len(unrecovered_failures)} unrecovered failure(s): {unrecovered_cmds}"
elif skill_faults > 0:
score = max(0.0, 1.0 - (skill_faults * 0.25))
reason = f"{skill_faults} skill defect(s), {agent_faults} agent error(s)"
@@ -5335,6 +5352,8 @@ def check_error_recovery(
"reason": reason,
"first_attempt_clean": first_attempt_clean,
"corrections": corrections,
+ "failures": failures,
+ "unrecovered_failures": unrecovered_failures,
"skill_faults": skill_faults,
"agent_faults": agent_faults,
}
diff --git a/src/skillevaluator/tier3/harbor/templates/eval.py b/src/skillevaluator/tier3/harbor/templates/eval.py
index 69360f1a..00d67cc2 100644
--- a/src/skillevaluator/tier3/harbor/templates/eval.py
+++ b/src/skillevaluator/tier3/harbor/templates/eval.py
@@ -8082,6 +8082,7 @@ def check_error_recovery(tool_calls, expected_script=None):
return b1 == b2 or b1 in c2 or b2 in c1
corrections = []
+ failures = []
seen = set()
for i, (orig_idx, call) in enumerate(exec_calls):
@@ -8089,11 +8090,21 @@ def check_error_recovery(tool_calls, expected_script=None):
continue
cmd = _cmd_text(call)
obs = str(call.get("observation", ""))
+ fault = "skill" if any(k in obs.lower() for k in skill_fault_kw) else "agent"
+ # Record every observed failure, whether or not it is later recovered.
+ # Previously only recovered failures (corrections) were tracked, so an
+ # unrecovered failure was silently scored as first-attempt clean.
+ failure = {
+ "failed_cmd": cmd[:200],
+ "error": obs[:300],
+ "fault": fault,
+ "recovered": False,
+ }
+ failures.append(failure)
for j in range(i + 1, min(i + 6, len(exec_calls))):
retry_idx, retry_call = exec_calls[j]
retry_cmd = _cmd_text(retry_call)
if _cmds_similar(cmd, retry_cmd) and not _is_failure(retry_call):
- fault = "skill" if any(k in obs.lower() for k in skill_fault_kw) else "agent"
corrections.append(
{
"failed_cmd": cmd[:200],
@@ -8103,15 +8114,21 @@ def check_error_recovery(tool_calls, expected_script=None):
"steps_to_fix": retry_idx - orig_idx,
}
)
+ failure["recovered"] = True
seen.add(orig_idx)
break
- first_attempt_clean = len(corrections) == 0
+ first_attempt_clean = len(failures) == 0
skill_faults = sum(1 for c in corrections if c["fault"] == "skill")
agent_faults = sum(1 for c in corrections if c["fault"] == "agent")
+ unrecovered_failures = [f for f in failures if not f["recovered"]]
if first_attempt_clean:
score, reason = 1.0, "All commands succeeded on first attempt"
+ elif unrecovered_failures:
+ score = 0.0
+ unrecovered_cmds = ", ".join(f["failed_cmd"][:60] for f in unrecovered_failures[:3])
+ reason = f"{len(unrecovered_failures)} unrecovered failure(s): {unrecovered_cmds}"
elif skill_faults > 0:
score = max(0.0, 1.0 - (skill_faults * 0.25))
reason = f"{skill_faults} skill defect(s), {agent_faults} agent error(s)"
@@ -8125,6 +8142,8 @@ def check_error_recovery(tool_calls, expected_script=None):
"reason": reason,
"first_attempt_clean": first_attempt_clean,
"corrections": corrections,
+ "failures": failures,
+ "unrecovered_failures": unrecovered_failures,
"skill_faults": skill_faults,
"agent_faults": agent_faults,
}
diff --git a/tests/tier3/test_error_recovery.py b/tests/tier3/test_error_recovery.py
new file mode 100644
index 00000000..f24dbe89
--- /dev/null
+++ b/tests/tier3/test_error_recovery.py
@@ -0,0 +1,79 @@
+# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0
+
+"""Tests for check_error_recovery unrecovered-failure scoring (issue #149).
+
+An observed command failure that is never followed by a successful similar
+command must NOT be scored as first-attempt clean.
+"""
+
+from __future__ import annotations
+
+from skillevaluator.tier3.eval_core.checks import check_error_recovery
+
+
+def _call(cmd: str, observation: str) -> dict:
+ return {"action": "bash", "action_input": {"command": cmd}, "observation": observation}
+
+
+def test_failure_with_no_retry_is_not_first_attempt_clean():
+ """A failure that is never retried must not score 1.0 / passed-clean."""
+ result = check_error_recovery(
+ [_call("pytest tests/test_api.py -x", "ERROR: test_create_user failed\nexit code 1")]
+ )
+ assert result["first_attempt_clean"] is False
+ assert result["score"] == 0.0
+ assert len(result["unrecovered_failures"]) == 1
+ assert result["unrecovered_failures"][0]["failed_cmd"] == "pytest tests/test_api.py -x"
+ assert result["unrecovered_failures"][0]["recovered"] is False
+ assert "1 unrecovered failure" in result["reason"]
+ assert "pytest tests/test_api.py -x" in result["reason"]
+
+
+def test_failed_retries_are_not_first_attempt_clean():
+ """Repeated failures of a similar command are all recorded as unrecovered."""
+ result = check_error_recovery(
+ [
+ _call("pytest tests/test_api.py -x", "ERROR: test_create_user failed\nexit code 1"),
+ _call("pytest tests/test_api.py -x -v", "ERROR: test_create_user failed\nexit code 1"),
+ ]
+ )
+ assert result["first_attempt_clean"] is False
+ assert result["score"] == 0.0
+ assert len(result["failures"]) == 2
+ assert len(result["unrecovered_failures"]) == 2
+ assert result["corrections"] == []
+
+
+def test_recovered_failure_behavior_unchanged():
+ """A failure followed by a successful similar command keeps the old scoring."""
+ result = check_error_recovery(
+ [
+ _call("pytest tests/test_api.py", "pytest: error: unrecognized arguments: --bogus\nexit code 2"),
+ _call("pytest tests/test_api.py -q", "12 passed"),
+ ]
+ )
+ assert result["first_attempt_clean"] is False
+ assert result["unrecovered_failures"] == []
+ assert len(result["corrections"]) == 1
+ assert result["corrections"][0]["failed_cmd"] == "pytest tests/test_api.py"
+ assert result["corrections"][0]["retry_cmd"] == "pytest tests/test_api.py -q"
+ # Unchanged pre-existing scoring: one corrected agent fault -> 0.9, passed.
+ assert result["score"] == 0.9
+ assert result["passed"] is True
+
+
+def test_unrecovered_failure_after_earlier_success():
+ """An unrecovered failure later in the log still breaks first_attempt_clean."""
+ result = check_error_recovery(
+ [
+ _call("ls -la", "total 4\ndrwxr-xr-x 2 root root 4096 ."),
+ _call("make build", "gcc: error: missing.c: No such file or directory"),
+ ]
+ )
+ assert result["first_attempt_clean"] is False
+ assert result["score"] == 0.0
+ assert len(result["failures"]) == 1
+ assert len(result["unrecovered_failures"]) == 1
+ assert result["unrecovered_failures"][0]["fault"] == "skill"
+ assert "make build" in result["reason"]