Skip to content

fix(agent): a declined write is a finished answer, not unfinished work - #4693

Merged
kovtcharov-amd merged 1 commit into
amd:mainfrom
kovtcharov:kalin/completion-respects-denial
Oct 4, 2026
Merged

kovtcharov-amd merged 1 commit into
amd:mainfrom
kovtcharov:kalin/completion-respects-denial

Conversation

@kovtcharov

Copy link
Copy Markdown
Contributor

If you clicked Deny on a file write, the agent's honest reply ("I can't write to your Documents folder, you denied the permission") was replaced with "I can't confirm this is done … Treat it as unfinished — ask me to pick it up". That message also named a path the user never gave (<cwd>\ui_notes.txt for "ui_notes.txt in my Documents folder"). Worse, before replacing the reply, the completion check told the model to write the file at that invented path. That raised a second permission prompt the user hadn't asked for. Now a write the user turned down counts as a finished answer once the reply says it wasn't saved. A false "Saved!" is still caught and gets the real reason: "The write to …\Documents\ui_notes.txt was declined, so nothing was saved there."

🔍 Technical details
  • CompletionEvidence records write-tool calls that never ran because they were refused: confirmation status: "denied", or a validator Access denied: / User declined to overwrite error. Preflight refusals such as "read it first" are not recorded.
  • The obligation is dropped only when a refused write matches it (same key, inside the folder, or same bare name) and the answer admits it wasn't saved and makes no save claim. Otherwise the gap is the refusal reason. When every gap is a refusal, incomplete_answer returns just those reasons, with no "complete the missing work" line.
  • If the only gaps are refusals, the loop's [check:completion] correction says not to retry the write anywhere. Before this change it said "Use write_file for a missing requested save".
  • A bare requested name is shown as the name in gap text, not as a cwd-joined, case-folded key.
  • Related: fix(agent): a declined action is not run another way #4460 adds DeniedEffects, which keys denials on the path, so a write of the same file elsewhere is not blocked. In this repro the second write came from the completion correction above, not from the model, so this PR removes that trigger. Widening DeniedEffects to cover same-name writes belongs in fix(agent): a declined action is not run another way #4460.
  • Possible small conflict with feat(agent): plain-English verification note, shown only when work isn't confirmed #4508, which rewords incomplete_answer.

Test plan

  • python -m pytest tests/unit/agents/test_completion_evidence.py: the 9 new cases fail on origin/main (src diff reverse-applied) and pass with the fix. The preflight guard case passes on both.
  • python -m pytest tests/unit/agents: 2112 pass. The 1 failure, test_symlinked_directory_is_the_same_output, is an environment issue: Windows WinError 1314 (no symlink privilege). It is unrelated to this change.
  • python util/lint.py --black --isort
  • Eval required (this changes the agent-loop answer gate): gaia eval agent --category gaia_files, and gaia_honesty, run serially on one Lemonade
  • Agent UI repro: ask "Create a file ui_notes.txt in my Documents folder containing the line: hello from the agent ui", then click Deny. Expect no second prompt, and the model's own "not saved" reply as the final answer.

When the user said no to a file write, the completion check still counted
the save as missing. It told the model to write the file again at an
invented cwd path, which raised a second permission prompt, and then
replaced the model's honest "you denied it" reply with "Treat it as
unfinished".

- A write turned down by the confirmation prompt or the path allowlist is
  recorded. If the answer says it wasn't saved, the obligation is dropped.
- A claim of success after a denial is still caught, and the reason given
  is the real one: "The write to `<path>` was declined, so nothing was
  saved there."
- The correction for that case says not to retry the write anywhere.
- A bare requested file name is shown as the name, not joined to the cwd.
@github-actions github-actions Bot added tests Test changes agents labels Oct 4, 2026
@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

Clicking Deny on a file write now leaves the agent's honest "I couldn't save that" reply alone. Before, the reply was replaced with "treat it as unfinished", and the agent was pushed into a second, unrequested write prompt at a path the user never gave. A false "Saved!" after a denial is still caught, and now gets the real reason. The logic is tightly scoped and well tested. Two things remain before merge, and the PR already lists both as open:

  • Run the agent eval. This changes the gate that decides whether an answer counts as finished, so the gaia_files and gaia_honesty categories need a run on the Strix Halo pool.
  • Show the Agent UI repro. Add a screenshot of the Deny flow: no second prompt, and the model's own "not saved" reply kept as the final answer.

Real-world evidence

N/A: no evidence bundle was produced for this run. The change affects the Agent UI and real inference, so it is deferred to the strix-halo lane. This verdict rests on static review of the diff alone. I could not run the unit tests here because pytest is not installed in the review environment.

🔍 Technical details

Issues

🟡 Eval and UI evidence are still open (PR test plan). The answer gate in CompletionEvidence.gaps and the loop's [check:completion] correction (agent.py:9309) both change LLM-facing behaviour. CLAUDE.md requires a gaia eval agent run for this kind of change. Dispatch eval_flagship.yml for gaia_files and gaia_honesty, then compare against tests/fixtures/eval_baselines/gaia-flagship/. The rubric also asks for a Playwright before→after screenshot of the Deny flow, embedded in the PR description.

🟢 _ADMITS_UNSAVED matches anywhere in the answer, on very common words (completion.py:168). can't, didn't, wasn't and permission count as an admission even when they're about something else ("I didn't change the wording, and saved it"). The claimed / claim_without_path guards stop a save claim from being waved through, so this is low risk. Matching only in sentences that also name the refused path, or that contain a write verb, would make it tighter.

🟢 The pathless-save exemption is not tied to the requested file (completion.py, self.save_requested and not (self.refused and admitted)). Any refused write in the turn, such as an Access denied on an unrelated scratch path, plus any admission word clears the "you asked me to save this" obligation. Checking that the refusal is the only write the turn attempted would keep this narrow. Optional.

Strengths

  • Refusals are taken from the real refusal sources: confirmation status: "denied", and the two prefixes from security.py:928/1050/1075. Preflight errors like "read it first" are deliberately excluded and tested.
  • The loop correction only switches to "do not retry" when every artifact gap is a refusal (set(artifact_gaps) <= refused). Mixed gaps still get the normal write-and-read-back instruction.
  • Good loop-level tests: one checks the honest reply survives with exactly two model calls, and one checks a repeated false "Saved!" ends incomplete with the declined reason and no Use write_file nudge. The bare-name display fix (shown) stops cwd-joined, case-folded keys from leaking into user-facing text.

@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Oct 4, 2026
Merged via the queue into amd:main with commit 4b71824 Oct 4, 2026
@kovtcharov-amd
kovtcharov-amd deleted the kalin/completion-respects-denial branch October 4, 2026 23:55
kovtcharov added a commit to kovtcharov/gaia that referenced this pull request Oct 5, 2026
…urn-scope

A declined write is a finished answer (amd#4693), so the completion check no longer widens the turn scope with the path the user said no to.
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