fix: preserve exact turn diffs after partial apply_patch failures#21518
fix: preserve exact turn diffs after partial apply_patch failures#21518
Conversation
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f55724e027
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
fcoury-oai
left a comment
There was a problem hiding this comment.
I manually tested the happy path by creating a workspace where apply_patch could write the move destination but fail removing the locked source.
The file-change item failed, the locked file remained unchanged, but the destination file wwas updated with the proper contents.
It also still streamed a turn diff containing the committed destination change as expected.
Code looks good, approved! 👍
Why
Follow-up to #21180: turn diffs are operation-backed now, but a failed
apply_patchcan still leave exact filesystem mutations behind. For example, a move can write the destination file before failing to remove the source. Treating the whole call as unknowable then drops a change that Codex actually knows happened, so the emitted turn diff can drift from the workspace.What changed
apply-patchnow returnsApplyPatchFailurewith the exact committed prefix accumulated before an error. If a write failure may already have mutated the target, the delta is marked inexact instead of being reused blindly.ApplyPatchRuntimenow accumulates committed deltas across attempts and forwards them even when the visible tool result is failed or sandbox-denied (runtime path, event path).TurnDiffTrackernow consumes committed exact deltas rather than only fully successful patches; exact-empty failures leave the aggregate unchanged, while inexact deltas still invalidate it.Verification
apply_patch_failed_move_preserves_committed_destination_diff.apply_patch_clears_aggregated_diff_after_inexact_delta.