Skip to content

fix(agent): count a trimmed rerun of the same test command as the rerun - #7319

Merged
kovtcharov-amd merged 4 commits into
amd:mainfrom
kovtcharov:kalin/rc18-verification-rerun
Nov 12, 2026
Merged

kovtcharov-amd merged 4 commits into
amd:mainfrom
kovtcharov:kalin/rc18-verification-rerun

Conversation

@kovtcharov

Copy link
Copy Markdown
Contributor

After fixing a failing test, an answer that said "All 5 tests pass now"
still ended "I haven't confirmed this works - 1 of 2 pytest runs didn't
pass", because the passing rerun cut its output with "| tail -20" where the
failing run used "| tail -40". Now the rerun replaces the earlier run and
no note is added.
Refs #7293

Draft until it is replayed in the app: this changes a check or tool result the agent reads.

Test plan

  • python -m pytest tests/unit/agents/test_verification_scope.py (214 pass; 7 new tests fail on main)
  • Replay on a cloud model: fix a failing test suite and re-run it with a slightly different command
  • Eval categories to watch: gaia_resilience, coding and test-fix categories

After fixing a failing test, an answer that said "All 5 tests pass now"
still ended "I haven't confirmed this works - 1 of 2 pytest runs didn't
pass", because the passing rerun cut its output with "| tail -20" where the
failing run used "| tail -40". Now the rerun replaces the earlier run and
no note is added.

A check is grouped by its command, so the two commands were two checks and
the pre-fix failure was never superseded. The command's trailing output
trimming (tail, head, tee, Select-Object -First/-Last, Out-String,
redirections such as 2>&1 and > file) no longer counts toward which check
it is; anything that changes what runs still does.

Closes #ISSUE
@github-actions github-actions Bot added tests Test changes agents labels Nov 12, 2026
@kovtcharov
kovtcharov marked this pull request as ready for review November 12, 2026 06:08
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

When the agent fixes a failing test and reruns it, the closing note no longer says "1 of 2 pytest runs didn't pass" just because the rerun cut its output differently (for example | tail -20 where the first run used | tail -40). The change is narrow, well tested in both directions, and can't let a still-failing suite pass as verified: the shell tool already fails a pipeline when any stage fails, so pytest | tail keeps pytest's failure.

One small edge to tighten: a > inside a quoted argument is read as a redirect, so two different commands can be counted as the same check. It's rare and doesn't block merge.

Real-world evidence

N/A: no evidence bundle was produced for this run. The change is in the agent's internal verification bookkeeping, and the PR's own test plan still has the in-app replay unchecked (the PR says it stays a draft until then). This verdict rests on static review and the PR's unit tests. I couldn't run the tests here because the runner has no gaia/pytest environment, so I checked the regex on its own.

🔍 Technical details

Issues

🟢 > inside quotes is treated as a redirect (src/gaia/agents/base/verification.py:196): the redirect branch \s*\d?>>?… needs no whitespace before it, so it also matches inside a quoted argument. I checked the regex on its own:

  • pytest -k "a>b" → pytest -k "a
  • python -c "assert f()>0" and python -c "assert f()>5" → both python -c "assert f(), so they collapse to one target and a later pass of one hides a failure of the other.

Real redirects are almost always preceded by a space, so requiring one closes most of this:

    r"|\s+\d?>>?\s*(?:&\d|[^\s|;&<>]+))\s*$",

(pytest -q>out.txt with no space would stop being normalised. That's acceptable, because it only keeps the old, stricter grouping.)

Checked, no issue

  • Failure masking: in _run_pipeline (shell_tools.py:2590), the pipeline's exit code is the rightmost failing stage, so a pytest -q | tail -5 rerun of a still-failing suite stays failed and can't overwrite the earlier failure into "verified".
  • Sibling caller: flagship_tasks.py:557 keys latest on the same verification_check_target, so the eval's "tests passed" check picks up the same normalisation. That is consistent, not a drift.
  • Filters that change what ran stay distinct: grep, && / ; chains, and -k are left alone, and the negative parametrized cases pin this.
  • Docs: nothing documents the grouping key, so there was no drift to check.

Strengths

  • The tests run in both directions: trimming variants must collapse, and real scope changes (-k, a later command, grep) must not. A loop-level test reproduces the rc18 note end to end.
  • The loop stops at a fixed point and never reduces a command to an empty string.

A passing "pytest ... | tail -20" still did not replace the failing
"pytest ... | tail -40" before it, so a fixed test kept the closing note
"1 of 2 pytest runs didn't pass". Now it does, for commands run through the
shell tool.

The shell tool declares its own check, and that check's target was the raw
command, so the earlier fix (which only normalised the fallback for tools
that declare nothing) never ran for it. Both paths now share one
command_check_target(). A new test runs real pytest through
run_shell_command twice and reads the resulting note.
kovtcharov-amd and others added 2 commits November 11, 2026 22:36
A ">" inside a quoted argument, as in python -c "assert f()>0", was read
as a redirect, so two different checks could share one target and a later
pass of one would hide a failure of the other. A redirect now needs the
space before it that real ones carry. Adds the quoted cases and a trimmed
rerun that still fails, which must stay unverified.
…o kalin/rc18-verification-rerun-r2

# Conflicts:
#	src/gaia/agents/base/verification.py
@kovtcharov

Copy link
Copy Markdown
Contributor Author

Round 2 of the rc18 test still saw "1 of 2 pytest runs didn't pass" after a fixed test, when the two runs went through the shell tool with | tail -40 and | tail -20. The new commit applies the same "trimmed rerun is the same check" rule to the check the shell tool reports itself, which the first commit missed.

🔍 Technical details
  • check_from_command built its target from the raw command, and verification_record takes a declared target as is, so the normalising in verification_check_target never ran for run_shell_command.
  • Both paths now share command_check_target() in checks.py.
  • New test runs real pytest through run_shell_command twice (fail, then pass with different trimming) and asserts no note; a narrower rerun still leaves the failed suite reported.

@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

Took the review's quoted-`>` point: two different `python -c` checks no longer collapse into one, so a later pass of one can't hide a failure of the other.

🔍 Technical details
  • The redirect branch of _OUTPUT_TRIM_RE now needs whitespace before the >, as suggested. pytest -q>out.txt with no space keeps the old, stricter grouping.
  • New cases: python -c "assert f()>0" vs >5 and pytest -k "a>b" vs "a>c" stay distinct; a trimmed rerun that still fails stays unverified. All three fail on the previous head.
  • test_verification_scope.py: 217 pass (one -n parallel flake that passes alone).

@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Nov 12, 2026
Merged via the queue into amd:main with commit 20bd476 Nov 12, 2026
37 of 43 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the kalin/rc18-verification-rerun branch November 12, 2026 08:01
kovtcharov-amd added a commit to kovtcharov/gaia that referenced this pull request Nov 12, 2026
amd#7276, amd#7277, amd#7278, amd#7248, amd#7319 and amd#7322 merged, so their seven strict
expected failures now pass and would turn the unit job red. The two left
(amd#7321 open, amd#7326 unfixed) still fail as recorded.

The stand-in console now returns an empty-string default the way the real
transport does, instead of reading it as no default.
kovtcharov-amd added a commit to kovtcharov/gaia that referenced this pull request Nov 12, 2026
The rc18 release test found seven cases where GAIA's own answer checks
got a turn wrong: a correct read-only answer ended with "I couldn't
confirm all of this", a plan the user asked for was thrown away, an
unanswered question became the user's answer. Each check had unit tests
and none caught these, because every case needed the request, the tool
results and the answer together. This adds a corpus of recorded turns
and one test that replays each through the real loop with no model, so a
misfire seen once in a release test becomes a file that guards it for
good.

Seeded with 16 turns: a "must not fire" and a "must fire" case for each
of F8, F10, F11, F12, F36, F80 and F81. Adding a case is adding a JSON
file; the README beside the cases says how to make one from a
transcript.

**Bugs it found** (a bug still open is a strict expected failure, so the
fix has to delete the marker):

| Case | Issue | Fix |
|---|---|---|
| Read-only answer that says "I wrote no file" gets the unsaved-file
note | amd#7178 | amd#7276 (merged, marker removed) |
| Answer quoting an edit's own backup path gets the note | amd#7179 | amd#7277
(merged, marker removed) |
| A plan the user asked for is sent back as unfinished work | amd#7180 |
amd#7278 (merged, marker removed) |
| "Do NOT run anything" is answered with GAIA's own "look first" message
| amd#7181 | amd#7278 (merged, marker removed) |
| A native tool call is shown as answer text | amd#7205 | amd#7248 (merged,
marker removed) |
| A fixed test's rerun with a different `tail` reads as an unpassed
check | amd#7293 | amd#7319 (merged, marker removed) |
| A file a script wrote beside its input is called unwritten | amd#7293 |
amd#7321 (merged, marker removed) |
| Silence after a question is handed to the model as the user's answer |
amd#7294 | amd#7322 (merged, marker removed) |
| **New:** "I also saved it to X" with no write gets no note | amd#7326 |
none yet |

I replayed the corpus on each fix branch: every case passes there, so
the markers come off as those PRs land.

## Test plan

- [ ] `python -m pytest tests/unit/agents/test_answer_check_corpus.py
-q` reports 17 passed, 1 xfailed
- [ ] Delete the `"xfail"` line from any case and the test fails with
the note or nudge the tester saw
- [ ] Runs in the existing unit job (`test_unit.yml` runs
`tests/unit/`), no workflow change needed

<details>
<summary>🔍 Technical details</summary>

- `kind: "turn"` builds a bare `Agent` whose tools are stand-ins
returning the recorded results (and writing the files the real call
wrote, since the checks stat the disk), scripts the model's replies, and
runs `process_query`.
- `kind: "stream"` feeds recorded provider chunks to
`AgentSDK.send_messages_stream` (F36 lives below the loop).
- `kind: "question"` calls the flagship's real `request_user_input` with
a console that answers or stays silent (F81 is the tool's contract, not
a check).
- Unknown keys in a case are an error, so a typo cannot turn an
assertion off.
</details>

---------

Co-authored-by: Kalin Ovtcharov <[email protected]>
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