Skip to content

[Other] An edit copies the exact text instead of retyping it, and says so when it does not match - #4448

Closed
xvcezrqpbxtpzblrt wants to merge 2 commits into
Niko1221:mainfrom
xvcezrqpbxtpzblrt:agent/edit-exact-027
Closed

xvcezrqpbxtpzblrt wants to merge 2 commits into
Niko1221:mainfrom
xvcezrqpbxtpzblrt:agent/edit-exact-027

Conversation

@xvcezrqpbxtpzblrt

Copy link
Copy Markdown
Contributor

Problem

In one real session (103 turns, 3,868 steps) the agent made 1,446 edits and 87 of them failed (6%). The breakdown of the errors in that session:

code count what happened
FS_EDIT_NOT_FOUND 43 the text to replace was not in the file
FS_STALE_VERSION 18 the file changed after it was read
FS_NOT_OBSERVED 13 an edit without reading the file first
FS_SANDBOX_DENIED 2 a real permission refusal

So drive access was not the problem (2 refusals, not 120), and no run had more than three failures in a row: these were wasted attempts spread through the work, not a loop.

Two things were missing:

  • nothing in the app's standing rules said to copy the old text from the file instead of retyping it, or to re-read after a failed edit;
  • 43 of those failures reached the chat as the tool's own words, old_string was not found in "D:\…", because plainToolError had no sentence for that error.

Result

  • The standing prompt says: copy the text an edit replaces from the file just read, exactly, spaces and line breaks included, never retype it; if an edit says the text was not found or the file changed, read the file again and edit afresh.
  • That failure now reads in plain words: "The file was not changed: the text to replace is not in it. The assistant will read the file again and retry." The original text stays after it as Details, as every other tool failure does.

Validation

  • node --test tests/agent-tools.test.mjs tests/functional-fixes.test.mjs tests/agent-events.test.mjs → 77 tests, 64 pass, 13 skipped (the Harness cases), 0 fail; the new assertion covers old_string was not found.
  • The prompt is 1,907 characters (about 480 tokens) against the 2,600 ceiling.

Limits

  • The rule is wording: a model can still retype from memory. What the app controls is the plain sentence and the fact that the failure is visible.
  • No guard stops a turn after failed edits. The data did not support one: the longest run was 3, and a turn stop would have thrown away the work around it.
  • Based on [Other] A tool call written as text is shown as not run #4447 (it adds the other rule to the same prompt); that one should merge first.

@xvcezrqpbxtpzblrt

Copy link
Copy Markdown
Contributor Author

Superseded by #4606, which carries this change with the rest of the 0.2.7 branch. Closing so the review has one place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant