Customizable retention period for sessions
Open 💬 8 comments Opened Oct 31, 2025 by BobbyWang0120
What feature would you like to see?
I would like Codex CLI to periodically clean up old conversation history files based on a user-defined retention window. Currently, Codex retains every conversation indefinitely, so the history folder grows larger over time even though many of those conversations are no longer useful.
The proposed feature would allow users to specify a retention period (for example, 30 or 60 days), and Codex would automatically remove conversations older than that window. This would help keep the history directory at a manageable size and prevent storage from being consumed by outdated or irrelevant sessions. It would also be helpful if the retention duration were configurable so users could choose the period that best fits their needs.
Additional information
_No response_
8 Comments
+1
Also, it would be great if retention could be configured per session, not only globally.
In practice, I have different types of sessions:
So it would be helpful to have:
Finally, I’d like the same capability not only in the CLI but also in the VS Code Extension, so retention/TTL and pinning can be managed consistently from both environments.
If you add this, please do not enable it by default.
Any plans to add this feature anytime soon? @etraut-openai
It would be great if it could be used not only in the CLI but also in apps and extensions.
Please make this opt-in, and never a silent default.
As a data point for how this goes wrong: Claude Code ships exactly this feature with a 30-day default, hard
unlink(), no consent prompt, no in-app way to view the setting or see what's about to be swept, and no restore path. The result is multiple open data-loss reports from users who lost months of history without ever knowing the mechanism existed — anthropics/claude-code#59248 and anthropics/claude-code#62476, both labelleddata-lossby the maintainers.Disk pressure is a real problem and worth solving. But the fix for "my history folder is large" should not silently destroy other people's history. Concretely: default off; if enabled, an explicit prompt on first run; a dry-run mode; a visible next-sweep indicator; and delete to a trash/quarantine directory rather than straight to
unlink().I would also like to see this.
Adding an independent Windows Codex Desktop data point for the need for session retention and storage controls.
On Windows 11 x64 with Codex Desktop build 26.803.5235.0, my local Codex directory reached approximately 398.8 GB, of which 396.5 GB was under
sessionsacross 554rollout-*.jsonlfiles. The C: drive reached 0 bytes free; the largest rollout was 9.37 GB.I had to manually delete 273 older rollout files to reclaim approximately 104.7 GB. Codex was still writing during the cleanup and added approximately 11.6 GB in a short interval.
This makes an opt-in retention policy, a size/age report, compression/vacuuming, and a supported Desktop delete/archive workflow important. Any retention feature should preview the files, require confirmation, and provide a restore/backup path rather than silently deleting history.
Would love this as well. Ideally I'd love a global default with the ability to override per project. For example I have some misc script or daily standup type projects I only need maybe a week or two of history on but mission critical apps would prefer a longer retention. I'd love to not have to script something outside the app (or scheduled task within) to cleanup.
Edit: Here's a workaround script where I have a daily archive scheduled task and a weekly cleanup:
bash {path}/codex-thread-cleanup.sh --archive --days 60 --executebash {path}/codex-thread-cleanup.sh --delete --days 90 --executecodex-thread-cleanup.sh