Stop/cancel becomes unresponsive when subagent MCP processes exhaust memory — Codex unrecoverable without killing processes externally

Open 💬 1 comment Opened Jun 19, 2026 by alanxchen85

Primary bug: When a fleet of subagents accumulates enough MCP server processes to exhaust memory, the Stop control no longer interrupts the run. The app becomes unresponsive and the only recovery is killing processes from a terminal (kill -9 on the MCP children / the app-server). There is no in-app escape once the machine is under that memory/CPU pressure — which makes Codex effectively unusable for high-fan-out subagent work.

Root cause (what builds the pressure)

  • The built-in default subagent inherits the parent's full mcp_servers roster with no way to restrict it. The [agents] section only exposes max_threads, max_depth, job_max_runtime_seconds — no MCP scoping. Only user-defined custom agent files support an mcp_servers override.
  • Per-spawn MCP processes are neither pooled (#12333, closed not-planned) nor reaped on subagent exit.

Observed

One long-running session, on a single app-server process, accumulated:

  • 212 × SkyComputerUseClient (built-in Computer Use — not an [mcp_servers] entry, so config can't disable it)
  • 113 × npm exec @playwright/mcp@latest
  • 93 × previewsmcp serve
  • 78 × railway mcp
  • ~13 each of ios-simulator-mcp, xcodebuildmcp, node_repl, bundled .server.{mjs,cjs,bundle}

Total: ~800+ node processes, ~16–27 GB RSS, with syspolicyd/trustd pegged from the trust-check churn of constant process spawns. Killing the children frees the RAM, but they rebuild to ~500 procs / ~16 GB in ~15 minutes as long as the app-server stays alive. The only reliable recovery was quitting Codex entirely.

Requests (priority order)

  1. Stop/cancel must stay responsive under memory pressure. Interrupting a run should forcibly tear down spawned subagents and their MCP processes even when the system is starved — give the user an in-app recovery path. (Critical — this is what makes it unusable rather than merely wasteful.)
  2. Reap dead MCP server processes when a subagent exits; cap or pool per-server instances.
  3. Allow mcp_servers scoping on the built-in default agent (e.g. honor agents.default.config_file, or an [agents.default] mcp_servers key) so high-fan-out fleets don't each inherit the full roster.
  4. Document whether spawned subagents inherit the cwd/global AGENTS.md instruction chain, and consider allowing a per-agent external instructions file.

Environment

  • Codex.app, macOS (Apple Silicon), 64 GB RAM.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗