Detect and reject overlapping edit ranges in streaming_edit_file_tool#48547
Merged
Detect and reject overlapping edit ranges in streaming_edit_file_tool#48547
Conversation
22f3e18 to
0ef67f1
Compare
Contributor
…atch error to use line numbers - Compute first_edit_line from the sorted edits list so the emitted location always points to the earliest edited line in the file, regardless of the order edits were provided. - Convert byte offsets to 1-indexed line numbers in the ambiguous match error message so the LLM gets accurate line references instead of raw byte offsets.
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.
In
streaming_edit_file_tool.rs, edits are sorted in reverse order and applied sequentially. If the LLM produces overlapping edit ranges, the first applied edit shifts the buffer, and the second edit's range targets stale offsets, leading to incorrect results.This adds a
windows(2)check on the sorted (descending by start) edits that verifies each earlier-in-file range's end does not exceed the next later-in-file range's start. The validation is done before entering the buffer update closure so the error can propagate cleanly viaanyhow::bail!.Release Notes: