codex - 💡(How to fix) Fix Plan Mode should allow safe cleanup of completed subagents

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

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.

Root Cause

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.

RAW_BUFFERClick to expand / collapse

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:

  1. The user asks for broad read-only planning/research.
  2. The assistant uses subagents appropriately for read-only sidecar review.
  3. The subagents complete.
  4. Later, more sidecars would be useful.
  5. spawn_agent fails or is expected to fail because completed subagents still occupy thread slots.
  6. The safe recovery is close_agent on completed agents.
  7. 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

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

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.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING