Repository navigation
Description
Summary
In Codex Desktop, after the root agent spawns three direct subagents and their tasks appear to be completed, a later spawn_agent can fail with:
collab spawn failed: agent thread limit reached
The user-facing problem is that a subagent shown as completed can still be a non-evictable resident because of hidden pending mailbox state. The UI and the generic error do not identify the blocking agent or provide a recovery action.
Environment
- Product: Codex Desktop
- Platform: Windows
- Date reproduced: 2026-07-21
- App/CLI version: not exposed to the isolated test thread, so I cannot report it reliably
- Observed collaboration capacity: root plus three direct subagent resident slots
- No files or configuration were changed during the reproduction
Original user-facing symptom
- Ask the root agent to delegate work to three subagents.
- Let the delegated tasks finish.
- Continue the same Codex task and ask it to delegate another task.
- The later spawn fails or delegation is unavailable even though the earlier subagents appear completed.
From the UI, this looks like completed subagents failed to release their capacity.
Controlled reproduction
I ran two isolated Codex tasks to separate ordinary completion from hidden mailbox state.
Baseline: ordinary completed agents
- Spawn direct subagents A, B, and C with clean history.
- Let all three return
A_OK,B_OK, andC_OKand reachcompleted. - Spawn a new direct subagent D.
Result: D's spawn_agent returned successfully without a noticeable wait, and D completed with D_OK.
This shows that ordinary completed agents alone were reclaimable in this runtime.
Pending-mailbox variant
- In a fresh isolated task, spawn A and let it complete with
A_OK. - Send
STATUS_PROBEto completed A using queue-onlysend_message. It does not trigger a new turn. - Spawn E and F with tasks that remain active for about 45 seconds.
- While E and F are active, attempt to spawn G.
The G spawn fails immediately with the exact output:
collab spawn failed: agent thread limit reached
At that point only E and F are actively running. A is completed, but it has the pending queue-only mailbox item. The controlled difference from the successful baseline is the hidden pending mailbox on A.
I then used followup_task on A; A consumed the queued work and returned A_DRAINED. E and F also completed. A subsequent retry could not be emitted because the isolated test task encountered a separate tool-routing failure, so this report does not claim that the recovery path was independently verified.
Actual behavior
- A completed subagent can remain resident and block admission.
- The completed status does not expose pending mailbox state.
AgentLimitReacheddoes not distinguish active concurrency exhaustion from residency pressure.- The user cannot see which completed agent is blocking eviction or how to recover.
- Raising the thread limit would only make the problem less frequent.
Expected behavior
At least one of the following should occur:
- Reject queue-only
send_messageto an already completed agent and direct the caller tofollowup_task. - Automatically trigger a follow-up turn when queue-only mail crosses the completion boundary.
- Persist the mailbox independently so the completed resident can be evicted.
- Expose a close/drain action for completed agents.
- Make
AgentLimitReachedreportmax,active,residents, and anypending_mailbox_blockers. - Show in the Desktop UI when a completed subagent still counts toward capacity.
Related issues
- MultiAgentV2: queue-only message to a completed agent pins a residency slot #32353 documents the pending-mailbox residency mechanism at the app-server level.
- Completed subagents continue to count against thread limit #22779 covers older completed/open-thread quota accounting.
- MultiAgentV2 spawn_agent can hang indefinitely while evicting a terminal resident thread #33777 covers a separate MultiAgentV2 hang while evicting a terminal resident.
This report is filed separately to track the Codex Desktop user-facing symptom: agents appear completed, but hidden residency state prevents later delegation with no diagnostic or recovery hint.
Additional evidence
Independent reproduction comment on #32353:
No local paths, task/thread IDs, account information, or private logs are included.
Activity
slobodaapl commentedon Jul 26, 2026
Can confirm it also happens in CLI; root agent tries to spawn agents; after they're done, they're no longer visible to the root agent, and thus if it tries to spawn another past the limit, it errors out on agent cap being reached, but it cannot close old ones as it cannot see them.
pomazanbohdan commentedon Aug 18, 2026
Additional Windows Desktop reproduction (26.814.5167.0; CLI/runtime 0.148.0-alpha.15):
task_complete/final_answer, but the parent persisted all 7 spawn edges as open; the parent recorded started/interacted activity without a terminal/completed edge transition.context_compactedevents, one already-completed child reappeared aspending_init. With that hidden resident plus two genuinely running reviewers, a third reviewer failed withcollab spawn failed: agent thread limit reached.codex_core::tools::router,core/src/tools/router.rs:231. All 7 child rollouts later completed while all 7 parent edges remained open.This indicates a completion-to-residency/edge-release gap, with compaction/rehydration reviving a stale resident handle. A regression test should compare child terminal state with parent edge closure and ensure completed/
pending_initresidents do not consume spawn capacity.pomazanbohdan commentedon Aug 23, 2026
Follow-up cluster note: the same boundary affects both capacity and presentation—terminal children can retain open parent edges/residency, then rehydrate as Active after reload. The safe invariant is rollout terminal state plus live-process absence, not UI Active or thread_spawn_edges.status=open; see #39694 and #37042.
iendeavor123 commentedon Sep 30, 2026
Additional Codex Desktop observation (2026-09-30, macOS)
Codex Desktop
26.928.20755, build12246. In a long-running task, the runtime advertised 11 concurrency slots including the root, matching the session's initial[agents] max_concurrent_threads_per_session = 10setting.Observed sequence:
agent thread limit reached.list_agentssnapshot shows the root and one worker running, eight workerscompleted, and onepending_init. Active work is well below the expected ten-worker concurrency limit.The on-disk agent cap was subsequently changed from 10 to 20. The active runtime still advertises 11 slots; this report does not claim the change was live-reloaded or tested in a new session.
Expected: replacement admission while fewer than ten workers are active, or an actionable error explaining which non-active thread/state prevents admission. Actual: a generic limit error despite only one running worker.
This corroborates the Desktop symptom. It is an observed production sequence, not a controlled deterministic reproducer: we have not inspected internal mailbox/residency state and cannot establish whether pending mail, the
pending_initentry, or another lifecycle condition caused this occurrence. No forced cleanup/restart was performed to diagnose it.iendeavor123 commentedon Oct 1, 2026
Update (Sep 30, 2026): I tested a fresh Codex task with the current config ([agents].max_concurrent_threads_per_session = 20). It advertised a 20-thread per-session limit and ran 10 workers simultaneously alongside the root; all completed a 60-second hold. This confirms fresh-session capacity with this config. It does not establish why replacement spawns failed in the original long-lived session or prove completed-thread retention was the cause; see the original observation at #34518 (comment).
con1857 commentedon Nov 13, 2026
Windows Desktop follow-up: a new spawn failed while a completed child was loaded for viewing
I saw the same combination reported in the August 18 comment: two running children, a previously completed child listed as
pending_init, and a new spawn rejected. I also captured how the completed child came back into the list and what happened to the next spawn after it disappeared.Setup. Windows, Codex Desktop
26.1106.51428, localstdioapp-server0.167.0-alpha.4.1, multi-agent V2. The session advertised four slots including the root. A worker had spawned a locally configuredadvisor. That advisor had returned its final response and unloaded. The root kept two other children in long-running turns for both attempts.navigate_to_codex_page. I sent the advisor no new message. Itsthread/resumesucceeded withactive_turn_present=false. The root listed tworunningchildren and the viewed advisor aspending_init. The worker was already absent.spawn_agentfrom the root returnedcollab spawn failed: agent thread limit reached. The same three children and statuses appeared immediately afterward.navigate_to_codex_page, Desktop recorded the advisor’s view as inactive while it still owned the stream. Three hours after that log entry, automaticthread/unsubscribefor the same child returnedunsubscribed. The advisor was still listed ten seconds later.Op::Shutdown, its session loop exited, and it disappeared from the root’s list. Only the two running children remained. Thethread/closedlog line immediately after loop exit had no child ID.running, and the new advisor returned its final response. The other two children finished at 15:52:08 and 15:52:12.Each of the two other children kept its original turn ID across both attempts. Both calls used
agent_type=advisorandfork_turns=none, with distinct task names. This was one attempt per condition. In a separate morning observation, a spawn succeeded while the same viewed advisor was still listed aspending_init. The other two listed children were thencompleted, and one began shutting down during that spawn.Which limit did the 12:35:26 spawn hit:
ResidencyCapacityorExecutionCapacity? I expected to be able to view completed work and still start a third working child. The matching Rust version checks execution capacity first, then reserves residency. Under residency pressure it skipsPendingInitchildren. That makes residency pressure a plausible explanation. Both branches produce the same error text. I could not recover the per-calldetailfromcodex.multi_agent.spawn.failureor the execution, resident, and pending-reservation counts at rejection. If the trace for this call is available, itsdetailwould identify the branch. Spawn checks · Eviction rules · Shared error text · Failure trace fieldsdaemons2000 commentedon Nov 16, 2026
Additional same-version Windows/WSL observation and recovery
I observed a closely matching failure on Codex Desktop
26.1106.51428with app-server0.167.0-alpha.4.1and Multi-Agent V2. The local backend runs in WSL through a launcher wrapper, so this is not a clean-stock-launch reproduction.History inspection and capacity failure
thread/readandthread/turns/listsucceeded. Desktop then attemptedthread/resume, which failed with JSON-RPC-32600. The backend recordedagent thread limit reached; the client-facing error response used the broader messagecannot resume an unloaded multi-agent v2 sub-agent through its parent; resume the parent first, or use thread/read to inspect it.collab spawn failed: agent thread limit reached. The native roster included several historical agents whose saved turns were completed but whose current status waspending_init, filling the configured child capacity alongside current work.interrupt_agentattempt returnedprevious_status: pending_init. The subsequent roster was unchanged and no slot was released. The exposed collaboration tools had no close/unload operation.This is an observed sequence, not a minimal controlled reproducer. It does not establish which event restored every historical agent, whether pending mailbox state contributed, or whether the capacity rejection was specifically the execution or residency gate.
Recovery observed
After increasing the configured child limit and fully restarting Desktop, the coordinator's initial native roster contained only the coordinator. Continuing the existing implementer succeeded, subsequent reviewer pairs completed, and the workflow advanced. Existing work and review history were preserved.
Because the limit increase and restart were performed together, this does not isolate which action restored admission or establish a permanent fix.
This corroborates the history-viewing trigger in the November 13 comment above. It also overlaps with #39694 and #49986's completed/
pending_initcapacity symptoms. The blank-view symptom resembles #38250, but that report says its backend resume succeeded; here the affected resume failed, so I am not claiming an identical root cause.A useful recovery path would let the user inspect saved history when resume cannot obtain a slot, show an actionable failure instead of an indefinite spinner, and identify which resident agents prevent new work.