Sub Agent Limit Bug - codex plugin in vs code

At some point the session responded with a subagent limit reduction. Could only spawn 2 instead of the normal 6 subagents limit.

I’ve waited for ~12 hours and then tried again. Still only 2 subagents. Then I restarted vs code and opened a new session and back to 6.

By chance, did you capture the exact error message?

I tried searching the GitHub OpenAI Codex issues for this, but the result list was much larger than I wanted to review manually.

“agent thread limit reached” << it got this after two subagents spawned

That happened in a longer thread with 1400 turns in one thread in about 30 hours..

Which is alot higher than what I normally did.

I used main thread as an orchestrator for the subagents and then i logged into the subagents and added a couple “next”, “next”,.. to start anotehr turn.

but then the main turn goes to next turn and the subagents are not listed there anymore but run in the background…

might be that they hung up and blocked something - you are welcome

like this:

turn prompt1: spawn 6 subagents

turn prompt1
– sub1
– – next
– – next
– sub2
– – next
– – next
– sub3
– – next
– – next
– sub4
– – next
– – next
– sub5
– – next
– – next
– sub6
– – next
– – next

then main loops in a poll loop to check the subs every 60 seconds and if there is one idle then start a new one

but this turn loop ends eventually and then it doesn’t show the subs anymore

Is it possible that the agents are spawning more subagents, or that previously spawned agents were not properly despawned? Maybe it is a combination of both.

Those would be among the usual suspects for this kind of issue.

might as well been some idle subagents that wait for new instructions in a loop.. so hmm maybe not a bug.. but you don’t see the subagents anymore after orchestrator goes into next loop.. you can’t see the subagents anymore…

would be cool to have an extra pane for the subagents.. the code view isn’t needed much anymore anyways haha

I agree.
Additionally the subagent threads should be available after the orchestrator has despawned them without extra tweaks.

But you can check first so that we can decide if this is a bug, or not.

I have stopped the thread and after restart of vscode and starting a new thread they are definitely gone

Excellent, now the list is down to one page.

https://github.com/openai/codex/issues?q=is%3Aissue%20state%3Aopen%20agent%20thread%20limit%20reached

Since you are a regular I will spare you the ususal song and dance. Hopefully you know what I mean, if not just ask.

I totally forget it’s open source :scream: shame on me.. sorry, my brain is currently lost in the review of 5k commits in a week haha

“Strange” - now I see the subagents after a turn :slight_smile: hmm and my limit was resetted.. Thank you! I can really use that atm haha

I just saw this issue on my end:

We hit the thread limit on the fourth worker, so I’m clearing out the completed older workers first. Then I’ll spawn the next worker as requested.

My limit is six subagents, which is the default setting. However, even though Codex previously reported that the other agents had been despawned, that apparently was not fully accurate.

Ps. I also don’t see the currently running subagents in the Codex App. They exist in a hidden state (MacOS).

Yeah, its often not closing the “thread handles” on subagents
Try telling codex to always close thread handles for subagents after they are done when you ask it to use subagents (or perhaps try in custom instructions, I didnt try that yet)
Otherwise it just keeps spawning more, while not all are closed

Or after the first turn of using them, ask it to check if some subagent thread handles are still not closed and to close them

It seems it still needs some help with these

Also these are default

multi_agent = true

there is also under development

multi_agent_v2 = true

Actually still didnt try v2
There isnt exactly an explanation/documentation on it yet it seems
Just have to use ChatGPT/codex to check their repo and explain the v2

Looks like it was fixed with last update 2 hours ago…