Skip to content

fix: Edit tool false positive 'failed' error#1943

Open
BingqingLyu wants to merge 2 commits intomainfrom
fork-pr-60664-fix-edit-tool-false-positive
Open

fix: Edit tool false positive 'failed' error#1943
BingqingLyu wants to merge 2 commits intomainfrom
fork-pr-60664-fix-edit-tool-false-positive

Conversation

@BingqingLyu
Copy link
Copy Markdown
Owner

@BingqingLyu BingqingLyu commented Apr 28, 2026

Root cause: Recovery logic used simple 'includes' checks which failed when:

  1. newText pre-existed in file (false positive success)
  2. oldText was substring of newText (e.g. 'foo' -> 'foobar')

Fix: Use before/after occurrence counts for robust detection:

  1. Count newText occurrences before and after edit
  2. Verify newText count increased (not just present)
  3. Strip newText when checking oldText to handle substring case
  4. Verify oldText count decreased when original available

Fixes openclaw#54455, fixes openclaw#49363

admin and others added 2 commits April 4, 2026 09:46
Root cause: UI used lifetime accumulated tokens (totalTokens) for
context percentage, which stays high after compaction. Should use
current window tokens (post-compaction) instead.

Fix:
1. Add currentWindowTokens field to GatewaySessionRow type
2. Gateway computes it: when totalTokensFresh=false (post-compaction),
   use transcriptUsage.totalTokens (current window), else use totalTokens
3. UI uses currentWindowTokens for context % calculation, with
   fallback to totalTokens for backwards compatibility
4. Remove early return when totalTokensFresh=false - now shows
   correct post-compaction percentage via currentWindowTokens

Fixes openclaw#48252
…g of newText

Root cause: Recovery logic used simple 'includes' checks which failed when:
1. newText pre-existed in file (false positive success)
2. oldText was substring of newText (e.g. 'foo' -> 'foobar')

Fix: Use before/after occurrence counts for robust detection:
1. Count newText occurrences before and after edit
2. Verify newText count increased (not just present)
3. Strip newText when checking oldText to handle substring case
4. Verify oldText count decreased when original available

Fixes openclaw#54455, fixes openclaw#49363
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant