Skip to content

fix(agent): don't read "I wrote no file" as a claim that one was saved - #7276

Merged
kovtcharov-amd merged 10 commits into
amd:mainfrom
kovtcharov:kalin/rc18-negated-save-claim
Nov 12, 2026
Merged

kovtcharov-amd merged 10 commits into
amd:mainfrom
kovtcharov:kalin/rc18-negated-save-claim

Conversation

@kovtcharov

Copy link
Copy Markdown
Contributor

A read-only answer could end with "the requested output file has no recorded successful write", or GAIA would re-prompt itself, because the check read the answer's own denial ("I wrote no file this turn") as a claim that a file was saved. A recalled memory that mentioned a save had the same effect on every later turn. Denials are no longer claims, and the check reads only the user's own words.

Closes #7178

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

Test plan

  • python -m pytest tests/unit/agents (7234 pass) with 8 denials that must not count, 5 near-miss real claims that still must, and the rc18 answer verbatim; 11 fail on main
  • Flagship suite: the same 3 tests fail here as on main (tool-count mismatch), none new
  • Replay on a cloud model: ask a read-only question about a file that contains a planted "create a file" instruction
  • Eval categories to watch: gaia_honesty, gaia_files, gaia_rag, gaia_memory, gaia_data, gaia_resilience

Before: an answer to a read-only question that said "I wrote no file this
turn" or "No file was written" was read as a claim that a file had been
saved, so GAIA re-prompted the model and ended the answer with "The
requested output file has no recorded successful write". After: a write
verb whose own subject or object is "no file", "nothing" or "none" is not
a claim, and the answer goes out as written.

A turn whose request asked for a save still counts that sentence, because
it names the save that is still owed; a negation elsewhere in the sentence
("No problem, I saved it to x.md") never cancels a real claim.

Closes #ISSUE
…mory

Before: a stored memory or recalled procedure that mentioned saving a file
("then save the chart to chart.png") made every later turn that recalled it
owe that save, so a plain question ended with "No successful write to
chart.png is recorded for this turn". After: only what the user typed this
turn can ask for a save.

The completion ledger read the memory-framed message; it now reads the
user's own text, the same source the grounding and look-first checks
already use.

Closes #ISSUE
The completion ledger takes any one-argument claim test, and tests pass
their own. Asking it to forward a keyword broke those callers, so the
agent now picks the claim test for the turn: one that still counts "no
file was written" when the user asked for a save, the plain one otherwise.

Closes #ISSUE
@github-actions github-actions Bot added tests Test changes agents labels Nov 12, 2026
@kovtcharov kovtcharov changed the title fix(agent): pass the save-request context outside the claim callable fix(agent): don't read "I wrote no file" as a claim that one was saved Nov 12, 2026
@kovtcharov
kovtcharov marked this pull request as ready for review November 12, 2026 06:06
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

A read-only answer that said "I wrote no file" got flagged as an unfinished save, and a recalled memory that mentioned a save made later turns owe one too. This PR fixes both. When the user did ask for a save, the check still demands it. The logic is sound and well tested, and no other caller of the save-claim check was missed.

  • Before merging, finish the unchecked replay on a real model. This changes how every turn decides it's done, so unit tests can't stand in for that run.
  • One small gap: on a turn that didn't ask for a save, "I created no other files besides notes.md" now counts as a denial, so a made-up save worded that way would no longer be caught. It's a narrow case, and there's a suggestion below.

Real-world evidence

N/A: no evidence bundle was produced for this run. The change is in the agent's turn-completion check, so it can only really be exercised with a live model. That falls to the author's pending replay and the next RC's eval (gaia_honesty, gaia_files, gaia_rag, gaia_memory, gaia_data, gaia_resilience). This verdict rests on static review alone. The unit tests couldn't be run on this runner either (pytest and dotenv aren't installed), so I relied on the PR's stated results.

🔍 Technical details

Issues

🟢 A denial with an exception clause hides a real save (src/gaia/agents/base/agent.py, _NEGATED_OBJECT_PATTERN). _NEGATED_OUTPUT allows any one word between no and files. That means "I created no other files besides notes.md" and "I saved nothing but the report to r.md" both read as denials, even though each names a file it claims was written. This only matters when instructed is false, because the denials=True path keeps the old behaviour. One way to close it is to refuse the negation when an exception word follows:

_NEGATED_OBJECT_PATTERN = re.compile(
    rf"\s+{_NEGATED_OUTPUT}\b(?!\s+(?:but|except|besides|other\s+than|apart\s+from)\b)",
    re.IGNORECASE,
)

Add the two sentences above to SAVE_CLAIMS with the change.

🟡 Merge gate: the live replay is still unchecked. The PR is already marked draft until it runs. Please paste the replay's request and final answer into the PR when it's done. _completion_evidence.gaps feeds the re-prompt and the "incomplete" caveat on every turn.

Checked, no action needed

  • Sibling paths. All three gaps(...) call sites switched to _write_claims_for(...): the final check, the restored-answer check and the per-step candidate check. _claims_file_write has no other callers in src/ or hub/.
  • Stale request text. _request_text reads _original_user_input. MemoryMixin.process_query sets that unconditionally on every turn, and the value is None when memory is off. A previous turn's text can't leak into the CompletionEvidence query. Grounding already uses the same helper.
  • Placement of negations. The subject check is anchored to the text right before each verb match (\s+$), and the object check to the text right after it. A "No problem, …" or "No errors: …" elsewhere in the sentence doesn't cancel a real save. The five new near-miss SAVE_CLAIMS cases cover this.
  • Docs drift. No doc under docs/ or the flagship package describes this check's wording.

Strengths

  • With denials=True, a turn that asked for a save still treats "No file was written" as an unpaid save. The fix doesn't weaken the main guard.
  • The tests use the rc18 answer verbatim, plus paired tests for memory context (a recalled save isn't owed, the user's own save still is). They pin both directions.

kovtcharov and others added 4 commits November 11, 2026 22:30
A read-only answer with the aside "... the `granite-1812` I have stored as
your bookshelf slot - the file's line says `copper-1397`" was sent back with
"The requested output file has no recorded successful write", and the model
dropped the useful aside. It is now left alone.

A sentence counted as a save claim whenever it held a write verb and any
file word. A write verb that tells of something remembered no longer counts:
"stored as your ...", "saved to memory", or a backticked value that is not a
path right before "I have stored". "I saved report.md", "saved as chart.png"
and "the `report.md` I saved" are still claims.
"I created no other files besides notes.md" and "I saved nothing but the
report to r.md" read as denials, so a made-up save worded that way went
unchecked on a turn that did not ask for one. A negation followed by an
exception (but, except, besides, other than, apart from) now still claims
the file it names.
…o kalin/rc18-negated-save-claim-r2

# Conflicts:
#	src/gaia/agents/base/agent.py
#	tests/unit/agents/test_fabricated_save_guard.py
@kovtcharov

Copy link
Copy Markdown
Contributor Author

Round 2 of the rc18 test found the same false re-prompt from a sentence that is not negated: a read-only answer with the aside "... the granite-1812 I have stored as your bookshelf slot - the file's line says copper-1397" was sent back as a claimed save. The new commit stops reading a remembered value described as stored as a file write.

"I saved report.md", "saved as chart.png" and "the report.md I saved" are still claims.

🔍 Technical details
  • A sentence was a claim whenever it held a write verb and any file word; here "I have stored" plus "the file's".
  • _is_write_claim now skips a write verb followed by "as your ..." or "in/to memory", or preceded by a backticked token that is not a path.
  • Both directions are in SAVE_CLAIMS / NON_CLAIMS, plus ledger tests with the tester's answer.

@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

Closed the exception-clause gap the review found. "I created no other files besides notes.md" and "I saved nothing but the report to r.md" count as save claims again, so a made-up save worded that way is still checked.

🔍 Technical details
  • _NEGATED_OBJECT_PATTERN refuses the negation when but|except|besides|other than|apart from|aside from|save for follows, as suggested. The subject-side negation ("No other file was written apart from out/report.md") is refused the same way when an exception word follows the verb.
  • Five new SAVE_CLAIMS cases, all failing on the previous head. Merged origin/main; 316 pass across the save-guard, completion-evidence and loop suites.

The remembered-value carve-out also dropped real saves: "Here's the
`summary` I saved to `out/summary.md`" and "The file was saved as your
`todo.md`" read as values kept in memory, so a made-up save worded that way
went unchecked. A path or file name in the verb's own clause now keeps it a
claim; "saved to memory" and the rc18 bookshelf-slot aside are unchanged.
@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

The remembered-value carve-out let two real saves through unchecked: "Here's the summary I saved to out/summary.md" and "The file was saved as your todo.md". Both count as save claims again. "Saved to memory" and the rc18 bookshelf-slot aside are still left alone.

🔍 Technical details
  • _describes_a_remembered_value now returns False when a path or file name appears in the verb's own clause, which runs up to the next , ; : — – or -. The explicit "in/to memory" branch is checked first, so stored in my memory as ~/work is unchanged.
  • Two new SAVE_CLAIMS cases. 330 pass across the save-guard, completion-evidence and loop suites.

@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

Not merged yet: the remembered-value carve-out still lets made-up saves through, even on a turn where the user asked for a save. On main each of these is flagged; on this head none are.

  • "Here's the summary I saved, at out/summary.md."
  • "The weekly-report I saved: out/report.md."
  • "The report was saved as your weekly summary - see out/r.md."

Next step: treat a path anywhere later in the sentence as a save (not only in the verb's own clause), then add these three to SAVE_CLAIMS.

🔍 Technical details
  • _describes_a_remembered_value cuts the clause at the first , ; : — – or -, so the path after the comma, colon or dash is never seen. Then the backticked non-path token before the verb (or the as your after it) marks the sentence as a remembered value.
  • This runs before the denials check, so _write_claims_for with instructed=True drops it too. CompletionEvidence("Summarise notes.txt and save the summary", d).gaps("Here's the summaryI saved, atout/summary.md.", _write_claims_for(L)) returns [] on this head. On main the same call with _claims_file_write returns the "No successful write to ...out\summary.md" gap.

The remembered-value exemption only looked for a path in the verb's own
clause, so "Here's the `summary` I saved, at `out/summary.md`." and "The
`weekly-report` I saved: `out/report.md`." went unchecked. It now treats
any path or file name in the sentence as a save. On a turn that asked
for a save the exemption no longer applies at all, matching main.
# Conflicts:
#	tests/unit/agents/test_completion_evidence.py
@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

All three saves from the verifier's list are checked again. A path or file name anywhere in the sentence now makes it a save claim, and on a turn that asked for a save the remembered-value reading doesn't apply at all, the same as main. The rc18 bookshelf-slot aside and "saved to memory" are still left alone.

🔍 Technical details
  • _describes_a_remembered_value checks the whole sentence for a slash or a file extension before the clause cut, so text after a , : or - counts.
  • _is_write_claim with denials=True (an instructed turn) reads every write verb as a claim, so _write_claims_for matches _claims_file_write on main.
  • All three sentences are in SAVE_CLAIMS. New ledger tests cover the read-only and the save-requested turns. All of them fail on 5640dd7. Merged origin/main, which had keep-both test conflicts. 537 pass across the save-guard, completion-evidence, look-first, announced-action and grounding suites.

@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Nov 12, 2026
Merged via the queue into amd:main with commit d6622b2 Nov 12, 2026
36 of 37 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the kalin/rc18-negated-save-claim branch November 12, 2026 08:48
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]>
grtninja pushed a commit to grtninja/gaia that referenced this pull request Nov 14, 2026
…md#7539)

A made-up file save can slip past the "unverified save" check again when
it is worded as a denial with an exception. On a turn that asked for no
save, "I saved nothing, except the summary to `out/summary.md`", "I
wrote nothing else besides `out/r.md`", "I created no other file than
`out/r.md`" and "Apart from `out/report.md`, no file was written" were
all flagged before amd#7276 and are silent after it. This restores the
check for them; plain denials ("I wrote no file this turn") and denials
whose exception is not a saved file ("Besides, no file was written.",
"Apart from reading report.pdf, I saved no files.") stay quiet.

Post-merge review finding on amd#7276: the exception-clause gap its
reviewer raised was closed only for an exception word directly after the
negation.

## Test plan
- [x] `python -m pytest
tests/unit/agents/test_fabricated_save_guard.py`: new `SAVE_CLAIMS`
cases fail on main, pass here; new `NON_CLAIMS` (exception word with no
saved file) pass on main and here
- [x] `python -m pytest -n 4 tests/unit/agents -k "save or completion or
claim or refused or look or announced or grounding"`: 2158 passed
- [x] Denials without an exception, or whose excepted file was only read
or already existed ("Other than report.pdf, which I only read, I wrote
no file."), are still not claims
- [ ] Eval categories to watch on the next RC: gaia_honesty, gaia_files

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

- An exception overrides a denial only when the excepted phrase is a
bare file, or "the X to/in/as <file>", followed directly by a clause
boundary that does not open a relative clause. A file followed by
"which/that", "being", its own verb, or "the fact that" is another
clause, not a save.
- "I didn't write any file except `out.csv`" (no claim verb of its own)
is now caught too.
- `nothing/no file [else|other] but|than` goes through the same object
check.
</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: a read-only answer gets a false "no file was written" note

2 participants