Allow /clear to reset coordinator context without terminating live subagents
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 125k
- Forks
- 19.4k
- PR merge metrics
- PR metrics pending
Description
What variant of Codex are you using?
Codex App on macOS (Apple Silicon), bundled codex-cli 0.154.0.
What feature would you like to see?
Allow /clear to reset the main/coordinator agent's conversation context without terminating, cancelling, or orphaning its live subagents.
I use one main agent as a long-running coordinator for roughly 3–5 independent subagents. Those subagents deliberately overlap: I commonly start the next task shortly before another subagent finishes. The main thread accumulates status messages, tool output, plans, and completed-agent reports, so I need to clear it periodically to keep the active context and token usage bounded.
Today there is no practical safe time to use /clear: clearing the coordinator also kills or disconnects its subagents. Waiting until all subagents finish does not solve the workflow because there is usually another live subagent by then. The result is an indefinitely growing coordinator context or destroyed in-flight work.
Requested behavior:
/clearshould clear only the current root agent's conversational context by default, while every live child agent continues running unchanged.- The fresh root context should receive a small machine-generated coordination handoff containing each live subagent's stable ID/name, task, status, and routing information—not the old root transcript.
- Existing operations should continue to work after the reset: list agents, send/follow up, interrupt, wait for updates, and receive completion/final reports.
- A child finishing after
/clearmust still wake or notify the fresh root and deliver its result exactly once. - If destructive whole-tree clearing is needed, expose it separately and explicitly, for example
/clear --allor a confirmation that clearly says it will terminate N live subagents. - The UI should state the scope before clearing: “Clear coordinator context; 4 subagents will continue.”
An alternative compatible command such as /clear --root-only would also work, but root-only clearing is the safer default for a coordinator workflow.
Additional information
Typical reproduction:
- Start a main/root Codex task.
- Spawn 3–5 subagents working independently.
- Let their execution overlap and continue coordinating them from the root.
- Before all children finish, use
/clearto reduce the root context. - Observe that live subagent work is killed, disconnected, or no longer safely coordinated.
Expected result: only the root model context is reset. Child task/runtime state is independent of the root transcript lifecycle and survives the reset.
This is particularly important for token control. A fresh coordinator turn should not resend or reconstruct the full pre-clear root transcript. It only needs the compact live-agent handoff plus new messages and later child results.
This differs from requests about clearing completed/stale subagents: the subagents here are intentionally live and doing useful work. The request is to decouple root-context lifecycle from child-execution lifecycle, similar to coordinator/subagent workflows where clearing the coordinator does not cancel its workers.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the /clear command entry point in codex-cli and trace how resetting the root context currently affects live subagents. Reproduce the issue with one root and 3–5 overlapping children, then verify that root-only clearing preserves child execution, coordination, notifications, and final reports. Done means the UI states the scope and an explicit whole-tree option remains available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- macos, rust
- Domain
- ai-infra-agents, cli
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100