[Windows] Subagents leave unused stdio MCP process trees after task completion
Summary
On Windows, Codex Desktop appears to create a fresh stdio MCP process tree for each subagent/task context, even when the subagent never invokes those MCP tools. After the subagent or task finishes, the MCP child processes are not reliably reaped, so the process count grows with repeated multi-agent use.
This report focuses on the Windows behavior and complements related reports such as #17574, #20867, #21984, #25015, and #30408.
Environment
- Surface: Codex Desktop on Windows
- Codex build: current desktop release at the time of capture (exact build intentionally omitted)
- Workflow: multiple tasks and subagents
- MCPs involved: Chrome DevTools stdio MCP and Node REPL stdio MCP
No user name, machine name, absolute path, PID, thread ID, token, or other host-specific identifier is included.
Observed behavior
In one live Windows process snapshot:
- approximately 12 Chrome DevTools MCP launcher roots were present under one Codex host
- approximately 13 Node REPL processes were present
- each Chrome root expanded into a
cmd -> npx -> node -> chrome-devtools-mcptree, including a watchdog/telemetry child - the affected conversation did not invoke Chrome DevTools or Node REPL tools
- the process groups remained after tasks/subagents completed or were cancelled
- the number of groups increased as more task/subagent contexts were created
The SketchUp MCP in the same setup was moved to a shared Streamable HTTP bridge and did not show legacy stdio processes, which helps isolate this as a Codex MCP lifecycle issue rather than an MCP server-specific failure.
Reproduction pattern
- Configure Chrome DevTools and/or Node REPL as global stdio MCP servers.
- Start Codex Desktop on Windows with multi-agent/subagent use enabled.
- Spawn several subagents that perform tasks without calling those MCP tools.
- Complete or cancel the subagents.
- Repeat the cycle and inspect the Codex process tree in Task Manager or PowerShell.
- Observe that new MCP trees appear while previous trees remain.
Expected behavior
- Start MCP servers lazily when a tool from that server is first requested, or clearly document eager startup.
- Associate every MCP process tree with its owning task/session.
- On task completion, cancellation, archive, restart, or app shutdown:
- close the stdio stream,
- wait for graceful exit,
- terminate the remaining Windows process tree/job after a bounded timeout.
- Reuse one safe MCP instance across sessions where protocol semantics allow it, or enforce a bounded idle timeout.
- Do not initialize unrelated MCP servers for subagents that cannot use them.
Actual impact
Repeated subagent use leaves unused node.exe, cmd.exe, npx, Chrome DevTools MCP, watchdog, and Node REPL processes alive. Over time this consumes memory and makes it difficult to tell which process belongs to an active task.
Temporary workaround
Disabling the affected MCP entries prevents new automatic launches, but requires a full Codex Desktop restart and removes those tools until re-enabled. This is only a workaround; it does not clean up already orphaned trees.
Requested diagnostics
Please add lifecycle diagnostics that expose:
- MCP server identity and configuration layer
- owning task/subagent ID
- process tree/job ID
- start time and last activity
- cleanup result on task close/cancel
A Windows-specific regression test covering repeated subagent creation and cleanup would help prevent recurrence.
1 Comment
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action