Contain agent runs and clear old temp files
A developer limited each coding run to a separate cgroup and added a recurring cleanup for forgotten temp files.
- What they did
- They noticed swap pressure coming from a tmpfs-based /tmp and from processes left behind by earlier agent runs. In response, they set up a frequent housekeeping job that removes temporary files older than about two hours, but only if nothing still has them open. They also wrote an agent launcher that places every coding session in its own cgroup and ends all processes in that group once the work is done.
- How it went
- The write-up says these changes reduced the swap problem and the lingering processes. It does not provide any benchmark numbers or a before-and-after comparison.
- Tips
- Check the real source of swap use before assuming the agents are to blame. The temp-file cleaner is intentionally conservative, so it skips files that are still open.
Try it yourself with Codex
In [repo or project], create a small launcher for [Linux distro or init system] that starts each coding-agent run inside a dedicated cgroup. When the run ends or fails, stop every process still attached to that cgroup. Add a scheduled task that removes stale files from [tmp path] once they have been idle for about [number] hours, but only if no process currently has them open. Before any deletion or process termination outside the test case, list exactly what would be affected and wait for my approval.
Fill in the [brackets]. Agents can make mistakes, so review anything before it is sent, paid or deleted.
Get 3 agent uses like this every morning
With the day's top AI news. Free, and one click to unsubscribe.
Related agent uses
Flag coding conflicts before agents edit
They set up a local layer that makes coding agents announce planned changes so overlapping architecture work gets caught early.
Move builds and tests to a remote Windows VM
A developer had Codex run builds and tests over SSH on WSL in remote Windows VMs instead of using their Mac laptop.
Create and launch a BaZi reading agent
A developer used coding agents to build a BaZi reader that calculates charts, writes interpretations, and handles language detection and USDT payments.
Run agent coding jobs in a sealed local box
A developer used Codex to run an almost fully self-contained build-and-deploy workflow on a locked-down spare machine.
Turn tracked tickets into pull requests
Use an agent to pick up issues or tickets, make the code change in an isolated pod, and open a PR for review.
Use Codex as a first-pass code submission filter
A commenter used Codex with a custom agents.md to check candidate code and automatically turn away submissions that broke simple file-change limits.