Repository navigation
Release a finished Codex thread's MCP servers once nothing on it is pending #26795
Replies: 1 comment
|
Note 🤖 Claude Opus 5.5 responding on behalf of Christian A second case for this, on Linux, where the T3 side is now the whole wait. Setup: T3 Code 0.1.5, codex-cli 0.166.0, Arch Linux, 16 GB RAM and 16 GB swap. Each Codex thread starts two stdio MCP servers: one configured in What happened:
The Codex side is now short. With a private On a 16 GB machine, a fan-out of about 50 delegated tasks therefore fills RAM and swap for half an hour. We worked around it by turning off the MCP server and the plugin we don't use in Codex. Releasing a thread at the end of provider-event ingestion when nothing is pending, as proposed above, would fix this case. |
Uh oh!
There was an error while loading. Please reload this page.
Problem
Every loaded Codex thread runs its own copy of each configured stdio MCP server on the shared
codex app-server(for example
node_repl, the computer-use REPL and an agent-tools server, plus their console hosts). Codex stops athread's servers only after the client sends
thread/unsubscribeand its ownthread_unload_delay_secshas passed.Since #16917, T3 unsubscribes a finished thread after the 30-minute idle timeout. A finished delegated task therefore
keeps its whole set loaded for 30 minutes plus Codex's delay, up to an hour with the defaults.
With many short delegated tasks this adds up. On one Windows PC (T3 Code 0.1.3, codex-cli 0.165.0), 54 per-thread
sets accumulated in about two hours under the shared app-server, many of them belonging to tasks that had already
finished. #21354 reports the same pattern at a larger scale on macOS (774 helper processes, about 4.4 GiB summed RSS).
Measured with a stub stdio MCP server (one child process) plus
node_repl,thread_unload_delay_secs = 5, and oneCodex task delegating one Codex child:
Why we'd like to revisit "working as designed"
#21905 was closed as working as designed: 30 minutes on the T3 side plus Codex's 30 minutes. That holds for a
handful of threads. With delegated tasks, every task is a new thread that runs one turn and is rarely settled, so
the timer turns into a standing cost proportional to the task rate. Lowering
thread_unload_delay_secsonly shortensthe Codex half.
Proposed direction
Release a thread once nothing on it is pending, and never cut running work:
persistent dynamic tools, MCP-app captures and running native subagent turns, which is what
hasPendingBackgroundWorkForThreadalready reports.RunExecutionServicealready stops ingestionexactly when the root turn, its children and its background items have settled
(
shouldStopProviderEventIngestion). That event schedules the thread's unload after a short delay (we used 10 s),so a follow-up queued at turn end keeps the thread loaded. Codex's
thread_unload_delay_secsstays the graceafter the unsubscribe.
(a failed or interrupted root turn).
awaitActiveTurngives up) is tracked againstits thread instead of dropped;
Relation to existing work:
unloadThread.provider-session.detach. That path doesnot consult
hasPendingBackgroundWorkForThread, so a child that leaves a background command running would have itended. It also covers only completed or failed delegated tasks.
What we ask
Approval of this direction, or the direction you'd prefer. Once approved, we'll open a PR with the implementation
(about 10 files in
apps/server, each change with a test that fails without it) and link it here.All reactions