[Feature Request] When the codex process exits, it cleans up the temporary files created by codex under /tmp.

Open 💬 6 comments Opened Aug 1, 2026 by LIghtJUNction
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

What variant of Codex are you using?

CLI

What feature would you like to see?

I've noticed that over time, my /tmp filesystem gets increasingly full because Codex loads too many temporary files into it without timely cleanup. Since tmpfs resides in memory, these numerous temporary files consume a significant amount of memory, directly impacting device performance.

Additional information

_No response_

View original on GitHub ↗

6 Comments

github-actions[bot] contributor · 27 days ago

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

  • #35383

Powered by Codex Action

LIghtJUNction · 27 days ago
Potential duplicates detected. Please review them and close your issue if it is a duplicate. * Worktree/temp-clone lifecycle broken: auto-delete and worktree-keep-count not enforced; managed-worktree list reports zero while 118 multi-GB run copies (202 GB) accumulate in /tmp #35383 _Powered by Codex Action_

No, I'm not closing it; these two issues are different.

LIghtJUNction · 26 days ago

I really envy OpenAI; your /tmp is so big that you can stuff all these junk files into it. My laptop only has a pitifully small amount of memory, so this problem is a huge one for me.

LIghtJUNction · 18 days ago

I implemented a candidate lifecycle fix for Codex-owned hook temporary output:

  • Each hook runtime now uses a process-owned, locked temporary root.
  • Owned stale directories are swept safely on startup, and the exact root is removed on runtime shutdown/drop.
  • Unknown legacy /tmp content is not deleted blindly.
  • PR: https://github.com/LIghtJUNction/codex/pull/1
  • Commit: 4c9440e8d

My account cannot create the upstream PR because it has read-only permissions on openai/codex. Please review the fork PR or cherry-pick the commit.

LIghtJUNction · 18 days ago

I have a suggestion: the Codex shouldn’t simply discard temporary files directly /tmp.
It should be discarded at /tmp/chatgpt or /tmp/codex.
Since Codex has been merged into ChatGPT, I recommend using the former option.

Secondly, it is necessary to introduce a mechanism for regular cleanup operations.

Secondly, it should support the configuration. The /tmp/chatgpt folder actually contains two sub-folders.
For example:
/tmp/chatgpt/tmpfs
/tmp/chatgpt/non-tmpfs
It’s best to use names that directly convey the meaning. After all, these names are meant to be understood by AI. This way, AI will know which data should be stored in tmpfs to achieve faster processing.
What data should be discarded from the regular file system, rather than using tmpfs, which consumes all of the memory available.

Similar improvements should also be made for other systems.

Basically, after a while, I need to clean up the /tmp directory. It’s quite tedious. It would be best if this process could be automated.

LIghtJUNction · 18 days ago

@fcoury @genki @simonw @longouyang Please help me take a look for me. Thank you.