[Windows] Completed subagents leave STDIO MCP Node.js processes running (245 processes / 18 GB)

Open 💬 4 comments Opened Jul 22, 2026 by zhang8630
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

What version of the Codex App are you using (From “About Codex” dialog)?

Codex Desktop 26.715.8383.0 (x64)

What subscription do you have?

Chatgpt pro

What platform is your computer?

Windows 11 Home, 64-bit, version 10.0.26200 (build 26200)

What issue are you seeing?

Node.js version

Node.js v24.15.0, installed at %ProgramFiles%\nodejs\node.exe
When a Codex task spawns subagents while multiple local STDIO MCP servers are enabled, each subagent starts its own copy of every enabled Node-based MCP server. After a subagent records task_complete, those MCP processes remain alive instead of being stopped.

The process count therefore grows approximately linearly with the number of subagents created during the lifetime of the Codex Desktop process. In the observed session, this reached 245 Node.js processes and approximately 18.3 GB of working-set memory.

What steps can reproduce the bug?

  1. On Windows, enable several local Node-based STDIO MCP servers. My configuration included:
  • npx -y @cyanheads/pubmed-mcp-server@latest
  • npx -y clinicaltrialsgov-mcp-server@latest
  • a local cas_journal Node MCP server
  • Node-based MCP servers bundled with the Data Analytics, Sites, and OpenAI Developers plugins
  1. Start Codex Desktop.
  2. Run a task that creates multiple subagents.
  3. Wait for the subagents to finish and record task_complete in their session transcripts.
  4. Inspect the remaining Node processes and their command lines:
$nodes = Get-CimInstance Win32_Process |
    Where-Object Name -EQ 'node.exe'

$nodes |
    Group-Object CommandLine |
    Sort-Object Count -Descending |
    Select-Object Count, Name

$workingSet = Get-Process -Name node -ErrorAction SilentlyContinue |
    Measure-Object WorkingSet64 -Sum

[math]::Round($workingSet.Sum / 1GB, 2)
  1. Observe that each new subagent adds another repeated set of MCP processes, but completing the subagent does not reduce the process count.

Expected behavior

When a subagent finishes, Codex should close or dispose of that subagent's STDIO MCP clients and terminate their child processes. Alternatively, MCP clients could be shared or pooled with a bounded lifetime across subagents.

The number of local MCP processes should not continue increasing after subagents complete.

Actual behavior

Each subagent created approximately eight Node processes:

| MCP source | Node processes per subagent | Why |
|---|---:|---|
| PubMed MCP | 2 | One npx-cli.js process and one server process |
| ClinicalTrials MCP | 2 | One npx-cli.js process and one server process |
| CAS Journal MCP | 1 | Direct Node server |
| Data Analytics plugin | 1 | Plugin-provided server.cjs |
| Sites plugin | 1 | Plugin-provided server.mjs |
| OpenAI Developers plugin | 1 | Plugin-provided server.mjs |
| Total | 8 | Per subagent/session |

Observed totals:

  • 30 repeated MCP process sets × 8 Node processes = 240 Node processes attributable to Codex MCP initialization.
  • 5 additional unrelated/orphaned tests/run_fixture_validators.js processes were present, resulting in 245 Node processes overall.
  • Total Node working-set memory was approximately 18.3 GB.
  • The count remained at 245 across repeated samples several minutes apart.

Evidence that completed subagents retain their MCP processes

  • Codex Desktop's codex.exe process started at 09:23:19.
  • MCP process sets were then created repeatedly from 09:23:57 through 10:19:05.
  • Their creation timestamps closely matched the creation timestamps of subagent session files.
  • 25 inspected subagent transcripts ended with an event_msg whose payload type was task_complete.
  • The corresponding MCP process sets were still alive after those completion records.
  • For one concrete example:
  • Subagent and its MCP processes started at 09:26:18.
  • The subagent recorded task_complete at 09:30:24.
  • Its CAS Journal MCP process was still alive when checked at 10:24:23.
  • Process ancestry showed the MCP processes were direct or indirect descendants of Codex Desktop's codex.exe (some npx servers had intermediate cmd.exe and node.exe processes).

Process distribution at the time of capture

| Command | Count | Approx. working set |
|---|---:|---:|
| PubMed server | 30 | 3,349 MB |
| PubMed npx-cli.js | 30 | 2,488 MB |
| ClinicalTrials server | 30 | 3,222 MB |
| ClinicalTrials npx-cli.js | 30 | 2,484 MB |
| Plugin server.mjs processes | 60 | 3,007 MB |
| CAS Journal server | 30 | 1,912 MB |
| Data Analytics server.cjs | 30 | 1,593 MB |

Why this does not appear to be a Node.js process-spawning issue

All 240 MCP-related Node processes followed the same Codex/subagent creation pattern and were launched as descendants of the active Codex Desktop process. Multiple independent MCP implementations remained alive in identical per-subagent groups. This points to the Codex session/MCP manager lifecycle rather than one MCP package spawning copies of itself.

I have not changed Node versions yet, because the multiplication is initiated by Codex when sessions/subagents are created. Testing with another supported Node version may still be useful as a secondary compatibility check.

Impact

  • Hundreds of Node processes remain after the related subagent work is complete.
  • Memory usage can grow into tens of gigabytes during multi-agent workflows.
  • The machine becomes slow and may experience memory pressure or paging.
  • Fully restarting Codex is currently the practical way to reset the accumulated MCP processes.

Additional context

The strongest current hypothesis is that each subagent initializes its own MCP manager, but the manager or its STDIO child processes are not disposed when the subagent reaches task_complete.

Additional information

_No response_

View original on GitHub ↗

4 Comments

github-actions[bot] contributor · 1 month ago

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

  • #33531
  • #34410
  • #34614

Powered by Codex Action

zhang8630 · 1 month ago
Independent adjacent reproduction on Windows 11 using a separate projectless Codex task (rather than a subagent) shows the same lifecycle shape. Privacy-safe A/B method: Process acquisition requested only Name, ProcessId, ParentProcessId, and CreationDate from Win32_Process. Process instances were matched by PID plus creation time to avoid PID-reuse errors. Output retained aggregate counts only. No PIDs, command lines, paths, usernames, environment data, or prompt content were recorded or shared. Treatment task had no file, shell, tool, connector, or web access; it returned one fixed line and was then archived. Treatment result: Phase Node total Nearest observed codex.exe ancestor Delta vs baseline Baseline 305 273 0 Active 353 321 +48 Completed, before archive 351 319 +46 Immediate after archive 341 309 +36 2/4/6/8 minutes after archive 344 312 +39 A measurement-only control used the same primary task and corresponding snapshot timings, but created no secondary task and performed no archive action. Its delta was +1 at the corresponding active point, then -5 to -6 through the eight-minute endpoint. Claude-attributed and unattributed Node branches remained unchanged in both series. Every immediate parent was live and its process instance validated by creation time; no invalid-instance, unknown-timestamp, or cycle case was observed. This supports Codex task-related Node/MCP fan-out that persists for at least eight minutes and is not reproduced by the measurement calls alone. It does not by itself prove orphan processes or a resource leak because the parent subtrees remain live and the intended pool lifetime is unknown. No processes were stopped during the experiment. The result suggests the retention may apply to general task/session lifecycle, not only subagents. Please let me know if a maintainer needs a specific additional lifecycle interval or version field collected in a similarly sanitized follow-up.

Thanks for the additional reproduction. I see the same behavior: simply creating a new task, before it does any actual work, causes many new Node.js processes to appear. They are repeated instances of the configured MCP servers, so this seems related to MCP servers being started again for each task and not being cleaned up properly afterward.

grtninja · 1 month ago

Independent corroboration from a separate Windows 11 Pro / ChatGPT Pro long-running Codex Desktop session on July 23, 2026:

  • the Codex-associated process tree grew to roughly 23.8 GB RAM during a multi-task, MCP-heavy workload;
  • completed/abandoned work did not return the process tree to a normal baseline;
  • the app became unstable enough to require a hard restart;
  • the operator separately observed task/session disruption and large usage waste while the process fanout remained active.

I did not capture a clean per-command process inventory before restarting, so this is corroborating impact evidence rather than a second exact reproduction of the 245-Node-process count. The visible symptom and recovery pattern match this issue closely: multi-agent/MCP activity accumulates unreaped descendants, memory rises into tens of gigabytes, and restarting Codex is the practical cleanup.

A useful built-in diagnostic would expose, per root thread/subagent: MCP client PID tree, ownership, creation time, task completion time, disposal status, and aggregate working set. Codex should also enforce a bounded process/memory ceiling and terminate orphaned MCP clients after the owning subagent reaches a terminal state.

SergeyPomelov · 12 days ago

Reproduced on Windows with ChatGPT/Codex Desktop 26.810.7004.0 the best flagship vibecoded application.
Task Manager showed 253 ChatGPT processes using 8.1 GB RAM. Shortly afterward, there were 139 node.exe processes using 12.5 GB, mostly repeated MCP servers such as GitLab, Jira, Confluence, and Chrome DevTools.