Codex Desktop on Windows: apply_patch and some exec processes hang indefinitely

Resolved 💬 1 comment Opened Jul 22, 2026 by david-rzepa Closed Jul 26, 2026
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

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:

  1. Outer tool: functions.exec
  2. Nested tool: tools.apply_patch(input)
  3. Result polling tool: functions.wait({ cell_id, ... })

Shell reproduction path:

  1. Outer tool: functions.exec
  2. Nested tool: tools.exec_command({ cmd: "apply_patch", ... })
  3. 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(...):

  • tasklist
  • where.exe apply_patch
  • Get-Process -Name apply_patch
  • cmd.exe /d /c dir ...index.lock
  • a bundled Node.js command running the Codex manual helper

Reproduction

  1. Open a repository in Codex Desktop on Windows.
  2. Ask Codex to make a small source edit.
  3. Call functions.exec with:

``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);
``

  1. The call returns only:

``
Script running with cell ID <id>
``

  1. Poll with functions.wait for 30-60 seconds. It remains running with no output.
  2. Even a no-op one-line patch and a single-file patch behave the same.
  3. 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_patch still 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_patch never resolves and emits no diagnostic output.
  • functions.wait continues reporting the cell as running.
  • Cancellation is the only recovery.
  • Some tools.exec_command processes hang similarly, while rg completes 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.exec cell.
  • Investigate why native short-lived commands such as rg finish while apply_patch, process-enumeration commands, and Node commands remain alive without output.

View original on GitHub ↗

1 Comment

github-actions[bot] contributor · 1 month ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #34171
  • #34290
  • #33719

Powered by Codex Action