Clear context before implementing plan

Resolved 💬 14 comments Opened Mar 11, 2026 by matheuspimentaa Closed Apr 20, 2026
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

What variant of Codex are you using?

App, IDE, CLI

What feature would you like to see?

In tools like Copilot and Claude Code there is a very interesting feature: after creating a plan, it returns three options:

  1. Clear context and implement
  2. Implement without clearing context
  3. Continue in planning mode to iterate with more information.

Having an option to clear the context before implementing would be very helpful because when we are in a very long thread with many interactions to develop a more complex, concise, and accurate plan, it ends up consuming a lot of the context window.

Implementing from a reset (clean) context window would be much more effective, reducing the chances of the LLM hallucinating—especially when using lower reasoning effort for the implementation phase.

Additional information

_No response_

View original on GitHub ↗

14 Comments

github-actions[bot] contributor · 4 months ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #10948

Powered by Codex Action

smartcmd · 4 months ago
smartcmd · 3 months ago

@etraut-openai Will I have the opportunity to submit a PR? c:

etraut-openai contributor · 3 months ago

@smartcmd, we prioritize features based on community feedback (upvotes). This hasn't received many upvotes yet compared to many others, so it's not one that we will be spending time on at the moment, including accepting PRs, since that requires time to review and validate.

smartcmd · 3 months ago
@smartcmd, we prioritize features based on community feedback (upvotes). This hasn't received many upvotes yet compared to many others, so it's not one that we will be spending time on at the moment, including accepting PRs, since that requires time to review and validate.

Alright thanks for the reply!

Murphy-Joe · 3 months ago
@smartcmd, we prioritize features based on community feedback (upvotes). This hasn't received many upvotes yet compared to many others, so it's not one that we will be spending time on at the moment, including accepting PRs, since that requires time to review and validate.

Or we could just recognize at face value that this is a basic necessity. I will assume you use AI tools so I won't provide the obvious reasoning.

etraut-openai contributor · 3 months ago

@Murphy-Joe, I use plan mode dozens of times a day, and I've never felt the need to clear the context before starting the implementation. I'm not saying that this feature request isn't valid, but I'm just pointing out that it's not so obvious that it's a "basic necessity".

Murphy-Joe · 3 months ago
@Murphy-Joe, I use plan mode dozens of times a day, and I've never felt the need to clear the context before starting the implementation. I'm not saying that this feature request isn't valid, but I'm just pointing out that it's not so obvious that it's a "basic necessity".

sorry i'm rude. working on it.

redyuan43 · 3 months ago

I have an implementation prepared for this and would be happy to open a PR if the Codex team would like to invite one.

What it does:

  • adds a third post-plan action: Yes, clear context and implement
  • keeps only the latest completed <proposed_plan> as the compacted summary payload
  • clears the rest of the model-visible conversation history
  • switches back to Default mode
  • automatically submits Implement the plan.

Implementation notes:

  • I kept this as a dedicated plan-only handoff compaction path rather than reusing generic /compact, so the approved plan is preserved while the extra chatter is dropped.
  • The change includes matching TUI, core, app-server/protocol, docs, and tests support.

Prepared branch / commit:

  • branch: redyuan43/codex:ivan/plan-only-handoff-compaction
  • commit: ce1fdd8ace80d9be66eab4a2e468833da691eee6

If this aligns with the intended solution, would the Codex team be willing to invite a PR for it?
https://github.com/openai/codex/compare/main...redyuan43:ivan/plan-only-handoff-compaction?expand=1

Adding a UI snapshot and the ready-to-open PR link for reference.

<img width="802" height="179" alt="Image" src="https://github.com/user-attachments/assets/ba00c037-9e0c-4656-9a60-d575840abd1d" />

bgmulinari · 3 months ago
@Murphy-Joe, I use plan mode dozens of times a day, and I've never felt the need to clear the context before starting the implementation. I'm not saying that this feature request isn't valid, but I'm just pointing out that it's not so obvious that it's a "basic necessity".

@etraut-openai I'm also really missing this feature. Sometimes when you're finally done with a version of a plan you're happy with and ready to implement it, there's not enough context left for the implementation. I usually try to avoid compaction as much as possible and starting a fresh session with a finished plan ready to go would be ideal.

fcoury-oai contributor · 3 months ago

Implemented in https://github.com/openai/codex/pull/17499

Released in 0.122.0

markasoftware-tc · 3 months ago

One thing I'm a little concerned about with the fix is that the plans generated by codex often don't have as much detail as necessary to fully implement the plan. It seems like the plans are designed to be consumed alongside the existing context, or at least, the user's initial prompt. If you ask codex to "generate a plan with enough detail that someone else could implement it without reading our whole conversation", it generally comes up with something a lot more detailed than the "finalized plan" it prints out in plan mode.

Maybe the model could be prompted to come up with either a more detailed plan, or the extra context that might be needed alongside the plan (similar to compaction), before clearing the context.

fcoury-oai contributor · 3 months ago

@markasoftware-tc that's a fair point. In my testing, Codex instead went hydrating the necessary context as needed but it's for sure a trade-off. Curious to hear your experience with the feature.

TylonHH · 2 months ago

How can I use /clear in the codex app (windows)?
after sending this command the context window is stsill full

<img width="760" height="262" alt="Image" src="https://github.com/user-attachments/assets/6fb753e6-e5ce-4667-a83d-c73beb9f0d5e" />