[Agent Fix]: Old tail anchor not found after old head#338
Open
kamranjon wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary: Fix anchored edit tail anchor search
Bug:
editwith[upto]always fails withold tail anchor not found after old head, blocking large anchored replacements.Root Cause: In
agent_edit_find_old_span(), the tail string includes a leading\n(from[upto]\n), but the file after the head match has no such newline — so the tail needle never matches.Fix: Strip leading
\n/\rfrom the tail before searching. The head already ends with that newline.Changes (
ds4_agent.clines 5871–5879):\n/\rfromtail/tail_len.\n) and Windows (\r\n) line endings.\nand model-written\nafter[upto].agent_span_has_nonspaceguard (moved after the strip) still rejects empty/whitespace-only tails.match_lenremains correct because the head's trailing newline is counted inhead_len.Testing: Compiles cleanly with
-Wall -Wextra, all edge cases verified. [upto] edits actually work. I had to go back to a sha from 2 weeks ago to find an agent that could properly use the edit tool again to make this change: d447bdb - but tested with newest build and agent is able to edit reliably again!