Skip to content

fix(agent): don't count an edit's own backup as a claimed save - #7277

Merged
kovtcharov-amd merged 5 commits into
amd:mainfrom
kovtcharov:kalin/rc18-backup-path-claim
Nov 12, 2026
Merged

kovtcharov-amd merged 5 commits into
amd:mainfrom
kovtcharov:kalin/rc18-backup-path-claim

Conversation

@kovtcharov

Copy link
Copy Markdown
Contributor

After an edit, an answer that mentioned the edit tool's own backup file ended with "No successful write to ...bak is recorded", and the re-prompt behind it read to the model like a suspicious message. A backup path a write tool itself reported is no longer counted as an output the turn owed. Other paths in the same answer, and a .bak no tool reported, are still checked.

Closes #7179

Draft until it is replayed in the app: this is the agent's turn-completion check.

Test plan

  • python -m pytest tests/unit/agents (7220 pass); the backup cases and the loop test fail on main
  • Replay on a cloud model: edit a file, then ask what changed
  • Eval categories to watch: gaia_honesty, gaia_files, gaia_resilience

Before: after a successful edit, an answer that repeated the edit tool's
"a backup was written to ...\todo.txt.<stamp>.bak" line ended with "No
successful write to \?\c:\...\.gaia\cache\backups\...bak is recorded for
this turn", or the re-prompt behind it made the model warn the user about
a "suspicious" message. After: the backup GAIA made is recognised as the
tool's by-product and the answer goes out clean.

The completion ledger now remembers each backup_path a write tool reports
and drops those paths from the answer's claimed outputs, matching by file
name too because answers shorten the backup folder. Any other path in the
same sentence, and any .bak no tool reported, is still checked.

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:07
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve

After an edit, an answer that repeated the edit tool's own backup path got a false "No successful write to ...bak is recorded" footer and a suspicious-sounding re-prompt. This PR stops counting a backup that a write tool reported as an output the turn owed. Any other path in the same answer, and a .bak that no tool reported, are still checked. The fix is narrow, and the tests cover the normal case, the shortened-path case and both cases that must still be flagged.

The PR is a draft until the replay in the app is done. That's the right gate, because this changes the agent's turn-completion check. The eval categories it lists (gaia_honesty, gaia_files, gaia_resilience) are the right ones to watch on the next RC.

Real-world evidence

N/A: no evidence bundle was produced for this run. This is a change to the agent's internal completion check, and testing it for real needs a live model. The verdict rests on static review alone. I couldn't run the unit tests here because pytest isn't installed on this runner. The PR reports 7220 passing in tests/unit/agents.

🔍 Technical details

Issues found: none blocking.

Checked while reviewing:

  • Sibling write tools: every tool that makes a backup reports it under the same backup_path key (file_tools.py edit/write, and file_io_tools.py at lines 715 and 898). The isinstance(backup, str) guard handles file_io_tools.py:898, which can return backup_path: None, so no write tool is left out.
  • Matching by file name only is safe because backup_file names backups with a microsecond timestamp. A file the user really asked for can't collide with one by accident.
  • Mixed answers: if named and not paths: continue skips a sentence only when every path it names is a backup. A sentence that names a backup plus a real output still checks the real output, and test_a_claimed_output_beside_the_backup_is_still_checked pins that.
  • Different roots: backups are keyed without project_dir, while written files are keyed with it. The file-name fallback covers that mismatch.

Strengths

  • It fails closed in the right direction. Only a backup a tool actually reported this turn is exempt, and test_a_bak_file_no_tool_reported_is_still_a_claim stops a model from making up a .bak to dodge the check.
  • test_repeating_the_edits_backup_line_is_not_an_unbacked_save runs the whole process_query loop and asserts there was no extra re-prompt (len(sent) == 2), so it tests what the user sees, not just the helper.

kovtcharov and others added 3 commits November 11, 2026 22:33
One turn after an edit, "A backup of todo.txt was written to <path>" was
sent back to the model as an unbacked save, and the reply grew a disclaimer
nobody asked for. Now the sentence goes out as written.

The record of backups lived only for the turn that made them. The agent now
carries it across turns, and a path that is a real file inside GAIA's own
backup folder counts as a backup whichever turn or session made it. A backup
path that no tool reported and that is not on disk is still checked.
@kovtcharov

Copy link
Copy Markdown
Contributor Author

Round 2 of the rc18 test found the backup was only recognised in the turn that made it: asked one turn later "where did the backup go?", the one-sentence answer was sent back to the model and came out with a disclaimer nobody asked for. The new commit recognises the backup in later turns too.

A backup path no tool reported and that is not on disk is still checked.

🔍 Technical details
  • The agent now carries the reported backups across turns (_session_backups, passed into each turn's CompletionEvidence).
  • A named path that is a real file inside GAIA's backup folder also counts, so it holds after a restart.
  • The existing loop test now runs a second and third turn; ledger tests cover on-disk, not-on-disk and outside-the-folder paths.

completion.py pulled gaia_home from gaia.config, which calls it while the
module loads, so `import gaia` crashed on a machine with no resolvable home
directory (test_logger_home_unresolvable, Linux and Windows unit tests).
gaia.home provides the same function without the import-time call.
@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

The cross-turn backup commit broke import gaia on a machine with no resolvable home directory, which failed the Linux and Windows unit tests. Fixed, and unit tests are green again.

🔍 Technical details
  • completion.py imported gaia_home from gaia.config, which calls it while the module loads. Importing it from gaia.home gives the same function without that call, so test_logger_home_unresolvable passes. Merged origin/main.

@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Nov 12, 2026
Merged via the queue into amd:main with commit 0346bda Nov 12, 2026
37 of 39 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the kalin/rc18-backup-path-claim 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.

Agent: naming an edit's backup file adds a false "no successful write" note

2 participants