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

Closed
opened 2026-11-07 16:32:20 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/4448
Author: @xvcezrqpbxtpzblrt
Created: 10/28/2026
Status: ❌ Closed

Base: main ← Head: agent/edit-exact-027


📝 Commits (2)

  • ed85bf8 [Other] A tool call written as text is shown as not run
  • ef8dd38 [Other] An edit copies the exact text instead of retyping it, and says so when it does not match

📊 Changes

18 files changed (+241 additions, -16 deletions)

View changed files

📝 apps/host/server/agent/agent-bridge.mjs (+2 -0)
📝 apps/host/server/agent/events.mjs (+128 -5)
📝 apps/host/server/agent/preset.mjs (+2 -1)
📝 apps/host/server/agent/turn-guard.mjs (+3 -0)
📝 apps/host/src/locales/de.json (+5 -1)
📝 apps/host/src/locales/en.json (+5 -1)
📝 apps/host/src/locales/es.json (+5 -1)
📝 apps/host/src/locales/fr.json (+5 -1)
📝 apps/host/src/locales/ja.json (+5 -1)
📝 apps/host/src/locales/ko.json (+5 -1)
📝 apps/host/src/locales/pt.json (+5 -1)
📝 apps/host/src/locales/ru.json (+5 -1)
📝 apps/host/src/locales/zh.json (+5 -1)
📝 apps/host/tests/agent-events.test.mjs (+36 -0)
📝 apps/host/tests/agent-tools.test.mjs (+1 -0)
📝 apps/host/tests/agent-turn-guard.test.mjs (+14 -0)
📝 apps/host/tests/functional-fixes.test.mjs (+5 -1)
📝 apps/host/tests/helpers/scripted-worker.mjs (+5 -0)

📄 Description

## 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 #4447 (it adds the other rule to the same prompt); that one should merge first.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/4448 **Author:** [@xvcezrqpbxtpzblrt](https://github.com/xvcezrqpbxtpzblrt) **Created:** 10/28/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `agent/edit-exact-027` --- ### 📝 Commits (2) - [`ed85bf8`](https://github.com/Niko1221/Strata/commit/ed85bf85fe023554ed207de8a3d99a12f72b97b0) [Other] A tool call written as text is shown as not run - [`ef8dd38`](https://github.com/Niko1221/Strata/commit/ef8dd383e805bd8f07fc5155326950f0d678ecc3) [Other] An edit copies the exact text instead of retyping it, and says so when it does not match ### 📊 Changes **18 files changed** (+241 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `apps/host/server/agent/agent-bridge.mjs` (+2 -0) 📝 `apps/host/server/agent/events.mjs` (+128 -5) 📝 `apps/host/server/agent/preset.mjs` (+2 -1) 📝 `apps/host/server/agent/turn-guard.mjs` (+3 -0) 📝 `apps/host/src/locales/de.json` (+5 -1) 📝 `apps/host/src/locales/en.json` (+5 -1) 📝 `apps/host/src/locales/es.json` (+5 -1) 📝 `apps/host/src/locales/fr.json` (+5 -1) 📝 `apps/host/src/locales/ja.json` (+5 -1) 📝 `apps/host/src/locales/ko.json` (+5 -1) 📝 `apps/host/src/locales/pt.json` (+5 -1) 📝 `apps/host/src/locales/ru.json` (+5 -1) 📝 `apps/host/src/locales/zh.json` (+5 -1) 📝 `apps/host/tests/agent-events.test.mjs` (+36 -0) 📝 `apps/host/tests/agent-tools.test.mjs` (+1 -0) 📝 `apps/host/tests/agent-turn-guard.test.mjs` (+14 -0) 📝 `apps/host/tests/functional-fixes.test.mjs` (+5 -1) 📝 `apps/host/tests/helpers/scripted-worker.mjs` (+5 -0) </details> ### 📄 Description ## 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 #4447 (it adds the other rule to the same prompt); that one should merge first. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 16:32:20 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#5054
No description provided.