Skip to content

macOS: internal apply_patch intermittently times out on simple edits #17834

Open

Description

@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.

Activity

  1. added
    bug
    CLI
    tool-calls
    on Apr 14, 2026
  2. andrewalex commented on Apr 14, 2026

    @andrewalex
    Author

    Additional redacted repro detail from a local codex exec --json --full-auto run.

    Failed attempts used this exact patch on a tiny 2-line file:

    *** Begin Patch
    *** Update File: sample.txt
    @@
    -two
    +two patched
    *** End Patch

    Tool output on the failed attempts:

    command timed out after 10010 milliseconds
    

    Metadata:

    {"exit_code":124,"duration_seconds":10.0}

    After each timeout, the file contents were unchanged.

    A later retry succeeded when the patch included explicit EOF context:

    *** Begin Patch
    *** Update File: sample.txt
    @@
    -two
    +two patched
    *** End of File
    *** End Patch

    That succeeded immediately with normal success output:

    Success. Updated the following files:
    M sample.txt
    

    I also tried the apply_patch_freeform feature flag locally and still saw the first-attempt timeout pattern.

  3. removed
    CLI
    on Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugtool-calls

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions