Skip to content

fix: re-read files after formatting in apply_patch#15893

Open
JDNdeveloper wants to merge 2 commits intoanomalyco:devfrom
JDNdeveloper:fix/apply-patch-reread-after-format
Open

fix: re-read files after formatting in apply_patch#15893
JDNdeveloper wants to merge 2 commits intoanomalyco:devfrom
JDNdeveloper:fix/apply-patch-reread-after-format

Conversation

@JDNdeveloper
Copy link
Copy Markdown

@JDNdeveloper JDNdeveloper commented Mar 3, 2026

Issue for this PR

Closes #15897

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The edit tool re-reads files and recomputes diffs after the formatting pipeline runs, so that metadata reflects the actual on-disk state. apply_patch was missing this step, causing formatter changes (quote normalization, extra newlines, etc.) to NOT appear in the diff despite being applied to the file.

This PR updates the behavior of the apply_patch tool to match the edit tool.

NOTE: Motivating issue was #15864, though it turned out to be somewhat unrelated (I didn't realize there's a formatter that runs after edits).

How did you verify your code works?

Ran local dev and confirmed apply_patch behavior (using ChatGPT) now matches edit tool (using local model) (see screenshots below).

Screenshots / recordings

edit tool:
edit tool

apply_patch tool before the fix (despite the actual file having the second line edited as well!):
apply_patch tool before fix

apply_patch tool after the fix:
apply_patch tool after fix

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

If you do not follow this template your PR will be automatically rejected.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 3, 2026

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@JDNdeveloper JDNdeveloper force-pushed the fix/apply-patch-reread-after-format branch from 006609a to c6d5f6c Compare March 5, 2026 20:21
The edit tool re-reads files and recomputes diffs after the formatting
pipeline runs, so that metadata reflects the actual on-disk state.
apply_patch was missing this step, causing unintended stylistic changes
(quote normalization, extra newlines, etc.) to appear in the diff
without being accounted for.

Closes anomalyco#15864
@JDNdeveloper JDNdeveloper force-pushed the fix/apply-patch-reread-after-format branch from c6d5f6c to 6b28206 Compare March 7, 2026 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

apply_patch tool diff does not reflect formatter changes

2 participants