Codex Desktop on Windows: apply_patch and some exec processes hang indefinitely
Summary
On Codex Desktop for Windows, file editing becomes unusable because apply_patch hangs indefinitely. The failure occurs both through the orchestrated tool call and when invoking apply_patch as a shell command. Several other spawned processes also hang, while short commands such as rg continue to work.
This prevents Codex from making any workspace edits while still allowing it to inspect files, creating a misleading partially-functional state.
Environment
- Surface: Codex Desktop
- OS: Windows (PowerShell)
- Workspace path:
C:\workspace\repo(redacted) - Sandbox mode:
workspace-write - Bundled workspace dependency version reported by
codex_app__load_workspace_dependencies:26.715.12143 - Date observed: 2026-07-22
Exact tool names involved
Primary failing path:
- Outer tool:
functions.exec - Nested tool:
tools.apply_patch(input) - Result polling tool:
functions.wait({ cell_id, ... })
Shell reproduction path:
- Outer tool:
functions.exec - Nested tool:
tools.exec_command({ cmd: "apply_patch", ... }) - Result polling tool:
functions.wait({ cell_id, ... })
Control calls that completed:
functions.exec->tools.exec_command({ cmd: "rg ...", ... })functions.exec->tools.codex_app__load_workspace_dependencies({})functions.exec->tools.mcp__codex_apps__github_search_issues(...)
Additional commands observed hanging through functions.exec -> tools.exec_command(...):
tasklistwhere.exe apply_patchGet-Process -Name apply_patchcmd.exe /d /c dir ...index.lock- a bundled Node.js command running the Codex manual helper
Reproduction
- Open a repository in Codex Desktop on Windows.
- Ask Codex to make a small source edit.
- Call
functions.execwith:
``js``
const r = await tools.apply_patch(
"*** Begin Patch\n" +
"*** Update File: path/to/file\n" +
"@@\n" +
"-old line\n" +
"+new line\n" +
"*** End Patch"
);
text(r);
- The call returns only:
````
Script running with cell ID <id>
- Poll with
functions.waitfor 30-60 seconds. It remains running with no output. - Even a no-op one-line patch and a single-file patch behave the same.
- The task must be manually terminated with:
``json``
{ "cell_id": "<id>", "terminate": true }
Directly invoking apply_patch using tools.exec_command also hangs.
Git lock investigation
A lock initially existed at:
C:\workspace\repo\.git\worktrees\<redacted-worktree>\index.lock
The user confirmed no other task was running. The exact stale lock was removed with:
functions.exec->tools.exec_command- command:
Remove-Item -LiteralPath 'C:\workspace\repo\.git\worktrees\<redacted-worktree>\index.lock' sandbox_permissions: "require_escalated"
After removal:
rg --files .git -g 'index.lock'returned no lock.tools.apply_patchstill hung for more than 120 seconds on a one-line edit.- No requested workspace files were changed.
Therefore the stale Git lock was not the cause.
Expected behavior
tools.apply_patch should either:
- apply the patch and return a success/error result promptly, or
- fail with a bounded timeout and actionable error output.
Spawned commands should not remain indefinitely in a silent Script running with cell ID state.
Actual behavior
tools.apply_patchnever resolves and emits no diagnostic output.functions.waitcontinues reporting the cell as running.- Cancellation is the only recovery.
- Some
tools.exec_commandprocesses hang similarly, whilergcompletes normally. - Restarting the individual tool call and removing the Git lock do not recover editing.
Impact
Severity: high/blocking.
Codex can read and reason about the repository but cannot safely edit it. When repository instructions require using apply_patch, there is no compliant fallback. Repeated retries consume minutes and make Codex Desktop effectively unusable for coding work.
Suggested diagnostics
- Surface child-process lifecycle and stderr for
tools.apply_patch. - Add a bounded timeout/error for patch execution.
- Check for orphaned process or PTY/session handles after a terminated
functions.execcell. - Investigate why native short-lived commands such as
rgfinish whileapply_patch, process-enumeration commands, and Node commands remain alive without output.
1 Comment
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action