Plan Mode should allow safe cleanup of completed subagents
Summary
Plan Mode instructions can cause the model to avoid close_agent because it appears to be a mutating action, even when the target subagents are already completed and cleanup is only session resource hygiene.
This is not a report that close_agent is unavailable in Plan Mode. In the observed case, the tool was available and later worked. The problem is that the Plan Mode policy text can lead the assistant to classify completed-subagent cleanup as forbidden mutation, blocking the safe recovery path for agent thread limit reached.
Current behavior
In Plan Mode:
- The user asks for broad read-only planning/research.
- The assistant uses subagents appropriately for read-only sidecar review.
- The subagents complete.
- Later, more sidecars would be useful.
spawn_agentfails or is expected to fail because completed subagents still occupy thread slots.- The safe recovery is
close_agenton completed agents. - The assistant may refuse or defer that cleanup because Plan Mode says not to perform mutating actions.
In the observed session, close_agent was not platform-blocked. The assistant self-blocked due to a conservative interpretation of Plan Mode.
Expected behavior
Plan Mode should explicitly allow safe session lifecycle cleanup that does not modify source, git state, files, runtime product config, permissions, or external systems.
Examples of allowed Plan Mode hygiene should include:
- closing completed subagents after their results have been captured
- closing failed/canceled/stale sidecars when they are no longer useful
- freeing subagent slots before further read-only planning work
- cleaning up retained sidecar state when the user explicitly asks
This should be framed as session resource management, not implementation mutation.
Non-goals
This is not asking Plan Mode to allow:
- editing source files
- staging/committing/pushing
- materializing runtime configs
- changing workspace state
- terminating active useful sidecars merely for impatience
- deleting evidence before results are captured
Suggested instruction refinement
Add something like:
In Plan Mode, closing completed, failed, canceled, or genuinely stale sidecars to free capacity is allowed session hygiene, provided their useful results have been captured and no source, git, workspace, runtime product, credential, permission, or external state is changed.
Why it matters
Long planning sessions often rely on read-only sidecars. If completed sidecars cannot be cleaned up, the thread can hit agent thread limit reached, after which the assistant either stops using sidecars or asks the user to leave Plan Mode solely to perform cleanup.
That creates a false conflict: the planning work should remain read-only, but the session needs basic lifecycle hygiene.
Related issues
- #22779 Completed subagents continue to count against thread limit
- #23479 Main agent needs subagent capacity/status preflight before spawn_agent attempts
- #23700 Stale Codex subagents
- #24389 multi_agent_v1.close_agent can hang for hours when closing an unresponsive subagent
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗