Repository navigation
fix(apply-diff): reject partially matched stacked anchors - #4431
Conversation
seratch
left a comment
There was a problem hiding this comment.
Before merge, please add the released-compatibility regression covered in openai/openai-agents-js#1655: two stacked hunks in the same parent block must be able to reuse a parent anchor that is already before the current cursor, while each child anchor still matches forward. The implementation already appears to preserve this behavior; the missing test is needed because this PR rewrites that exact match-accounting branch.
|
Added in bec42e8. The new public |
Summary
This pull request fixes stacked
@@anchors so every non-empty anchor in a stack must match in sequence. Previously, if one anchor matched and a later anchor did not,apply_diffcontinued from the partial match and could apply the hunk body to unrelated nearby content.Single unmatched anchors keep their existing context fallback. Bare anchors, whitespace-fuzzy matches, and fully matched stacks also keep their existing behavior. A partially matched stack now raises
ValueErrorbefore edited content is returned; the sandbox boundary converts that error toApplyPatchDiffErrorbefore writing the file.This brings the Python parser in line with the same safety rule added in openai/openai-agents-js#1655.
Test plan
.agents/skills/code-change-verification/scripts/run.shwith format, lint, typecheck, and the complete test suite passing.Issue number
N/A. Found while comparing stacked-anchor behavior across the Python and JavaScript SDKs.
Checks
.agents/skills/code-change-verification/scripts/run.sh/reviewbefore submitting this PR