agent: reject edit calls whose new= text contains [upto]#421
Open
aledesogusbusiness-hue wants to merge 1 commit into
Open
agent: reject edit calls whose new= text contains [upto]#421aledesogusbusiness-hue wants to merge 1 commit into
aledesogusbusiness-hue wants to merge 1 commit into
Conversation
[upto] is an anchor marker that belongs only in the old= parameter of an edit tool call. If the model accidentally emits it in the new= parameter the literal string gets spliced into the file, leaving obvious corruption that triggers the system to retry the same patch, which fails again with the same outcome. Guard agent_tool_edit() against this: return a Tool error immediately when new_text contains "[upto]" so the model gets corrective feedback instead of writing the marker to disk. Fixes: antirez#408 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
[upto]is an anchor marker that belongs only in theold=parameter of anedittool call, where it acts as a range wildcard between a unique head and tail.If the model accidentally emits
[upto]inside thenew=parameter,agent_tool_edit()passesnew_textstraight toagent_apply_file_splice(), which splices the literal string — including[upto]— into the file. The resulting file corruption triggers the system to retry the patch, which fails again with the same outcome, looping.Fix
Add a guard in
agent_tool_edit()that returns aTool errorimmediately whennew_textcontains"[upto]". This gives the model corrective feedback on the next turn rather than writing the marker to disk.Test plan
new=includes[upto]; verify the tool returns the error string and leaves the file unchanged.[upto]only inold=are unaffected.Fixes #408
🤖 Generated with Claude Code