Skip to content

fix(tier3): score unrecovered command failures instead of first-attempt clean - #151

Closed
priyadarshnisundararajan wants to merge 9 commits into
NVIDIA:mainfrom
priyadarshnisundararajan:fix/unrecovered-failure-scoring-149
Closed

priyadarshnisundararajan wants to merge 9 commits into
NVIDIA:mainfrom
priyadarshnisundararajan:fix/unrecovered-failure-scoring-149

Conversation

@priyadarshnisundararajan

Copy link
Copy Markdown
Contributor

fix(tier3): score unrecovered command failures instead of first-attempt clean

Fixes #149.

The bug

check_error_recovery() only ever recorded a failure in corrections when a
later similar command succeeded. Any failure that was never retried (or whose
retries also failed) was never recorded at all, so the final scoring read:

first_attempt_clean = len(corrections) == 0   # True even with unrecovered failures!

…which meant a run with one or more unrecovered failures was scored
score = 1.0, "passed": True, "All commands succeeded on first attempt" —
as if the run were perfectly clean.

Repro: a single tool call {action: "bash", action_input: {command: "pytest -x"}, observation: "ERROR: test_create_user failed\nexit code 1"} returned
first_attempt_clean: True, score: 1.0 before this fix.

The fix

  • Track every observed failure in a new failures list (appended in the
    _is_failure() branch regardless of recovery), each entry carrying
    failed_cmd, error, fault (skill vs agent), and a recovered flag that
    is set when a successful similar command is later found.
  • first_attempt_clean is now len(failures) == 0 — the presence of any
    failure breaks it, not just the presence of a recovered one.
  • New scoring branch: any unrecovered failure scores 0.0 with a reason naming
    the offending commands, e.g. "2 unrecovered failure(s): pytest -x, make build".
  • passed semantics are deliberately left untouched for maintainers to decide.
  • New result keys (failures, unrecovered_failures) are purely additive, so
    existing consumers (report.py, tier3_report.py, collector.py) are
    unaffected.

Applied identically to both copies of the function:

  • src/skillevaluator/tier3/eval_core/checks.py
  • src/skillevaluator/tier3/harbor/templates/eval.py (harbor template mirror)

Tests

Added tests/tier3/test_error_recovery.py with four cases using synthetic
tool_calls lists (no fixtures, no network, no GPU):

  1. Failure with no retry → first_attempt_clean is False, score == 0.0,
    one entry in unrecovered_failures, reason names the command.
  2. Two failed retries of a similar command → both recorded as unrecovered,
    corrections stays empty, score 0.0.
  3. Failure followed by a successful similar command → behavior unchanged
    (corrections has one entry, unrecovered_failures empty, score 0.9,
    passed is True).
  4. Unrecovered failure after an earlier successful command → not clean,
    score 0.0, fault correctly attributed (skill fault for No such file
    errors).

Handover note

The issue reporter mentioned they were happy to open a PR themselves. If
they'd rather take this on, I'm happy to close this PR in favor of theirs —
just say the word.

@mavericksea-ai

Copy link
Copy Markdown
Contributor

Thanks for picking this up. I ran my original reproduction for #149 against this branch (99eced7) and against main (5c73273) for comparison, using Python 3.13 and Harbor 0.13.2:

  • main: the failing run.py call (exit 1, no report) still gets score 1.0 / "All commands succeeded on first attempt" from both checks.check_error_recovery and the Harbor template copy. skill_execution is 1.0, and the case passes pass@1 at the default 0.5 threshold (best score 0.5), even though accuracy, goal_accuracy and behavior_check are all 0.
  • this branch: both copies return score 0.0, first_attempt_clean: False, one unrecovered failure. skill_execution drops to 0.75, the overall score to 0.4583, and pass@1 to 0/1, both through _pass_summary and through collect_harbor_results.

My regression tests (host + harbor-verifier) go from 2 failed to all passing here. Your tests/tier3/test_error_recovery.py passes, and so do the rest of tests/tier3 (1216 passed).

One gap: none of the four cases covers a final unrecovered failure after an earlier successful recovery. test_unrecovered_failure_after_earlier_success follows a successful ls, not a corrected failure. On main that mixed pattern scores 0.9 ("1 agent error(s), no skill defects") because the recovered correction hides the later unrecovered failure. This branch correctly gives 0.0. Also, the new tests only exercise the checks.py copy, not harbor/templates/eval.py. Happy to push a case like this, parametrized over both implementations:

@pytest.mark.parametrize("checker", [check_error_recovery, eval_template.check_error_recovery], ids=["host", "harbor-verifier"])
def test_unrecovered_failure_after_earlier_recovery(checker):
    result = checker([
        _call("pytest tests/test_api.py", "pytest: error: unrecognized arguments: --bogus\nexit code 2"),
        _call("pytest tests/test_api.py -q", "12 passed"),
        _call("make build", "gcc: error: missing.c: No such file or directory"),
    ])
    assert len(result["corrections"]) == 1
    assert result["first_attempt_clean"] is False
    assert [f["failed_cmd"] for f in result["unrecovered_failures"]] == ["make build"]
    assert result["score"] == 0.0

It fails on main for both implementations and passes on this branch.

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@priyadarshnisundararajan The unrecovered-failure score now changes as intended, but the boolean verdict/reporting remains inconsistent, and successful command output can receive the new zero penalty. Please address the inline findings and cover both the host checker and bundled verifier.

Local validation: 352 focused error-recovery/tool-normalization tests passed; Ruff passed. Separate host/template reproductions confirmed the two gaps against the base branch.

CI: 16 checks pass; DCO fails because commit 99eced70c3b21deff07abb2f541fbbcd91f02881 lacks a Signed-off-by trailer. Please add your sign-off as well.

Comment on lines +1998 to +2001
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}"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Make the verdict and fault counts reflect unrecovered failures

For a single make build returning gcc: error: missing.c: No such file or directory, this branch returns score=0 but the result still has passed=True and skill_faults=0, because the counters only examine recovered corrections. The report's _collect_fail_reasons("skill_execution", ...) consequently returns no failure reasons. Count unrecovered faults and make the verdict reflect them while preserving the intended behavior for recovered agent mistakes. Mirror the fix in the bundled verifier and test the report failure-reason path.

Comment on lines +1965 to +1971
failure: dict[str, Any] = {
"failed_cmd": cmd[:200],
"error": obs[:300],
"fault": fault,
"recovered": False,
}
failures.append(failure)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Confirm a command actually failed before applying the new penalty

A successful command whose observation is Process exited with code 0\nFinal output:\n0 errors scores 1.0 on the base branch but 0.0 here, in both implementations. _is_failure matches the word error, and recording every such match now turns benign output into an unrecovered failure. Prefer explicit execution outcomes where available and constrain the text fallback; add successful-output and nonzero-exit regressions. Keep the host/template detectors aligned too: a single ConnectionRefused or timeout observation currently scores 0.0 in the host but 1.0 in the bundled verifier.

@rng1995
rng1995 force-pushed the fix/unrecovered-failure-scoring-149 branch from 99eced7 to 50cadf4 Compare September 23, 2026 02:38
@rng1995

rng1995 commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

@priyadarshnisundararajan - Gentle ping to fix the review comments posted by me in order to merge the PR. Thanks for your patience and contribution to SkillEvaluator!

@mavericksea-ai

Copy link
Copy Markdown
Contributor

Thanks @priyadarshnisundararajan for the initial fix and the handover offer. I’d be happy to take this forward and address the remaining review findings, including verdict/reporting consistency, failure detection, and regression coverage across both implementations. Would you and @rng1995 prefer a replacement PR referencing this work, or a contribution to the existing branch?

@rng1995

rng1995 commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator

@mavericksea-ai Thanks for offering. Please go with a replacement PR. You don't have push access to Priyadarshni's fork, and they already offered the handover, so that's the quickest path.

  • Branch from current main and cherry-pick 50cadf4. It keeps Priyadarshni as author and already has a sign-off. Please sign off your own commits too (DCO check).
  • Put Fixes #149 and Supersedes #151 in the description. I'll close fix(tier3): score unrecovered command failures instead of first-attempt clean #151 once yours is open.
  • Scope is the two open inline findings, applied to both eval_core/checks.py and harbor/templates/eval.py:
    1. Verdict and fault counts: an unrecovered skill fault should set passed=False, count toward skill_faults, and show up in _collect_fail_reasons("skill_execution", ...). Agent mistakes that were recovered should keep their current behavior.
    2. Failure detection: don't penalize successful output that just contains the word "error" (e.g. Process exited with code 0\nFinal output:\n0 errors). Use the explicit exit status when it's available, tighten the text fallback, and make the host and bundled-verifier detectors agree (a lone ConnectionRefused or timeout currently scores 0.0 in the host but 1.0 in the verifier).
  • Tests: parametrize over both implementations. Include your recovered-then-unrecovered case, a successful-output case, a nonzero-exit case, and the report fail-reason path.

@priyadarshnisundararajan Thanks for the initial fix! If you'd rather keep working on this branch, just say so here.

@rng1995

rng1995 commented Oct 21, 2026

Copy link
Copy Markdown
Collaborator

Closing in favor of #217, which @mavericksea-ai opened as the replacement. It keeps @priyadarshnisundararajan's commit 50cadf4 with the original authorship and sign-off, and it fixes both open findings from this PR in the host checker and in the bundled verifier. Review continues on #217. Thanks to both of you.

@rng1995 rng1995 closed this Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Unrecovered command failures are scored as first-attempt clean

3 participants