I'd been running into a lot of disk pressure on my system from agents running. I discovered two main causes:

- my approach to using git worktrees for all work. Not entirely surprising, the duplicated build artifacts in each worktree being the main culprit here. There were some limited gains to be had by just being more efficient with how builds were managed but ultimately I just had to limit the number of concurrent features I was working on in a couple of particularly large repos.

- more insidious was the fact I was actually hitting memory limits more than I realised and causing my mac to have to swap heavily. The system was surprisingly still quite performant while this was happening... until it wasn't. Unfortunately as best I can tell the only "fix" when this happens is to restart the machine. There's no way to have the system reclaim any of the swap space once it's written to disk. Which if you have it thrash a couple of times a day (especially easy if you leave something running overnight) adds up very quickly.

I ran into similar issues. Sometimes though there are good language specific solutions. For Rust based worktrees you should definitely check out https://mr-boxington.jdx.dev/ .

Regarding swapping, are you sure it's not just from ram backed tmpfs partition? For me that was it and most of the swap was from /tmp. So I created an agressive job that runs frequently to delete all tmp files not used in the last ~2 hours without any command holding handles to it.

The other thing I found was that there were a bunch of leftover processes from prior coding agents forking commands and just leaving them. So I had to build a system into my agent spawner to automatically launch each agent session in a cgroup whose processes all get killed on task completion.

switching to copy on write worktrees is the biggest game changer it should become common knowledge pretty soon and it's already available on most operating systems