macOS: internal apply_patch intermittently times out on simple edits

Open 💬 1 comment Opened Apr 14, 2026 by andrewalex

Summary

On macOS ARM64 with codex-cli 0.120.0, the internal apply_patch tool intermittently hangs for about 10 seconds and returns exit code 124 on simple file edits. The same patch often succeeds on a later retry. In one repro, adding *** End of File to the patch made the retry succeed immediately.

This does not appear to be an installation problem:

  • codex --version reports codex-cli 0.120.0
  • the native binary is present via the normal npm-installed wrapper
  • there is no standalone apply_patch executable on PATH, which appears to be expected because apply_patch is an internal tool

Environment

  • Host: Mac mini
  • OS: Darwin 25.3.0 / macOS ARM64
  • Codex CLI: 0.120.0
  • Install path: /opt/homebrew/bin/codex
  • Wrapper target: /opt/homebrew/lib/node_modules/@openai/codex/bin/codex.js
  • Native package: @openai/codex-darwin-arm64

Repro

Create a scratch file:

tmpdir=$(mktemp -d /tmp/codex-applypatch2.XXXXXX)
printf 'one\ntwo\n' > "$tmpdir/sample.txt"

Run Codex in writable exec mode:

codex exec --json --full-auto --skip-git-repo-check --cd "$tmpdir" \
  'Edit sample.txt to replace two with two patched, using apply_patch if available.'

What happened in the recorded session:

  1. Codex read sample.txt correctly.
  2. Codex invoked internal apply_patch with:
*** Begin Patch
*** Update File: sample.txt
@@
-two
+two patched
*** End Patch
  1. The tool returned:
command timed out after 10010 milliseconds

with metadata:

{"exit_code":124,"duration_seconds":10.0}
  1. The file was unchanged after the timeout.
  2. A retry with the same minimal patch also timed out.
  3. A later retry with:
*** Begin Patch
*** Update File: sample.txt
@@
-two
+two patched
*** End of File
*** End Patch

then succeeded immediately.

Observed Behavior

  • First apply_patch attempt often times out after ~10 seconds.
  • The target file remains unchanged after the timeout.
  • A later retry may succeed.
  • In at least one repro, adding *** End of File changed the outcome from timeout to success.
  • Enabling apply_patch_freeform did not eliminate the first-attempt timeout in my testing.

Expected Behavior

The minimal patch should either:

  • apply successfully on the first attempt, or
  • fail quickly with a deterministic parse/verification error

It should not hang for ~10 seconds on a tiny local file.

Notes

  • This was reproducible outside the local harness sandbox, so it does not appear to be caused by the harness blocking writes.
  • I also found the same command timed out after 10010 milliseconds pattern in earlier interactive Codex logs, so this does not look specific to codex exec.

If useful, I can provide the exact JSONL session log excerpt and the matching codex-tui.log lines.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗