Command to clear context in current session

Open 💬 4 comments Opened Apr 27, 2026 by MrLightful
💡 Likely answer: A maintainer (etraut-openai, contributor) responded on this thread — see the highlighted reply below.

What variant of Codex are you using?

App

What feature would you like to see?

Working the worktree, I like to run review skills on empty context, giving it another chance to explore code potentially finding new edge cases.

There is, however, no way to clear context in the current session/worktree (e.g. /clear).

Additional information

_No response_

View original on GitHub ↗

4 Comments

etraut-openai contributor · 4 months ago

The way I typically do this is to ask the agent to create a subagent to do the work. Subagents work within the same context (worktree) but get an empty context. Once a subagent is done, it reports back to the main agent, which can then supply the answer to you. Does that address your use case?

MrLightful · 4 months ago
The way I typically do this is to ask the agent to create a subagent to do the work. Subagents work within the same context (worktree) but get an empty context. Once a subagent is done, it reports back to the main agent, which can then supply the answer to you. Does that address your use case?

@etraut-openai, thanks for the suggestion.

Well, not quite. Usually after running the reviews, I want to continue with discussing details & making new plans for the fixes, which in this way still happens in the already polluted session. I'd rather keep it entirely clean for these continuation stuff, which can be quite large on their own.

williamlmao · 3 months ago

Really wish we had this esp for worktrees

devansh-jain-18 · 2 months ago

This also shows up in the existing-worktree workflow from #22316.

The concrete need is: keep the same worktree/files/git index, but drop the accumulated transcript/context so a fresh pass can continue from the current filesystem state. Forking does not solve this because it preserves history, and New worktree does not solve it because it creates a different checkout.

A /clear-style command in the current session/worktree would be one good solution; a separate "New thread here" / "Use existing worktree" flow would be another.