When should you use it?
- Your machine slows after many agent sessions
- Agents start servers and leave them
- You run Linux
Not for: Single short sessions; Machines you do not administer
What do you need, and what do you get?
You need
- Agent launcher script
- Linux cgroups
- Temp folder rules
You get
- Sessions isolated in process groups
- Leftover processes killed
- Temp space kept small
How does it work, step by step?
- Check memorySee whether the temp folder is in memory and filling up.
- Clean tempSchedule a job that removes old unused temp files.
- Wrap sessionsLaunch every agent run inside a dedicated cgroup.
- Kill on finishEnd all processes in that group when the task completes.
- WatchCheck memory and process counts after a week.
The prompt
Our own prompt, inspired by _matthew_ on Hacker News and written to work in Custom agent. Values in lime are placeholders.
Fill in the blanks (optional; the copied prompt uses your values)
Write a launcher that wraps each agent run in a dedicated cgroup and terminates the whole group as soon as the run finishes. Also write a scheduled job that removes files in {tmp_dir} older than {hours} hours that no process has open. Explain how to test both safely.
Inspired by _matthew_ on Hacker News: Comment in Codex Desktop continuously generates Crashpad pending dumps. The prompt above is written by playbooks.bot in our own words; nothing from the original is quoted.
What can go wrong?
- Do not delete files still in use; check open handles.
- Long-running servers you want must live outside the group.
- Test the cleanup on a non-critical machine first.
Our take
Coding agents leave debris that a human session would not: dev servers nobody stops, child processes that outlive the task, and temp files that pile up in memory-backed storage. _matthew_'s diagnosis is the first useful step, because swap pressure on such machines often comes from tmpfs rather than the agents themselves. Check that before buying RAM. Of the two fixes, the cgroup wrapper is the stronger one, because it guarantees cleanup no matter how the agent exits; systemd-run --scope gives you the same effect without writing your own spawner. Before enabling the kill step, list anything that should legitimately survive a session, such as a database container, and start it outside the group. For the temp job, keep the open-handle check the commenter describes, so a long build is never pulled out from under itself, and log what it removes for the first week. Measure free memory and swap before and after, so you know which change mattered. On macOS the same idea applies, but you will need a process-group kill instead of cgroups.
Where the time goes back: Your machine stays fast across many agent sessions.
FAQ
Where was the swap coming from?
Why cgroups?
Source and credit
Inspired by _matthew_ on Hacker News. We describe the idea in our own words, link to the original, and wrote the prompt ourselves; nothing is quoted.
- Inspired by
- Comment in Codex Desktop continuously generates Crashpad pending dumps
- Creator
- _matthew_ on Hacker News
- Published on
- Hacker News
- Original date
- Oct 17, 2026
- License
- Not openly licensed (the poster keeps all rights), so we quote nothing and link to the original
- Originally for
- Custom agent
- AI dry run
- Oct 23, 2026: passed. Dry-run tested by our AI test agent on sample input. PASS: Gates held on desk check; no live sends, bookings or purchases.
AI dry run on sample data; not run with live connected accounts. The playbooks.bot test agent filled the prompt with synthetic inputs, produced the output and checked it against the page's stated outputs and guardrails. - Verified
- Oct 23, 2026: source link resolves to the original, the credited creator published it, our excerpt or prompt matches it, and the license allows our use.
Are you the creator? Claim or correct this page.