Summary
Codex Desktop appears to hit the spawn_agent thread limit even when the visible subagent list only contains the main thread plus historical subagents marked as shutdown. Attempts to close those historical subagents fail with thread ... not found, but subsequent spawn_agent calls still report the session/thread limit as reached.
This makes multi-agent review workflows unreliable: the user sees old subagent entries that are no longer live or closable, while the model cannot spawn the intended new reviewers.
Environment
- Product: Codex Desktop app
- Platform: Windows / PowerShell session
- Workspace path shape:
H:\...
- App version: not available from this session; I can provide it later from the About dialog if needed.
- Mode: local desktop session using the multi-agent/collab
spawn_agent, list_agents, and close_agent tools.
What happened
During a multi-AI review workflow, the model attempted to spawn several read-only reviewer agents. Only one new reviewer could be spawned. The other spawn_agent calls failed with:
collab spawn failed: agent thread limit reached
The model then inspected live agents with list_agents. The returned list showed:
/root as running
- several older subagents as
shutdown
- the new reviewer as
running initially
The historical shutdown entries included older unrelated review tasks from previous work in the same root session. They were not part of the current task.
The model attempted to explicitly close those old shutdown entries with close_agent, but each close attempt failed with errors like:
collab tool failed: thread <id> not found
After this, the system still behaved as if the thread/session limit had been reached, even though those old agents were already shutdown and not closable.
Expected behavior
One of these should happen:
shutdown or nonexistent subagents should not count against the active max_concurrent_threads_per_session / spawn limit.
- If they do count,
close_agent should be able to remove/release them.
- If the limit is not about active agents but about total historical agents in a root tree, the error message should say so explicitly and provide a recovery path.
list_agents should clearly distinguish active, closed-but-retained, and non-counting historical entries.
Actual behavior
spawn_agent reports the thread limit is reached.
list_agents shows old unrelated agents as shutdown.
close_agent cannot close them because the thread is already not found.
- The user and model cannot tell which entries are still consuming capacity or how to release capacity.
Why this matters
This blocks legitimate multi-agent workflows. In this case, the user explicitly asked for multiple AI reviewers to concurrently critique planning artifacts. The model could only spawn one reviewer and had to fall back to a less reliable main-thread-only review.
It also creates a confusing UX: the model reports old shutdown threads, cannot close them, and cannot spawn new agents, which looks like stale session state or leaked accounting.
Reproduction outline
- In Codex Desktop, create a root session.
- Spawn several subagents for review tasks.
- Let them complete/shutdown, or have them become historical
shutdown entries in list_agents.
- Later in the same root session, try to spawn several new subagents.
- Observe
spawn_agent failing with agent thread limit reached.
- Call
list_agents; observe old entries marked shutdown.
- Try
close_agent on those old entries; observe thread ... not found.
- Try spawning again; observe the effective capacity is still unavailable.
Related-looking issues found before filing
I found some similar-but-not-identical issues around subagent/session state:
This report is specifically about shutdown / nonexistent agents being visible but not closable, while spawn_agent still reports a thread-limit condition.
Suggested fix direction
- Make the spawn limit count only currently running or pending agents.
- Ensure completed/shutdown child agents release capacity deterministically.
- Make
close_agent idempotent: closing an already-shutdown/nonexistent child should return success or a clear already closed; not counted result.
- Add a diagnostic field to
list_agents, such as counts_toward_spawn_limit: true/false.
- Improve the
agent thread limit reached error to include active-count / max-count and a list of counted agents.
Summary
Codex Desktop appears to hit the
spawn_agentthread limit even when the visible subagent list only contains the main thread plus historical subagents marked asshutdown. Attempts to close those historical subagents fail withthread ... not found, but subsequentspawn_agentcalls still report the session/thread limit as reached.This makes multi-agent review workflows unreliable: the user sees old subagent entries that are no longer live or closable, while the model cannot spawn the intended new reviewers.
Environment
H:\...spawn_agent,list_agents, andclose_agenttools.What happened
During a multi-AI review workflow, the model attempted to spawn several read-only reviewer agents. Only one new reviewer could be spawned. The other
spawn_agentcalls failed with:The model then inspected live agents with
list_agents. The returned list showed:/rootasrunningshutdownrunninginitiallyThe historical
shutdownentries included older unrelated review tasks from previous work in the same root session. They were not part of the current task.The model attempted to explicitly close those old
shutdownentries withclose_agent, but each close attempt failed with errors like:After this, the system still behaved as if the thread/session limit had been reached, even though those old agents were already
shutdownand not closable.Expected behavior
One of these should happen:
shutdownor nonexistent subagents should not count against the activemax_concurrent_threads_per_session/ spawn limit.close_agentshould be able to remove/release them.list_agentsshould clearly distinguish active, closed-but-retained, and non-counting historical entries.Actual behavior
spawn_agentreports the thread limit is reached.list_agentsshows old unrelated agents asshutdown.close_agentcannot close them because the thread is already not found.Why this matters
This blocks legitimate multi-agent workflows. In this case, the user explicitly asked for multiple AI reviewers to concurrently critique planning artifacts. The model could only spawn one reviewer and had to fall back to a less reliable main-thread-only review.
It also creates a confusing UX: the model reports old
shutdownthreads, cannot close them, and cannot spawn new agents, which looks like stale session state or leaked accounting.Reproduction outline
shutdownentries inlist_agents.spawn_agentfailing withagent thread limit reached.list_agents; observe old entries markedshutdown.close_agenton those old entries; observethread ... not found.Related-looking issues found before filing
I found some similar-but-not-identical issues around subagent/session state:
This report is specifically about
shutdown/ nonexistent agents being visible but not closable, whilespawn_agentstill reports a thread-limit condition.Suggested fix direction
close_agentidempotent: closing an already-shutdown/nonexistent child should return success or a clearalready closed; not countedresult.list_agents, such ascounts_toward_spawn_limit: true/false.agent thread limit reachederror to include active-count / max-count and a list of counted agents.