fix(tools): count chained StrReplaceFile edits against intermediate content - #2569
Open
aalhadxx wants to merge 1 commit into
Open
fix(tools): count chained StrReplaceFile edits against intermediate content#2569aalhadxx wants to merge 1 commit into
aalhadxx wants to merge 1 commit into
Conversation
…ontent The StrReplaceFile tool tallied every edit against the original file text. When a later edit looked for text produced by an earlier one, it was counted as zero even though it was successfully applied. Move the replacement counter into the edit-application loop so each edit is scored against the content as it exists just before that edit. Fixes MoonshotAI#2526
This was referenced Jul 29, 2026
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.
Problem
The
StrReplaceFiletool tallied every edit against the original file text. When a later edit looked for text produced by an earlier one, it was counted as zero even though it was successfully applied.Reproduction
Before this fix the tool reported 1 total replacement but the file ended up as .
Fix
Move the replacement counter into the edit-application loop so each edit is scored against the content as it exists just before that edit.
Test
Added
test_replace_chained_edits_countto verify that chained edits report the correct total replacement count.Fixes #2526