Skip to content

fix(agent): a line of warnings or skips alone is not a test run - #4173

Merged
kovtcharov-amd merged 1 commit into
amd:mainfrom
kovtcharov:claude/soft-counts-not-a-test-run
Sep 25, 2026
Merged

kovtcharov-amd merged 1 commit into
amd:mainfrom
kovtcharov:claude/soft-counts-not-a-test-run

Conversation

@kovtcharov

Copy link
Copy Markdown
Contributor

The agent is asked to run the tests when it changed code and did not check it. That reminder is cancelled by anything in the turn that looks like a test-runner summary — and the check accepted a line made only of soft counts, like 2 warnings or 12 skipped. A compiler, a downloader or a packager printing one of those convinced the turn its tests had already run, so the reminder never appeared and an unverified change was reported as done.

Soft counts now need pytest's own rule or timing tail to qualify. A real outcome, no tests ran, and unittest's Ran N tests still stand on their own, so a genuine skips-only run is unaffected.

Test plan

  • pytest tests/unit/agents/test_answer_quality_checks.py tests/unit/agents/test_verification_scope.py — 200 passed.
  • New table covers both directions: 2 warnings / 12 skipped / Found 3 errors are not a run; ===== 2 warnings =====, 3 skipped in 0.01s, no tests ran and Ran 4 tests in 0.003s still are.

🤖 Generated with Claude Code

The "did you run the tests?" reminder is cancelled by any output that looks like
a runner summary, and the pattern accepted a line made only of soft counts —
`2 warnings`, `12 skipped`. A compiler, a downloader or a packager printing one
of those convinced the turn its tests had run, so the reminder never appeared.

Soft counts now need pytest's own rule or timing tail to qualify. A real
outcome, `no tests ran`, and unittest's `Ran N tests` still stand alone, so a
genuine skips-only run is unaffected.

Co-Authored-By: Claude Opus 5 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

This tightens the "did you actually run the tests?" check so that a bare line like 2 warnings or 12 skipped — which compilers, downloaders and packagers print all the time — no longer convinces the agent that a test run happened. Soft counts now need pytest's own ===== rule or in 0.12s tail to qualify; real outcomes, no tests ran and unittest's Ran N tests still stand alone. The logic is correct and the new test table covers both directions.

One thing worth a second look before merge: the fix stops short of the most common offender. A line reading just 3 errors is still accepted as proof that tests ran, even though a linter or compiler is far more likely to have printed it than pytest — pytest always decorates its own summary with the rule or the timing. The PR's own test table hints at this worry (it checks Found 3 errors), but that string is rejected by the older outer pattern, so it never exercises the new gate. Treating error counts the same way as warnings and skips would close the remaining hole at no cost to genuine runs.

Nothing here is blocking: this is strictly better than what's on main, touches no public API, CLI or UI surface, and the existing recognition cases are unaffected.

Real-world evidence

N/A — internal helper change with no CLI, API, MCP or Agent UI surface; no evidence-bundle.md was produced for this run. I could not execute the suite here (no pytest in the review environment), so the behavioural claims below come from re-executing the changed regexes and predicate standalone against a spread of inputs, not from a pytest run. The PR description reports 200 passing tests locally.

🔍 Technical details

Issues

🟢 A bare N errors line still passes as a test run (src/gaia/agents/base/verification.py:534)

errors sits in _PYTEST_HARD_OUTCOME_RE, so it bypasses the new decoration requirement. Re-running the predicate standalone:

'3 errors'   -> True
'2 errors'   -> True
'0 errors'   -> True
'12 skipped' -> False
'2 warnings' -> False

pytest never emits a bare N errors line — its summary always carries the = rule or in 0.31s, both of which _PYTEST_DECORATION_RE already accepts. So demoting errors to a soft count costs no real run and closes the same false-positive class the PR is fixing. It also makes the #: comment above the constant true as written ("counts only a test runner reports"), which it currently isn't for errors.

_PYTEST_HARD_OUTCOME_RE = re.compile(r"\d+ (?:passed|failed|xfailed|xpassed)", re.I)

No existing case regresses: test_test_summaries_recognised has no error-only input, and 2 errors in 0.31s / ===== 2 errors ===== still pass via the decoration branch.

🟢 ("Found 3 errors", False) doesn't exercise the change (tests/unit/agents/test_answer_quality_checks.py:304)

That string is filtered by the pre-existing _TEST_SUMMARY_RE (it doesn't start with a count), so finditer yields nothing and the new gate never runs. Swapping in the form that actually reaches the new code documents the intended boundary:

        ("3 errors", False),

(Pair this with the constant change above — as-is it asserts current behaviour inverted.)

🟢 Test placement and redundant import (tests/unit/agents/test_answer_quality_checks.py:297-317)

The new parametrized test sits at module level while its siblings (test_test_summaries_recognised, test_non_summaries_ignored) live inside TestVerifyAfterChangeHelpers, and it re-imports has_test_run_summary locally although the module already imports it at line 21. Moving it into the class and dropping the local import keeps the file's one-place-for-this-helper structure.

Strengths

  • The regex split is the right shape: _TEST_SUMMARY_RE keeps deciding what looks like a summary line, and the new pair decides whether that line was machine-written. No rewrite of the harder-to-reason-about outer pattern.
  • The parametrized table asserts both directions on one axis, including the three decorated forms (===== rule, timing tail, unittest) that must keep working — that's what makes a future tightening safe to attempt.
  • Docstring and #: comments state the invariant rather than the history, matching the repo's comment rule, and the change adds no public-surface or behavioural risk outside this one predicate.

@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Sep 25, 2026
Merged via the queue into amd:main with commit af2e70c Sep 25, 2026
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants