codex - 💡(How to fix) Fix apply_patch tool hangs indefinitely on tiny patch in /private/tmp

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

  • no success/error/completion line for the tool call

Root Cause

This is blocking because Codex coding sessions rely on apply_patch for safe manual edits. The current workaround is to avoid apply_patch and use shell-based file edits followed by git diff verification, but that is less safe and bypasses the intended workflow.

Fix Action

Fix / Workaround

The Codex apply_patch tool hangs indefinitely even for a one-line patch against a tiny file in /private/tmp. This reproduces after restarting and updating Codex, and it affects multiple sessions on the same macOS machine.

Normal shell file writes and reads complete immediately, so this appears isolated to the apply_patch tool/tool-bridge path rather than disk, git, or the target repository.

codex doctor also reported provider reachability/DNS failures for chatgpt.com/api.github.com, but the session itself could continue and normal shell commands worked. The apply_patch hang reproduced locally in /private/tmp, before any network operation should be needed.

Code Example

mkdir -p /private/tmp/apply-patch-test && printf 'a\n' > /private/tmp/apply-patch-test/t.txt && cat /private/tmp/apply-patch-test/t.txt

---

*** Begin Patch
*** Update File: /private/tmp/apply-patch-test/t.txt
@@
-a
+b
*** End Patch
RAW_BUFFERClick to expand / collapse

What happened?

The Codex apply_patch tool hangs indefinitely even for a one-line patch against a tiny file in /private/tmp. This reproduces after restarting and updating Codex, and it affects multiple sessions on the same macOS machine.

Normal shell file writes and reads complete immediately, so this appears isolated to the apply_patch tool/tool-bridge path rather than disk, git, or the target repository.

Environment

  • Codex CLI: codex-cli 0.133.0
  • Platform from codex doctor --json: macos-aarch64
  • Install method: npm package @openai/codex
  • Auth mode: ChatGPT auth
  • Sandbox: restricted filesystem + restricted network, approval OnRequest
  • codex doctor state DB checks: state_5.sqlite, logs_2.sqlite, and goals_1.sqlite all reported integrity ok
  • Disk check: about 80 GiB free; inode pressure negligible

codex doctor also reported provider reachability/DNS failures for chatgpt.com/api.github.com, but the session itself could continue and normal shell commands worked. The apply_patch hang reproduced locally in /private/tmp, before any network operation should be needed.

Minimal reproduction

  1. Create a tiny file:
mkdir -p /private/tmp/apply-patch-test && printf 'a\n' > /private/tmp/apply-patch-test/t.txt && cat /private/tmp/apply-patch-test/t.txt

This completes immediately and prints a.

  1. Ask Codex to run this apply_patch tool call:
*** Begin Patch
*** Update File: /private/tmp/apply-patch-test/t.txt
@@
-a
+b
*** End Patch

Expected behavior

The tool should return quickly and update the file from a to b.

Actual behavior

The tool call does not return. After about 100 seconds I interrupted it. The file remained unchanged as a.

Earlier, a larger apply_patch call in a separate worktree also hung until manually interrupted. Local log timing for that case showed the task closing only after interrupt, with approximately time.idle=8104s.

Relevant local log pattern

From ~/.codex/log/codex-tui.log, the pattern is:

  • ToolCall: apply_patch ...
  • no success/error/completion line for the tool call
  • manual interrupt later
  • task closes only after interrupt, with long idle time

For the tiny /private/tmp repro, the preceding normal shell command was logged and completed immediately, then the apply_patch tool call was logged and never completed until interrupt.

Notes

This is blocking because Codex coding sessions rely on apply_patch for safe manual edits. The current workaround is to avoid apply_patch and use shell-based file edits followed by git diff verification, but that is less safe and bypasses the intended workflow.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

The tool should return quickly and update the file from a to b.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

codex - 💡(How to fix) Fix apply_patch tool hangs indefinitely on tiny patch in /private/tmp