You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Codex startup sub-agent will restart a bunch of mcp, but it will not be automatically cleared after closing the sub-agent. #12976
Repro confirmation on codex-cli 0.107.0 (WSL/Linux), same core symptom: after sub-agents are closed, many MCP subprocesses can remain alive under the root Codex process.
Run an 8-lane sub-agent wave (spawn 8 agents, wait for completion).
Call close_agent for all agent IDs.
Immediately inspect children under the root Codex PID.
Observed
Immediately after close_agent calls completed, the root Codex PID still had many direct MCP launcher children (example snapshot had 49
direct children):
8x context7-mcp
8x gcloud-mcp
8x observability-mcp
8x analytics-mcp
8x workspace-mcp
8x mcp-metricool
plus systemd-inhibit
These were still attached to the same active Codex parent process, not reparented zombies from a dead parent.
Important distinction
I understand duplicate MCP instances while agents are active may be by design (#12333, per-agent MCP config isolation).
The issue here is lifecycle after close: close_agent did not promptly tear down associated MCP subprocesses.
Expected
After close_agent (or shortly after with a deterministic timeout), MCP subprocesses associated with those closed sub-agents should be released automatically.
Request
Can you confirm intended teardown semantics for close_agent in current builds, and whether this is expected to be fixed in a release after 0.107.0?
That report keeps the scope narrow to Windows stdio MCP teardown / lifecycle cleanup, includes a ready compare branch, and documents the regression coverage I validated locally.
Activity
github-actions commentedon Feb 27, 2026
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
etraut-openai commentedon Feb 27, 2026
When you say "not be automatically cleared", do you mean that the MCP servers are not shut down?
And what do you mean by "startup sub-agent"?
CE0Alex commentedon Mar 4, 2026
Repro confirmation on
codex-cli 0.107.0(WSL/Linux), same core symptom: after sub-agents are closed, many MCP subprocesses can remain alive under the root Codex process.Environment
0.107.0agents.max_threads = 8features.multi_agent = truecontext7,gcloud,gcp-observability,google-analytics,google-workspace,metricoolRepro
close_agentfor all agent IDs.Observed
Immediately after
close_agentcalls completed, the root Codex PID still had many direct MCP launcher children (example snapshot had 49direct children):
context7-mcpgcloud-mcpobservability-mcpanalytics-mcpworkspace-mcpmcp-metricoolsystemd-inhibitThese were still attached to the same active Codex parent process, not reparented zombies from a dead parent.
Important distinction
I understand duplicate MCP instances while agents are active may be by design (#12333, per-agent MCP config isolation).
The issue here is lifecycle after close:
close_agentdid not promptly tear down associated MCP subprocesses.Expected
After
close_agent(or shortly after with a deterministic timeout), MCP subprocesses associated with those closed sub-agents should be released automatically.Request
Can you confirm intended teardown semantics for
close_agentin current builds, and whether this is expected to be fixed in a release after0.107.0?leonsong09 commentedon Mar 28, 2026
I pushed a narrow Windows teardown fix branch here:
https://github.com/openai/codex/compare/main...leonsong09:fix/windows-stdio-mcp-teardown?expand=1
Scope:
This does not try to change MCP instance sharing/pooling across active subagents; it only addresses lifecycle cleanup for stale Windows stdio stacks.
leonsong09 commentedon Mar 29, 2026
I filed a more detailed follow-up report here:
That report keeps the scope narrow to Windows stdio MCP teardown / lifecycle cleanup, includes a ready compare branch, and documents the regression coverage I validated locally.
Ready compare branch:
Terminate stdio MCP servers on shutdown to avoid process leaks (opena…
Terminate stdio MCP servers on shutdown to avoid process leaks (opena…
Terminate stdio MCP servers on shutdown to avoid process leaks (opena…