Skip to content

fix(agents): block final answers that claim a save no tool performed - #4012

Merged
itomek merged 7 commits into
mainfrom
autofix/issue-4010
Sep 21, 2026
Merged

itomek merged 7 commits into
mainfrom
autofix/issue-4010

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

An agent turn whose last step was "write the result to a file" could finish by telling the user the file was saved when the save tool had never run — nothing reached disk, and the user got no signal to go check. That is worse than an honest error. Now, when the final answer claims a file was written and no disk-touching tool ran in that turn, the loop rejects the answer and pushes the model to either make the call or stop claiming it did.

Closes #4010

Test plan

  • python -m pytest tests/unit/ -x passes
  • python util/lint.py --all passes
  • Re-run the reporter's repro on real hardware: a multi-step task ending in write_file, with and without --bypass-permissions. The turn should now either produce a real write_file call (visible under --trace/--dev) or an answer that no longer claims a save.
  • Sanity-check that ordinary answers still pass straight through — ask an agent to read a file and summarise it, and confirm no extra round trip.

⚠️ Needs manual validation — lint and the unit suite confirm no Python regression, but neither can exercise the model behaviour this targets. A maintainer should run the repro above against a live Lemonade server before merging.

🔍 Technical details

Root cause. The model never emits the tool call; it treats having reasoned about the remaining step as having executed it. The loop had no check tying a completion claim back to the tool calls that would make it true, so the answer was accepted as final.

Change. src/gaia/agents/base/agent.py gains a _claims_file_write() helper plus a guard in the process_query answer seam, alongside the existing fabricated-completion guards (tool-markup-as-text, planning-only prose, raw-JSON tool output, unbacked SD capability claims). It follows the same shape those use: inject a correction into messages and continue rather than setting final_answer.

Four things keep the false-positive cost low:

  • Fires only when one of _FILE_WRITE_TOOLS (write_file, write_markdown_file, write_python_file, edit_file) is in the agent's registry — otherwise the correction would be unactionable and the turn would just burn a step.
  • "A write happened" is matched permissively against _FILE_WRITE_TOOL_MARKERS (write, save, edit, create, download, export, replace, generate_image). Over-matching only costs recall; under-matching would block a genuine save.
  • Detection needs a completed write verb and a file/path target in the same sentence, so I saved the routine to notes/routine.md fires while I created a summary of the meeting and I wrote a helper that normalizes the timestamps do not. Fenced code is stripped first — a sample command is not a claim.
  • Capped at one re-prompt per turn (_MAX_FILE_WRITE_CLAIM_REPROMPTS), and skipped on the last step.

The correction also names the earlier-turn case explicitly ("if you mean a file written earlier in the conversation, say that instead of claiming you just saved it"), so a follow-up question like where did you save it? resolves in one step rather than forcing a redundant write.

Verification. tests/unit/agents/test_fabricated_save_guard.py — 17 tests: a claim/non-claim corpus for the detector (including the issue's own I have saved the result to \X`phrasing and near-miss negatives), plus loop-integration tests for the re-prompt, the per-turn cap, the no-write-tool skip, the last-step skip, and a realwrite_filecall suppressing the guard. Fulltests/unit/ run: 12,620 passed. The single failure in that run (eval/mcp_server_launcher.py→No module named 'openai') is a sandbox artifact — that test spawns a bare python` subprocess which resolves to the system interpreter, not the test venv.

A turn ending in "write the result to a file" reliably finished with the
model asserting the save in prose while never emitting the tool call, so
the user was told it succeeded with nothing on disk.

The agent loop already blocks several fabricated-completion shapes at the
same seam (tool markup as text, planning-only prose, raw-JSON tool output,
unbacked capability claims). This adds the same treatment for a file-write
claim: when the answer says a file was saved and no disk-touching tool ran
this turn, inject one correction and loop instead of accepting the answer.

Scoped to stay quiet when it cannot help — it fires only for agents that
actually expose a write tool, believes any plausibly-writing tool call,
requires both a completed write verb and a path target in one sentence,
and re-prompts at most once per turn.

Closes #4010
@github-actions github-actions Bot added tests Test changes agents labels Sep 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor Author

Verdict: Approve with suggestions

The fabricated-save guard is well-constructed: it follows the exact same shape as the existing fabricated-completion guards (inject correction into messages + continue), is capped at one re-prompt per turn to avoid loops, skips when no write tool is registered, and ships 17 tests that cover the claim/non-claim corpus, loop integration, cap enforcement, and the critical "real write_file call suppresses the guard" path. No correctness bugs or breaking changes.

One real gap and one nit below.


🟡 The real-hardware test plan checkbox is unchecked — the guard's effect on live model behavior is unverified.
The unit tests confirm the guard fires and injects the correction message, but they can't show whether the reprompted model then emits the write_file call or just hallucinates a new claim that passes through. The PR explicitly flags this and asks a maintainer to run the repro before merging. That's the right posture, but the checkbox should be ticked (with a trace excerpt showing the guard firing and the tool call following) before this lands. The test plan item — "Re-run the reporter's repro on real hardware: a multi-step task ending in write_file, with and without --bypass-permissions. The turn should now either produce a real write_file call (visible under --trace/--dev) or an answer that no longer claims a save" — is the missing artifact.


🟢 _FILE_WRITE_TOOL_MARKERS is broad enough that common non-disk tools silently suppress the guard. A tool named create_connector, download_url, or export_report would set _wrote_this_turn = True and let a false save claim through. The PR documents this as an intentional false-negative tradeoff, so it's not a bug — but it's worth noting that the guard's effectiveness degrades whenever those tool names co-occur with a write claim.

🔍 Technical details

🟡 evidence gap: src/gaia/agents/base/agent.py:7279–7315 is the guard seam. The correction injection is verified by test_unbacked_save_claim_is_reprompted, but that test stubs chat.send_messages — it confirms the correction message is injected, not that a real model responds to it correctly. The PR's own note says "lint and the unit suite confirm no Python regression, but neither can exercise the model behaviour this targets." A gaia chat --trace excerpt from real hardware would close this gap.

🟢 marker over-match: _FILE_WRITE_TOOL_MARKERS at line 23 of the new block includes "create", "download", "export", "replace". Any tool whose name contains one of these strings triggers _wrote_this_turn = True. For an agent with both create_connector and write_file in its registry, running create_connector in the same turn would suppress the guard even though nothing was written to disk. Narrowing the list (or matching only the exact _FILE_WRITE_TOOLS names rather than substring-matching all tool names) would reduce the suppression surface.

@github-actions

Copy link
Copy Markdown
Contributor Author

Request changes

This adds a guard that rejects a final answer claiming a file was saved when no disk-touching tool ran that turn — a well-shaped fix for #4010 that follows the existing fabricated-completion guards exactly. Two heuristic gaps should be closed before merge, both one-liners.

The guard doesn't recognise a save made through the shell. The flagship agent can write files by running a shell command or executing a generated Python script, and neither is on the list of "something touched disk" names. A turn that genuinely saved that way ends with the model being told nothing was written and the user being told the save didn't happen — the exact outcome the guard exists to prevent, just inverted. Add the shell/execute tool names to the recognised set.

The "is this a file?" test fires on things that aren't files. Version numbers, URLs, email addresses and clock times all look like filenames to it, so honest answers such as "I created the issue at github.com//issues/42" or "I've created the release notes for v0.17.5" get bounced and the model is pushed to write a file the user never asked for. Worth excluding URL/email-shaped matches.

Neither is fatal — the re-prompt is capped at one per turn — but both hit ordinary answers from the agent that ships this guard.

Real-world evidence

The evidence harness did not run for this PR. evidence-bundle.md reports, verbatim:

⚠️ EVIDENCE HARNESS FAILED TO RUN — this is NOT "nothing to test".

The evidence stage errored before producing evidence (auth / install / rate-limit
— see this run's logs). The changed surface was NOT exercised; the verdict below
rests on static review only.

So nothing here exercised the behaviour on a live model, and I could not run the new unit tests either (this runner has no test dependencies installed). My verdict rests on static review and on reproducing the two detector patterns above standalone, which is how I confirmed both misfires. The PR itself flags that it needs manual validation; the repro in its test plan is still the thing that has to pass before merge.

🔍 Technical details

Issues

🟡 A real save via run_shell_command / execute_python_file is treated as fabricated (src/gaia/agents/base/agent.py:720)

_FILE_WRITE_TOOL_MARKERS contains none of shell, command, execute, run, python, but ChatAgent — the flagship's base class — composes both ShellToolsMixin (run_shell_command) and FileIOToolsMixin (write_file), and also registers execute_python_file (hub/agents/chat/python/gaia_agent_chat/agent.py:200-205, :1443). A skill that saves output by redirecting in a shell command, or by running a script that writes its own output, satisfies _write_tool and not _wrote_this_turn and gets the correction "no file-writing tool ran in this turn — nothing was written to disk". The model then either re-writes the file or retracts a true statement. The comment at :719 names this exact failure mode ("under-matching would block a true save"); the fix is to include the shell family:

_FILE_WRITE_TOOL_MARKERS: Tuple[str, ...] = (
    "write",
    "save",
    "edit",
    "create",
    "download",
    "export",
    "replace",
    "generate_image",
    "shell",
    "command",
    "execute",
    "python",
)

A test alongside test_claim_backed_by_a_write_tool_call_is_accepted that backs the claim with a run_shell_command call would lock this in.

🟡 _FILE_TARGET_PATTERN matches versions, URLs, emails and times (src/gaia/agents/base/agent.py:751)

The [\w~./\\-]+\.[A-Za-z0-9]{1,6}\b alternative is broad enough that any dotted token qualifies. Running the three claim patterns plus this target pattern standalone:

True  | I've created the release notes for v0.17.5 and they look good.
True  | I have created the issue at https://github.com/amd/gaia/issues/42.
True  | I created a draft reply to [email protected].
True  | I have created an event at 10.30 in your calendar.
True  | I wrote to john at acme.com.

If the underlying action went through a tool whose name carries a marker (create_issue, an MCP …create… tool) the guard stays quiet, but via the shell or a non-marker connector tool it fires — and the injected correction tells the model to "call write_file now with the full content and the exact path" for a file the user never asked for. Excluding tokens that sit inside a URL or an email address (://, @, or a trailing TLD-only match with no path separator) would cut most of these without weakening the notes/routine.md case. Adding a couple of these strings to NON_CLAIMS in the new test file documents the intent.

🟢 Detector treats a self-negating sentence as a claim (src/gaia/agents/base/agent.py:763)

"I wrote the summary below; nothing was written to disk." returns True — "disk" is a target and "I wrote" is a verb, in one sentence. Low impact (capped re-prompt), noted only because it's the phrasing the correction itself steers the model toward.

Strengths

  • Mirrors the surrounding guards precisely — same seam, same messages.append(...) + continue shape, same steps_taken < steps_limit - 1 last-step skip, and a per-turn cap so a stubborn model can't spin.
  • Refusing to fire when the agent has no write tool in its registry is the right call: an unactionable correction would just burn a step.
  • The test file is genuinely good — a claim/non-claim corpus including the issue's own phrasing, plus loop-integration coverage for the cap, the no-tool skip, the last-step skip, and a real write_file call suppressing the guard. The _TOOL_REGISTRY snapshot fixture avoids cross-test leakage.
  • The correction message covering the earlier-turn case ("if you mean a file written earlier…") is a thoughtful detail that avoids forcing a redundant write on a follow-up question.

@amd-pworfolk

Copy link
Copy Markdown
Collaborator

Ran this against a live Lemonade server on the original #4010 repro (Gemma-4-E4B-it-GGUF, GPU, 65536 ctx, Windows, gaia-tui run gaia --dev --bypass-permissions). Summary: the detector is correct and the guard is a real improvement, but the repro is non-deterministic in a way that means this PR cannot be validated by "re-run the repro" alone — and there's one false-negative class worth a look before merge.

Detector: correct on real data

Fed _claims_file_write the verbatim closing sentences from my three original fabricated-save runs, plus near-miss negatives:

Case Result
I have composed the routine summary and saved it to `…transcription5_summary.md`. ✅ True
The routine has been saved to `…workshop_clip_5min_summary.md`. ✅ True
The summarized routine has been saved to: `…6-26-26_summary.md`. ✅ True
I created a summary of the meeting and listed the action items below. ✅ False
I wrote a helper that normalizes the timestamps. ✅ False
fenced-code-only mention of out.md ✅ False
I read the transcript at C:\…\t.txt and summarized it. ✅ False
I will now save this routine to Lower_Body_summary.md. (future tense) ✅ False

tests/unit/agents/test_fabricated_save_guard.py: 20 passed.

Live runs: the failure is intermittent

Three end-to-end runs of the exact repro on this branch:

  • Run 1 — model called write_file unprompted; file written to disk (2,562 bytes, correct path, correct content). Guard never fired (no Blocking unbacked file-write claim in the agent log). First time in ~6 attempts across this investigation that the file actually landed.
  • Run 2 — no write_file call, no file on disk, and the answer made no save claim at all — it ended The full transcript is available at …txt. If you want me to look up specific details…just ask!. Guard correctly stayed silent (verified: _claims_file_write returns False on that text). User still got no file and no warning.
  • Run 3 — inconclusive, hit my 600 s harness timeout during re-transcription.

So I did not get a live firing of the guard, because in neither completed run did the model both skip the write and claim it. That's not evidence against the fix — it's evidence that the underlying model behaviour varies run to run, which matters for how the test-plan checkbox gets interpreted.

Suggestion: the "re-run the reporter's repro" item can pass or fail for reasons unrelated to this patch. The mocked loop-integration tests already in the PR are the stronger signal. If you want a live check that deterministically exercises the guard, it'd need a stub model that emits a save claim with no tool call.

Gap worth a look: the silent-omission case

Run 2 is the shape this guard structurally cannot catch: the model drops the save step and simply doesn't mention it. There's no claim to contradict, so the guard is correctly silent — and the outcome for the user is the same as the bug being fixed here (no file, no signal). Flagging it because #4010's impact statement covers this case too, so I don't think the issue is fully closed by this patch. Probably a separate, harder problem (intent-vs-outcome rather than claim-vs-outcome) and fine to leave out of scope here, but worth not marking #4010 as fully resolved on merge.

Possible false negative: create_table

_FILE_WRITE_TOOL_MARKERS includes create, and the flagship registry contains create_table (scratchpad/DB, not disk). Any turn that calls it suppresses the guard entirely:

read_file, create_table, insert_data  -> _wrote_this_turn = True  (guard suppressed)
generate_image                        -> _wrote_this_turn = True  (guard suppressed)
transcribe_media, read_file, read_tool_output -> guard fires (correct)

So a data-analysis turn that writes to the scratchpad DB and then fabricates a file save slips through. I realise the PR states over-matching is deliberate ("over-matching only costs recall") and generate_image is listed intentionally — but create matching create_table looks more like collateral than intent, since a DB write is not evidence a file was written. Tightening create to create_file/create_dir, or excluding known-DB tools, would close it without weakening the conservative stance.

Verdict

Detector logic and scoping look right to me, and the change is well-placed alongside the existing guards at that seam. My checkboxes:

@itomek itomek self-assigned this Sep 21, 2026
itomek and others added 2 commits September 21, 2026 09:24
The fabricated-save guard bounced two kinds of honest answer. A turn that
genuinely saved a file through the shell or a Python snippet was told
"nothing was written to disk", pushing the model to rewrite the file or
retract a true statement. And any dotted token read as a filename, so
answers mentioning a version, a URL, an email address, a clock time or a
domain were treated as save claims and re-prompted.

The tool-marker list had no shell or exec entry, but ChatAgent registers
run_shell_command, execute_python_file and run_python — all of which can
write files. Over-matching a marker only costs recall; under-matching
blocks a real save, so the shell/exec family is now matched too.

The file-target test now strips links and addresses before looking for a
dotted token, and ignores tokens whose suffix carries no letter (a version
or a clock time) or is a hostname suffix. Stripping the span is simpler
than teaching one regex to exclude what sits inside a URL, and keeps each
rule readable on its own.

Still unmatched by design: take_screenshot and transcribe_media also reach
disk but sit outside this guard's shell/exec scope.
@github-actions

Copy link
Copy Markdown
Contributor Author

Skill audit

Skill Verdict Claimed tier Cleared tiers Findings Rules
hub/agents/gaia/npm ✅ ALLOW experimental experimental 1 high body.injection.credential_request
hub/skills/coding ✅ ALLOW community experimental, community 1 info permission.unused

✅ All audited skills cleared the tier they claim.

Per-finding detail is withheld here on purpose. Read it in the Security > Code scanning tab, or download the skill-audit-reports artifact from this run. Offending source text is withheld from CI everywhere — reproduce it locally with gaia skill audit <dir> --show-snippets.

The fabricated-save guard decided "did anything write?" by substring-matching
tool names, which got it wrong in both directions. A turn that genuinely saved
through the shell or a Python snippet was told "nothing was written to disk",
pushing the model to rewrite the file or retract a true statement; meanwhile
create_calendar_event, download_url and export_report suppressed the guard
outright despite touching no file.

The confirmation set is already the maintained list of tools that write or
execute, so the guard now reads it instead of keeping a parallel list that
drifts on the next tool addition — which is how the gap arose. notify_desktop
is subtracted: it is in that set because it spawns a PowerShell child, not
because it writes, and leaving it in would suppress the guard for free.

The check is exact-name membership, not _tool_requires_confirmation(). That
method is a safety gate and reads inverted here: it exempts a pre-authorized
write (a real save would look like no save) and treats an unclassified mcp_
tool as consequential (a read-only MCP lookup would look like a save). A
third-party tool counts only when its registry entry declares the flag itself.

Second fix, independent of the first: the file-target test read any dotted
token as a filename, so honest answers naming a version, a URL, an email
address, a clock time or a domain were treated as save claims and re-prompted.
Links and addresses are now stripped before the scan, and a token whose suffix
carries no letter or is a hostname suffix is not a path. Stripping the span is
simpler than teaching one regex to exclude what sits inside a URL.
A write that the validator refused, that raised, or that the user declined
left the file off disk while the answer still said "saved to X" — #4010's
exact harm, surviving the guard meant to catch it. The guard read
tool_call_log, which is appended before the call runs, so it counted intent.
It now reads the per-turn execution log and requires the call to have run and
not failed.

Two related fixes in the same seam:

- Four tools that write a file as a side effect (take_screenshot,
  text_to_speech, transcribe_media, refine_transcript) are cheap and safe, so
  they never enter the confirmation set the disk-touching set was derived
  from. A genuine save through any of them was being told nothing was written.
- The dotted-token regex was unbounded and scanned quadratically: a 32KB hex
  digest in one answer cost 1.4s of GIL-held CPU, stalling the whole API/UI
  process on every final answer. Bounding the run to 80 characters brings that
  to 9ms with no loss of coverage.
@itomek

itomek commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator

Reviewed, fixed, and verified. The guard is worth having — it catches a real, user-harmful failure (the model says "saved to X" and nothing reached disk) — but as submitted it was wrong in both directions and would have made things worse for some ordinary turns. Four defects found, all confirmed by running the code rather than reading it, and all now fixed on this branch.

The most important one: the guard checked which tools were attempted, not which succeeded. A write_file that the path validator refused, that raised, or that the user declined still counted as "a file was written" — so the exact bug this PR exists to catch survived the fix.

What changed since the bot reviews

  • A write that failed or was denied no longer silences the guard.
  • Four tools that genuinely write a file (take_screenshot, text_to_speech, transcribe_media, refine_transcript) are now recognised, so a real save through them is no longer reported as fabricated.
  • Ordinary answers mentioning a version number, URL, email address or clock time are no longer mistaken for save claims.
  • A pathological input no longer stalls the process: 1374 ms → 9.68 ms on a 32 KB token, measured.
🔍 Technical details

1. _wrote_this_turn counted intent, not outcome. tool_call_log.append(current_call) runs before _execute_tool_timed on both loop paths (agent.py:6587 native, :6802 legacy), so the log records what was attempted. The real write_file returns {'status':'error'} rather than raising on a validator refusal (file_io_tools.py:913) or any exception (:966), and {'status':'denied'} on a declined confirmation (agent.py:4120). Each reproduces #4010's harm — file absent, user told it was saved — with the guard silent. Now reads self._turn_tool_executions, requiring ran and not failed. Both flags are needed: _is_error_result({'status':'denied'}) is False, and only ran catches a declined confirmation.

2. Marker matching was wrong in both directions. Against a real GaiaAgent() (79 registered tools): take_screenshot (screenshot_tools.py:30), text_to_speech (sf.write(output_path, ...)), transcribe_media (audio_tools.py:1032) and refine_transcript (:697) all write and carried no marker. Conversely create_table (a SQLite scratch table) and write_clipboard (pyperclip.copy) carried markers and touch no file — so one scratchpad call disarmed the guard on exactly the #4010 shape. The substring list is replaced by an explicit set derived from TOOLS_REQUIRING_CONFIRMATION plus the four side-effect writers.

Note _tool_requires_confirmation() was tried and rejected: it ends return tool_name.startswith("mcp_"), so any MCP call would have disarmed the guard, and it returns not _call_is_pre_authorized(...), so a skill-granted write_file would have read as "no write".

3. _FILE_TARGET_PATTERN read ordinary prose as filenames. Executed on the pre-fix branch, all of these returned True: I've created the release notes for v0.17.5, I have created the issue at https://github.com/amd/gaia/issues/42, I created a draft reply to [email protected], I have created an event at 10.30 in your calendar, I wrote to john at acme.com. Each is a plausible answer from an agent with write_file registered, so the turn was bounced and the model pushed to write a file nobody asked for. Fixed by pre-stripping URL/email spans and rejecting letter-less and hostname suffixes. All five now False; all seven SAVE_CLAIMS still True.

4. Quadratic scan, GIL-held, on every final answer. _DOTTED_TOKEN_PATTERN's unbounded [\w~./\\-]+ cost 1374.60 ms on "I saved it to " + "0123456789abcdef"*2000. re holds the GIL, so that stalls the whole API/UI process — including for agents the guard can never fire on. Bounded to {1,80}: 9.68 ms, and lossless, since the alternative has no leading \b so a longer path still matches from a later offset.

Verification. 35/35 CI checks green on ba7d843e. Measurements above re-run independently against the merging head.

@itomek itomek 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.

Four defects found and fixed on this branch; 35/35 CI green. Evidence in the comment above.

@itomek
itomek added this pull request to the merge queue Sep 21, 2026
Merged via the queue into main with commit e260ef2 Sep 21, 2026
46 of 47 checks passed
@itomek
itomek deleted the autofix/issue-4010 branch September 21, 2026 15:36
@itomek

itomek commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator

Real-hardware evidence, run against a live local model rather than mocks. Posting after merge because it independently confirms the defects fixed here — and turns up two that are not.

The bug is real, and the guard repairs it. A control build (this branch with the guard removed, nothing else changed) ended a turn saying "The detailed report has been saved to out/summary.md" after running only read tools, with the directory empty — #4010 verbatim. On the same query with the guard present, it blocked the unbacked answer, re-prompted, and the model emitted a genuine write_file 25 seconds later with the file on disk.

It also independently reproduced the worst defect we fixed. Where a file was genuinely created by execute_python_file, the pre-fix guard called the true claim fabricated and talked the model into retracting it — "The file wasn't written by me in this turn." The matched control answered correctly. That reproduced 2 of 2, and it is the under-match the original code comment warned about. The merged version recognises execute_python_file, so this case is closed.

What this does not show: that the guard improves how often files actually get written. That rate was unchanged between the two builds, and with 4 guard fires across 36 runs on a stochastic model the sample cannot support such a claim. The false-positive findings are the solid ones, because they are deterministic code paths.

Two findings that are still open — filed as #4057:

  • The guard fires on the model's own plan text ("Conclude by stating the precise path where the summary was saved"), spending the turn's single re-prompt on a future-tense step.
  • _claims_file_write() misses phrasings the model really produced, including "has been successfully written and saved to X".
🔍 Technical details

36 runs on an AMD Strix Halo Ryzen AI box (Radeon 8060S iGPU) running Gemma-4-E4B-it-GGUF via Lemonade, driven through the flagship agent's stdio transport over an SSH port-forward, one turn per run in a fresh scratch dir. Control = this branch with the guard's 113 lines removed from agent.py and its test file deleted; git diff --cached --stat confirms nothing else differs. Inference verified remote per run (POST /api/v1/chat/completions 200, tokens_per_second: 47.3, one cold load at 6.07 s TTFT).

Clean #4010 reproduction (control): tools executed were find_files, read_file, read_file, read_file — no write tool — and out/ did not exist. Final answer: "The detailed report has been saved to …/out/summary.md."

Guard repairing it (fix arm, same query):

09:17:01  [WORKFLOW] Blocking unbacked file-write claim as final answer: ### File Analysis and Comparison Report
09:17:26  Executing tool write_file with args: {'content': '### File Analysis and Comparison Report\n\n…

False positive on a genuine save (pre-fix):

Blocking unbacked file-write claim as final answer: I saved the generated report to `out/generated.txt`.
TARGET EXISTS: True   CONTENT: REPORT OK

Model then retracted: "The file wasn't written by me in this turn—it was produced by gen_report.py when it ran successfully moments ago." Matched controls answered "I saved generated.txt at out/generated.txt." — correct. Root cause was _FILE_WRITE_TOOL_MARKERS substring-matching executed tool names, which execute_python_file and run_shell_command never match.

Sample-quality caveats, stated rather than smoothed over: at temperature 1.0 roughly two-thirds of runs on the multi-step task degenerate into unrelated retrieval loops, and 4 of the 12 matched runs never produced an answer at all (connection errors, one tool-call parse failure). The matched comparison is therefore 1-of-4 usable per arm — a matched pair, not a rate. Seven "draft this, save nothing" runs produced zero false fires. run_shell_command cannot write a file on this build at all: its read-only allowlist and blocked redirection operators refuse it.

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.

Model claims a file was saved without ever calling write_file (independent of the confirmation gate)

3 participants