codex icon indicating copy to clipboard operation
codex copied to clipboard

Windows Desktop: unbounded taskkill.exe/conhost.exe cleanup storm exhausts WMI

Open RocStone opened this issue 4 months ago • 14 comments

Summary

Codex Desktop on Windows can enter an unbounded process-cleanup loop where hundreds of taskkill.exe processes remain alive, each with a corresponding conhost.exe. The accumulated taskkill instances repeatedly query Win32_Process, exhaust the WMI provider quota, and make the entire Windows UI sluggish or unable to launch new processes.

This is related to #17229 and #21957, but the leaking processes in this case are taskkill.exe themselves rather than only git.exe/conhost.exe or leaked stdout.

Environment

  • Codex Desktop: 26.715.4045.0
  • OS: Windows 25H2 x64, build 26200.8875
  • RAM: 32 GB
  • Installation: Microsoft Store/MSIX package OpenAI.Codex_26.715.4045.0_x64__2p2nqsd0c76g0

Observed behavior

During normal local-agent use involving shell commands, cancellations, and command timeouts, process counts grew continuously.

Peak measurements:

  • taskkill.exe: 457 processes
  • conhost.exe: 473 processes
  • total processes: 1,388
  • total threads: over 14,000
  • total handles: over 350,000
  • WMI provider private memory: 720.5 MB

All sampled taskkill.exe instances had the Codex Desktop main process (ChatGPT.exe inside the OpenAI.Codex package) as their parent. Most excess conhost.exe instances were children of those taskkill.exe processes.

Windows Event Viewer recorded:

  • WMI event 5612: PrivatePageCount exceeded its 512 MB quota.
  • WMI event 5612: ThreadCount exceeded its 256-thread quota.
  • WMI Activity event 5858: repeated Win32_Process queries failed with 0x80041006 and 0x80041033.
  • taskkill.exe crashed with exception 0xc0000005 (Application Error event 1000 / Windows Error Reporting event 1001).

Killing the accumulated taskkill.exe processes immediately reduced the total process count from 1,388 to about 565, and WMI private memory fell from 720.5 MB to about 104 MB. However, while the original Codex process remained running, taskkill.exe counts grew again from 156 to 320 in 20 seconds.

Fully restarting/reinstalling Codex cleared the bad state. With the same app version reinstalled, the stable baseline was:

  • taskkill.exe: 0
  • conhost.exe: 12
  • total processes: about 390
  • WMI: 139 MB private memory / 54 threads

Because the reinstalled version is identical, this appears to clear the accumulated state rather than fix the underlying bug.

Relevant packaged-app implementation

Inspection of the installed app.asar shows that the Windows process-tree cleanup path invokes approximately:

execFile(taskkill.exe, ["/pid", pid, "/t", "/f"], {
  windowsHide: true,
});

The call does not appear to set a timeout. Cleanup is deduplicated per execution object, but there is no apparent global concurrency limit, backoff, or circuit breaker across multiple local executions. If taskkill.exe hangs because process enumeration/WMI is unhealthy, later cleanups can start additional taskkill.exe instances indefinitely.

Steps that may reproduce

  1. Open Codex Desktop on Windows and a local repository.
  2. Run multiple local shell operations, including operations that time out or are cancelled.
  3. Observe taskkill.exe and conhost.exe in Task Manager or Process Explorer.
  4. If WMI/process enumeration becomes slow, observe whether taskkill.exe instances remain alive and increase continuously.
  5. Keep the app open and observe WMI event 5858 failures and growing process/thread/handle counts.

The trigger is intermittent; the unbounded accumulation after the first stuck cleanup is the main defect.

Expected behavior

  • A process-tree cleanup should complete or time out within a bounded period.
  • Codex should not run hundreds of concurrent taskkill.exe cleanup processes.
  • Repeated cleanup failures should activate backoff/circuit breaking and surface one actionable error to the user.
  • Failure of WMI/process enumeration should not cause a system-wide process storm.

Suggested fixes

  1. Add a timeout to the taskkill.exe invocation and forcibly terminate a stuck cleanup helper.
  2. Add a process-wide single-flight or small concurrency limit for Windows tree cleanup.
  3. Add exponential backoff/circuit breaking after repeated cleanup failures.
  4. Prefer Windows Job Objects or direct Win32 process-tree termination instead of spawning taskkill.exe for every cleanup.
  5. Log the target PID, duration, exit status, and number of concurrent cleanup operations.

RocStone avatar Jul 20 '26 03:07 RocStone

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

  • #33776
  • #33778
  • #34001
  • #34025

Powered by Codex Action

github-actions[bot] avatar Jul 20 '26 03:07 github-actions[bot]

I'm also affected by this issue and would appreciate any updates on the progress. Thanks for the work on this.

frank9306 avatar Jul 20 '26 04:07 frank9306

26.715.4045.0 here also affected by this. My work laptop is frozen with 80% of the CPU wasted on ChatGPT taskkills.

msg7086 avatar Jul 20 '26 05:07 msg7086

I have been suffering from this bug for several days now. I hope it can be fixed as soon as possible.

Image

askxue avatar Jul 20 '26 08:07 askxue

I can reproduce this on a newer Codex Desktop build, so the issue persists beyond 26.715.4045.0.

Environment

  • Codex Desktop: 26.715.7063.0
  • Package: OpenAI.Codex_26.715.7063.0_x64__2p2nqsd0c76g0
  • Windows 11 Pro x64, build 10.0.26200
  • 32 GiB RAM

Reproduction and evidence

After fully quitting Codex, restarting Windows, checking for app updates, and relaunching Codex, the process storm returned.

  • Many live C:\Windows\System32\taskkill.exe /pid <pid> /t /f processes accumulated.
  • Every sampled taskkill.exe had the packaged Codex desktop main process (ChatGPT.exe) as its direct parent.
  • Task Manager showed approximately:
    • Service Host: Windows Management Instrumentation: 14.5% CPU
    • WMI Provider Host: 13.1% CPU
    • ChatGPT/Codex: 8.2% CPU
    • Total system CPU: 67%
  • Even a trivial one-line PowerShell command invoked through Codex timed out.
  • A direct git status --short --untracked-files=no completed in about 0.2 seconds, so repository Git responsiveness was not the trigger in this reproduction.

The Codex desktop log repeatedly reports:

[electron-sampler] Failed to collect child process snapshot
powershell.exe ... Get-CimInstance Win32_Process ...

Windows WMI Activity event 5858 records repeated Win32_Process query failures from the cleanup processes with result codes:

  • 0x80041032
  • 0x800706BE
  • 0x800706BA

Inspection of this build's packaged app.asar also shows that the Electron sampler:

  • constructs the Windows child-process snapshot worker unconditionally,
  • requests a heartbeat snapshot every 30 seconds while the primary window is focused,
  • permits additional triggered snapshots with a 5-second minimum interval.

This appears to amplify the failure: a timed-out WMI snapshot leads to taskkill cleanup; each stuck taskkill performs another Win32_Process query; later sampler cycles add more cleanup processes without effective global backoff/circuit breaking.

The same sampler failure first appears in local Codex logs from 2026-07-15 under desktop build 26.707.9981.0, and continues under 26.715.7063.0. No private paths, repository names, prompts, or raw logs are included here. Sanitized screenshots and selected log/event excerpts are available if maintainers need them.

adfras avatar Jul 20 '26 11:07 adfras

+1. Made whole app completly unuseable. With 2 220$ subscriptions. Great work, devs! win 10, 26.715.52143

levgoriachev avatar Jul 20 '26 16:07 levgoriachev

Confirmed on a newer Microsoft Store build with another Windows 10 reproduction.

Environment

  • Codex Desktop package: OpenAI.Codex_26.715.7063.0_x64__2p2nqsd0c76g0
  • Package status/signature: Ok / Store
  • Bundled ChatGPT.exe file version: 150.0.7871.124
  • OS: Windows 10 Pro 22H2 x64, build 19045.6466
  • Logical processors: 16
  • Observed: 2026-07-21 00:24:08 (Asia/Shanghai)

Observed behavior and evidence

Task Manager showed the following simultaneous CPU spike:

  • Service Host: Windows Management Instrumentation: 14.1%
  • WMI Provider Host: 11.8%

A read-only process/event investigation found:

  • Winmgmt was hosted normally by C:\Windows\System32\svchost.exe -k netsvcs -p.

  • Windows svchost.exe, WmiPrvSE.exe, and taskkill.exe binaries had valid Microsoft signatures.

  • Before the screenshot, the WMI Activity log already contained 742 Event ID 5858 failures from 00:17 through 00:23. The operations repeatedly enumerated Win32_Process and Win32_PerfFormattedData_PerfProc_Process, with result codes including 0x800706BA, 0x80041032, and 0x80041033.

  • One live snapshot found 46 taskkill.exe processes, all direct children of the Codex Desktop main ChatGPT.exe process. Sampled command lines were of the form:

    C:\Windows\System32\taskkill.exe /pid <pid> /t /f
    
  • A later five-second sample started with 212 live taskkill.exe processes and ended with 202 still alive.

  • During one 15-second polling window, 1,092 distinct PIDs were observed (including the initial live set), showing extreme intermittent process churn.

  • A later five-second CPU sample showed Winmgmt and all four WmiPrvSE.exe instances back at 0%, consistent with a bursty query/cleanup storm rather than sustained load.

  • The WMI permanent-subscription check found no CommandLineEventConsumer or ActiveScriptEventConsumer; only the standard SCM event-log subscription was present. No TCP connections were owned by the WMI provider PIDs.

Two later diagnostic commands timed out and may have amplified the subsequent taskkill.exe count. However, the 742 WMI failures and the Task Manager spike occurred before those diagnostics, so the underlying cleanup/query storm was already active.

This matches the unbounded Windows cleanup behavior described in this issue and confirms that it still reproduces in Store build 26.715.7063.0 on Windows 10. A bounded timeout plus global concurrency limit/backoff around taskkill.exe would prevent this failure from escalating into system-wide WMI and process exhaustion.

Usernames, repository paths, conversation contents, and unrelated process details were intentionally omitted. A screenshot of the WMI CPU spike can be provided if useful.

NocturnalSk avatar Jul 20 '26 17:07 NocturnalSk

Additional WPR and controlled Git/MCP isolation evidence

I have an independent reproduction on:

  • Codex Desktop/MSIX 26.715.4045.0
  • Windows 11 25H2, build 26200.8875, x64
  • Native Windows Git repositories, not WSL

A 4.09 GiB Windows Performance Recorder trace captured the process storm with zero lost events or buffers. During its final 385-second incident window:

  • 2,000 genuine taskkill.exe launches occurred.
  • 1,986 were children of the main ChatGPT/Codex Desktop process.
  • 1,908 targeted git.exe.
  • Approximately 1,983 Git launches ran git config --null --get core.fsmonitor.
  • Peak taskkill concurrency was 33, with a peak creation rate of 12 per second.

I later performed a controlled MCP-isolation comparison:

  1. Temporarily disabled all five configurable local MCP servers and performed a clean restart, ending the residual ChatGPT processes that remained after normal close.
  2. Codex still created app-managed Node/Node REPL helpers and rewrote config.toml, removing Node REPL’s disabled flag.
  3. Four Codex-launched Git children remained alive: rev-parse HEAD, remote -v, config --null --get core.fsmonitor, and status --porcelain.
  4. The identical direct git config --null --get core.fsmonitor command completed naturally in 91 ms.
  5. A brand-new control task was instructed to return one line and use no tools. It added two persistent Node/Node REPL helper pairs.
  6. That tool-free task left a Codex-launched git -c core.hooksPath=NUL -c core.fsmonitor=false status --porcelain process alive.
  7. The identical direct status command completed naturally in 98 ms with exit code 0.

Earlier logs also showed automatic title/description sessions initializing complete helper/MCP environments while recording zero MCP tool executions. During the full recurrence, ten matching local helper suites remained resident simultaneously.

Normal application closure was incomplete twice during the follow-up. Residual ChatGPT processes had to be ended through Task Manager; one idle residual group used approximately 755 MB.

This evidence supports a compound lifecycle problem:

  • Git commands launched through Codex can remain stuck even though identical direct commands complete immediately.
  • Visible and hidden sessions can retain eager MCP/helper environments after their work finishes.
  • The retained processes increase memory and process-table pressure.
  • Repeated cleanup through taskkill /T then enumerates that enlarged process table through WMI and can escalate into the reported storm.

After restoring the original MCP configuration and performing a final clean restart, the app was stable with one expected helper suite, zero Git, zero taskkill, and zero exact Win32_Process WMI failures during the final observation. This cleared the accumulated state but did not fix the underlying product defect.

I can provide the full WPR ETL, targeted WPA CSV exports, event-log details, process command lines, and timestamped chronology if useful.

Existing OpenAI feedback ID: 019f7bb3-69e7-7f23-8635-79b16e2eb930.

Related reports: #29408, #33531, and #34251.

Chronology note: #29408 documented the same Git polling command family on Codex versions 26.616.6631.0, 26.623.11225.0, and 26.707.62119. This indicates that the underlying Git polling defect predates 26.715; the WPR evidence above in this comment connects that older behavior to the downstream taskkill/WMI storm.

noman-qadir avatar Jul 20 '26 18:07 noman-qadir

Same issue here, ChatGPT/Codex windows app is stuck in a runaway process-enumeration loop with taskkill.exe whenever launched, causing WMI to get stuck at 25% CPU constantly, lagging my entire PC.

athan614 avatar Jul 20 '26 20:07 athan614

If I launch Codex Desktop directly in user mode, it spawns a large number of terminal processes and keeps failing repeatedly, with up to five or six hundred such processes running. Meanwhile, the WMI Provider Host process consumes over 50% of system resources. However, when I run it as administrator, no excessive terminal processes are created and WMI operates normally. This issue is most likely caused by a permission-checking process that keeps failing and restarting continuously. Right Click Codex And Run As Administrator may be helpful.

q447552640 avatar Jul 21 '26 04:07 q447552640

Thanks.

Follow-up from my machine:

I tested the “run ChatGPT/Codex as administrator” suggestion.

Result: it did not clearly eliminate the issue here. It may have reduced the severity, but the behavior still appeared.

Test summary:

  • Started a lightweight monitor using Get-Process only, sampling ChatGPT/codex/node/git/taskkill/WmiPrvSE.
  • Closed ChatGPT normally.
  • Waited, then ended remaining ChatGPT processes.
  • Relaunched ChatGPT as administrator.
  • Worked for roughly 10 minutes.
  • Closed ChatGPT again.

Observed:

  • Before the admin relaunch, the monitor captured a large spike, including 168 taskkill.exe processes in one sample.
  • After the close/end period, there was a calm interval with no ChatGPT, codex, node, git, or taskkill processes.
  • After relaunching ChatGPT as administrator, taskkill activity still reappeared, along with ChatGPT/codex/node/git activity.
  • The machine felt usable during/after this run, so admin mode may have changed severity, but it did not look like a complete fix on this system.

Conclusion: On my machine, admin launch may reduce severity, but it did not fully stop taskkill.exe activity. This suggests the underlying helper/process cleanup loop may still be active.

noman-qadir avatar Jul 21 '26 18:07 noman-qadir

Additional reproduction on newer build; switching to Work mode was the trigger

This issue still reproduces on a newer Microsoft Store build.

Environment

  • ChatGPT/Codex Desktop MSIX: 26.715.8383.0
  • Package: OpenAI.Codex_26.715.8383.0_x64__2p2nqsd0c76g0
  • Windows 10 Pro 22H2 x64, build 19045.6466
  • 16 logical processors
  • Observed: 2026-07-22 (Asia/Shanghai)

Trigger and user-visible impact

The incident started immediately after switching the newly updated unified desktop app to Work mode with a local folder available.

Task Manager then showed:

  • ChatGPT (630): approximately 630 child processes
  • ChatGPT/Codex group: 19.7% CPU and about 4,046.8 MB memory
  • WMI Provider Host: 49.4% CPU and about 520.3 MB memory
  • Total system CPU: 100%
  • Hundreds of entries displayed as “Terminal Process”

The whole machine became severely degraded.

Process evidence collected before a full restart

A read-only process inventory found multiple retained helper suites:

  • 12 node_repl.exe hosts
  • 12 Firecrawl MCP server workers
  • 12 Firecrawl npx launchers
  • 24 Firecrawl-related cmd.exe wrappers
  • 11 bundled mcp/server.mjs workers
  • approximately 2.6 GB combined working set across the Codex-related helper population

The duplicated helpers were descendants of the packaged ChatGPT/Codex app-server process. Firecrawl was configured as npx -y firecrawl-mcp; it appears to amplify the process count, but the broader defect is that complete helper/MCP suites were repeatedly initialized and retained instead of being reused or reaped.

Windows Event Viewer recorded WMI event 5612 at 02:11:31:

  • ThreadCount: 300
  • warning threshold: 256
  • provider: cimwin32.dll

Important diagnostic caveat: a subsequent read-only Get-CimInstance Win32_Process inventory likely amplified the WMI CPU spike visible in the screenshot. The 49.4% WMI number should therefore not be attributed entirely to the original Work-mode trigger. The core product symptom remains the approximately 630-process ChatGPT group and the repeated retained helper suites that existed before restart.

Recovery comparison

After fully quitting and reopening the desktop app:

  • node_repl.exe: 1
  • node.exe: 6
  • codex.exe: 1
  • WMI Provider Host CPU: 0%
  • total system process count: 321

This cleared the accumulated state but does not fix the lifecycle defect.

This reproduction adds two data points to the existing report:

  1. The issue persists in Store build 26.715.8383.0.
  2. Switching into local Work mode can be a direct trigger for rapid helper/process fan-out.

The screenshot and additional sanitized process data are available if maintainers need them. Usernames, private paths, repository names, prompts, email addresses, and configuration secrets are intentionally omitted.

shenxian096-eng avatar Jul 21 '26 19:07 shenxian096-eng

Follow-up: the trigger appears to be session-specific restoration

An additional user observation narrows the trigger further:

  • The process storm appears when reopening the same Work conversation that was originally created/used in Work mode.
  • Reopening that conversation appears to cause the problem to continue/recur.
  • When that conversation is not reopened, a 10-second non-WMI baseline remained completely stable:
    • total processes: 318 throughout
    • taskkill.exe: 0
    • conhost.exe: 7
    • node_repl.exe: 1
    • node.exe: 6
    • WMI provider processes showed no active storm

This suggests the trigger may be restoration of persisted per-conversation tool/helper state, rather than merely launching the desktop app or installing the update. A stale Work conversation may rehydrate multiple MCP/helper environments or replay cleanup state each time it is opened.

This is currently a strong user observation, not a deliberately repeated controlled reproduction: we did not ask the user to reopen it again because the previous occurrence saturated the machine. The calm baseline was collected using Get-Process only, specifically to avoid amplifying WMI load.

Practical implication for diagnosis: compare a newly created Work conversation against reopening the affected persisted conversation, and inspect whether restored task/tool ownership records cause helper fan-out before any new tool call is made.

shenxian096-eng avatar Jul 21 '26 19:07 shenxian096-eng

Independent reproduction with provider-level WMI trace and a restart control

I independently reproduced this failure and collected a short, sanitized provider-level trace.

Environment

  • Codex Desktop MSIX: OpenAI.Codex_26.715.7063.0_x64
  • Bundled ChatGPT.exe file version: 150.0.7871.124
  • Windows x64
  • 16 logical processors
  • Microsoft Store installation

User-visible impact

During the incident, Task Manager showed approximately:

  • Total system CPU: 80%
  • WMI Provider Host: 17.5%
  • Service Host: Windows Management Instrumentation: 7.8%

The machine was severely sluggish and ordinary commands launched through Codex were taking much longer than normal.

Provider and query evidence

A WMI provider health-counter sample identified CIMWin32 as the hot provider. Its raw processor counter ranged from approximately 241% to 393%, equivalent to about 15%–25% of the whole 16-logical-processor machine. Other active WMI providers were near zero.

A 12-second administrator WMI Trace capture recorded:

  • 118 repeated CIMWin32 queries of Win32_Process, selecting process ID, parent PID, session, thread count, working set, and kernel/user CPU time.
  • Provider events correlated those queries to cimwin32.dll inside the busy WmiPrvSE.exe host.
  • In the same 12-second interval, process-start tracing recorded 107 git.exe launches and 106 taskkill.exe launches directly parented by the packaged desktop application's main ChatGPT.exe process.

This matches the cleanup/process-enumeration amplification described in this issue: Codex creates short-lived helpers, the helpers repeatedly enumerate Win32_Process, and the resulting WMI workload is charged to WmiPrvSE.exe / Winmgmt rather than primarily to the Codex process itself.

Before/after control

After fully quitting and restarting Codex, I repeated the same provider-counter check:

  • Eight consecutive one-second samples showed 0.00% CPU for CIMWin32 and the other WMI providers.
  • System responsiveness returned to normal.
  • Some older Git helper processes remained, so restarting the app cleared the immediate WMI storm but should not be considered a permanent fix.

I did not establish a single repository-specific trigger in this reproduction. The captured evidence supports adding a bounded timeout, global concurrency limit, and backoff/circuit breaker around Windows process cleanup and process-snapshot helpers.

No raw trace is attached because it contains local identifiers. Sanitized aggregate results and selected redacted event records can be provided if useful.

Hime-Hina avatar Jul 22 '26 01:07 Hime-Hina

The unbounded taskkill.exe/conhost.exe cleanup storm and WMI exhaustion here closely match the downstream behavior I measured; repeated Git refreshes were upstream in my reproduction.

I published a single-file Windows launcher for the original Microsoft Store/MSIX Codex app:

  • Repository: https://github.com/suiyuebaobao/codex-git-refresh-workaround
  • Direct download: https://raw.githubusercontent.com/suiyuebaobao/codex-git-refresh-workaround/main/Codex-Git-Disabled.cmd

It starts Codex with a process-scoped GIT_DIR=NUL. On my machine, the stable trace changed from 247 new git.exe and 137 new taskkill.exe processes per 10 seconds to 0 and 0 over 15 seconds; WMI Provider Host fell from about 6.6% to 0.9%.

Usage: fully exit Codex from the Windows system tray, then run the script.

This is an unofficial workaround, not an upstream fix. It deliberately disables or limits Review, Changes, branch detection, commit, and other Git-backed Codex features. It does not patch Codex, modify repositories or Git configuration, write system environment variables, require elevation, terminate processes, or remove chat history. Launching Codex normally restores Git integration.

suiyuebaobao avatar Jul 22 '26 02:07 suiyuebaobao

Additional user observation after switching most local file/terminal work to FastCtx (an MCP tool runtime): for an initial period I did not see the previous taskkill.exe / conhost.exe accumulation or WMI-exhaustion behavior in ordinary Codex use.

Update: the storm has now recurred while writing this comment: 339 taskkill.exe and 351 conhost.exe processes, about 1,058 total processes, ~297,594 handles, and a WmiPrvSE instance at ~541 MB private memory. This is therefore not a fix and strongly supports the report's intermittent-trigger / unbounded-accumulation model.

FastCtx may have changed the workload and temporarily reduced the frequency of shell operations, cancellations, or timeouts that trigger cleanup, but it has not prevented the underlying Windows cleanup-path defect.

RocStone avatar Jul 22 '26 03:07 RocStone

Kimu-Nowchira avatar Jul 22 '26 06:07 Kimu-Nowchira

I can independently confirm this failure mode on the same Codex Desktop build, and I can add evidence for a likely trigger. This is not yet a deterministic minimal reproduction, so I am separating observed facts from the inferred mechanism.

Environment

  • Codex Desktop: OpenAI.Codex_26.715.4045.0_x64 (Microsoft Store/MSIX)
  • Windows: build 26200, x64
  • RAM: approximately 48 GB
  • Bundled Codex CLI observed in the session metadata: 0.144.5

User-visible impact

During the affected period, Windows Task Manager showed:

  • Total CPU: approximately 77%
  • WMI Provider Host: 14.2%
  • Windows Management Instrumentation service host: 5.4%
  • Microsoft Defender: 10.1%
  • Desktop Window Manager: 7.1%
  • ChatGPT/Codex process group: approximately 5%

The entire desktop visibly stuttered even though no heavy foreground application was running. CPU later returned to approximately 12% after the event subsided.

Likely high-probability trigger

A background Git review-summary operation was scanning a repository that contained 2,237 untracked and unignored files (approximately 26.5 MB) while another turn was actively generating and updating files.

The local Codex Desktop logs contained:

  • 119 explicit review-summary abort records
  • 63 aborts that directly referenced the untracked file tree
  • aborts beginning about one second after the visible turn started
  • residual abort activity continuing for approximately eight minutes after the visible work ended

A correlated ETW capture contained approximately 2,880 process-start records involving Git, conhost, and taskkill activity during the incident.

Inspection of the installed application bundle shows a stale Git snapshot path that advances the snapshot generation and calls AbortController.abort(). The Windows process-tree cleanup path then invokes approximately:

taskkill /pid <pid> /t /f

This makes stale review-summary cancellation a plausible trigger or amplifier for the unbounded cleanup/WMI storm. Source-level confirmation by a maintainer is still needed.

Suggested investigation areas

  • Coalesce or debounce repeated review-summary refreshes while the worktree is changing.
  • Enforce single-flight or bounded concurrency per worktree.
  • Add timeout, backoff and a global concurrency limit around Windows taskkill cleanup.
  • Avoid launching a new cleanup helper while an earlier cleanup for the same process tree is still pending.
  • Prefer Windows Job Objects or a direct Win32 termination path.
  • Log the Git operation, target PID, cancellation reason, cleanup duration and concurrent cleanup count.

Could a maintainer confirm whether stale review-summary cancellation reaches this Windows cleanup path and whether that path currently has a process-wide timeout or concurrency limit?

The project names, local paths, prompts and thread IDs have intentionally been omitted.

onovich avatar Jul 22 '26 08:07 onovich

I published an independent, Windows-first diagnostic and containment skill for this failure signature while an upstream fix is pending:

https://github.com/onovich/fix-codex-lag.skill

FixCodexLag takes one bounded process snapshot, detects taskkill/conhost/Git-helper churn and correlated WMI/Defender pressure, and reports a clear confirmed / not detected / inconclusive verdict.

It asks before taking any action. A runtime tree is cleanup-eligible only when strong ownership and lifecycle evidence proves that its Codex task has ended. Active or ambiguous process trees are preserved.

This is a temporary community mitigation, not an upstream fix. If the storm is rooted in the shared app-server and no safe leaf can be isolated, the skill reports that rather than guessing. It does not address the separate logs_2.sqlite/WAL write-storm issue.

onovich avatar Jul 22 '26 11:07 onovich

Confirmed on a newer Codex Desktop build with additional evidence connecting the cleanup storm, the Electron sampler, and review-summary cancellations.

Environment

  • Codex Desktop: 26.715.10079.0
  • Windows: 25H2 x64, build 26200.8875
  • Microsoft Store/MSIX package
  • Integrated terminal configured for PowerShell 7, but the internal sampler is unaffected because it explicitly invokes powershell.exe.

Live evidence

During the affected session, the process tree showed ChatGPT.exe -> taskkill.exe -> conhost.exe, with roughly 240 console-host processes present at the peak. WMI process enumeration then failed with resource/quota errors.

The packaged Desktop implementation contains two interacting paths:

  1. The Electron performance sampler explicitly runs Windows PowerShell:
powershell.exe -NoProfile -NonInteractive -Command
Get-CimInstance Win32_Process ...
Get-CimInstance Win32_PerfFormattedData_PerfProc_Process ...

The packaged constants show:

  • process snapshot timeout: 5 seconds
  • app-state heartbeat: 30 seconds while the primary window is focused
  • non-heartbeat trigger minimum interval: 5 seconds

The Desktop log recorded 14 [electron-sampler] Failed to collect child process snapshot events in this session, including repeated Win32_Process failures with HRESULT 0x80041006.

  1. The Git worker recorded 120 completed background Git requests:
  • 119 were requestKind=review-summary source=review_model
  • 99 ended as abortedBeforeStart
  • 20 ended as aborted after a process had started
  • 1 timed out

For started Git work, the packaged local execution host uses killProcessTree=true; on Windows that calls:

taskkill.exe /pid <pid> /t /f

There is per-execution deduplication, but no visible process-wide concurrency limit, timeout, backoff, or circuit breaker around the taskkill.exe calls.

Healthy-state comparison

After the storm ended, without changing the Codex version:

  • taskkill.exe: 0
  • conhost.exe: 7
  • WMI provider processes: 3, about 115 MiB total, 29 threads
  • Win32_Process query: 390 ms
  • Win32_PerfFormattedData_PerfProc_Process query: 651 ms

This supports a threshold/feedback-loop failure: on a healthy machine or healthy WMI state, the sampler finishes quickly and the helper exits; once cleanup processes accumulate and WMI exceeds the 5-second window or quota, sampler retries and additional cleanup work amplify the backlog. This also explains why another Windows PC with the same general workflow may not reproduce.

Requested fixes

  • Add bounded timeout and global concurrency limiting to Windows taskkill.exe cleanup.
  • Add exponential backoff/circuit breaking after sampler WMI failures.
  • Avoid spawning Windows PowerShell for frequent resource sampling; prefer native process APIs.
  • Coalesce or defer stale review-summary work so that a changing worktree does not repeatedly start and abort Git processes.
  • Expose a temporary user setting to disable Desktop process sampling/background review refresh.

No prompts, usernames, repository names, or raw logs are included. Sanitized excerpts can be provided if needed.

binawoh avatar Jul 22 '26 12:07 binawoh