openai / openai/codex

Allow /clear to reset coordinator context without terminating live subagents

Open
#44,737 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

app context enhancement subagent
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:

  1. /clear should clear only the current root agent's conversational context by default, while every live child agent continues running unchanged.
  2. 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.
  3. Existing operations should continue to work after the reset: list agents, send/follow up, interrupt, wait for updates, and receive completion/final reports.
  4. A child finishing after /clear must still wake or notify the fresh root and deliver its result exactly once.
  5. If destructive whole-tree clearing is needed, expose it separately and explicitly, for example /clear --all or a confirmation that clearly says it will terminate N live subagents.
  6. 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:

  1. Start a main/root Codex task.
  2. Spawn 3–5 subagents working independently.
  3. Let their execution overlap and continue coordinating them from the root.
  4. Before all children finish, use /clear to reduce the root context.
  5. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.