apply_patch Delete File fails on writable paths even when Add/Update succeed
What version of Codex CLI is running?
codex-cli 0.121.0
Which model were you using?
gpt-5.4
What platform is your computer?
Linux 6.12.76-linuxkit aarch64
What terminal emulator and version are you using (if applicable)?
bash
What issue are you seeing?
apply_patch can successfully create and update a disposable text file, but the corresponding Delete File patch fails on the same file in the same session.
Observed behavior in one session:
Add FilesucceedsUpdate FilesucceedsDelete Filefails with:
Failed to delete file /path/to/file
I reproduced this on both:
- a disposable file inside the workspace
- a disposable file under
/tmp
As a control, normal shell deletion of the same probe files succeeds immediately.
This looks narrower than the generic “patch hunk did not match” case: update mismatches still produce the expected Failed to find expected lines verification error, but Delete File fails even when the target file definitely exists and was just created/updated by apply_patch itself.
What steps can reproduce the bug?
Minimal repro with a disposable file:
- Use
apply_patchto add a file:
*** Begin Patch
*** Add File: tmp/codex-apply-patch-smoke.txt
+alpha
+beta
*** End Patch
- Use
apply_patchto update the same file:
*** Begin Patch
*** Update File: tmp/codex-apply-patch-smoke.txt
@@
alpha
-beta
+beta-updated
+gamma
*** End Patch
- Use
apply_patchto delete the same file:
*** Begin Patch
*** Delete File: tmp/codex-apply-patch-smoke.txt
*** End Patch
- Observe failure:
Failed to delete file /.../tmp/codex-apply-patch-smoke.txt
- Verify the file still exists.
- Run normal shell deletion (
rm -f tmp/codex-apply-patch-smoke.txt) as a control; it succeeds.
I also reproduced the same delete failure with /tmp/codex-apply-patch-smoke.txt, so this did not seem limited to one filesystem path.
What is the expected behavior?
apply_patch should support Delete File on the same writable paths where it already supports Add File and Update File in the same session.
Additional information
A few details that may help isolate it:
- The session also had a separate Linux sandbox issue for non-escalated shell commands (
bwrap: No permissions to create a new namespace), but this delete failure still reproduced as a distinctapply_patchbehavior after add/update succeeded. - The disposable repro above does not require any project-specific files or private code.
- I intentionally used throwaway probe files only.