VS Code reload re-adds closed subagents to the "background agents" count
What version of the IDE extension are you using?
26.707.31428
What subscription do you have?
ChatGPT Pro (20x)
Which IDE are you using?
Visual Studio Code 1.128.0 (x64)
What platform is your computer?
Microsoft Windows NT 10.0.26200.0 x64
What issue are you seeing?
In a local Codex conversation that uses multiple subagents, closed/completed subagents are re-added to the composer’s “background agents” panel after reloading or restarting VS Code.
In my reproduced case, the UI displayed “33 background agents” even though the persisted state for that conversation contained:
- 33 closed spawn edges
- 0 open spawn edges
This makes it appear that many agents are still running. The displayed count accumulates across a long-running conversation as more agents are spawned and closed.
What steps can reproduce the bug?
- Open a local Codex conversation in the VS Code extension.
- Have Codex spawn several subagents/background agents.
- Allow the agents to finish and close them using
close_agent. - Confirm that no agents should remain active.
- Reload the VS Code window or close and restart VS Code.
- Reopen the same Codex conversation.
- Observe that previously closed agents reappear in the “background agents” panel and are included in its count.
- Repeat the spawn, close, and reload cycle; the displayed count continues accumulating historical agents.
What is the expected behavior?
Closed agents should remain closed after conversation hydration.
The “background agents” summary should count only agents that are currently active or waiting. Completed agents may remain available as conversation history, but they should not be included in a count that implies they are still running.
Additional information
Environment:
- Codex IDE extension: 26.707.31428
- IDE: Visual Studio Code 1.128.0 (x64)
- Subscription: ChatGPT Pro (20x)
- Platform: Microsoft Windows NT 10.0.26200.0 (x64)
Read-only inspection of %USERPROFILE%\.codex\state_5.sqlite confirmed that the affected parent conversation had 33 closed entries and zero open entries in thread_spawn_edges. All 33 child threads remained unarchived.
Inspection of the installed extension bundle showed that reload hydration requests unarchived subAgentThreadSpawn threads. The resulting composer summary uses the total row count, including completed rows, rather than filtering to active/waiting agents.
This strongly suggests that closed agents are hidden correctly during the live session but are reconstructed as completed background-agent rows during reload hydration.
No extension files or Codex state files were modified during this investigation.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗