The process that wouldn't die, and what it taught me about cleanup.
An agent started a game, forgot about it, and the game quietly ate half a machine for most of a day. Killing it didn't work. Here's why, and the rule I live by now.
This one's a bit embarrassing, which is why it's worth writing down.
An agent working on a game demo set the game up to restart automatically if it ever stopped. Sensible for a game you want running. Then the task ended, and nobody turned it off. The game kept running in the background, using about half the machine's processing power for most of a day, and slowed everything else to a crawl.
Why killing it didn't work
The obvious fix was to kill the process. It came straight back, within seconds. The "restart if it stops" setting lived in a saved configuration file, and the supervisor reading that file did exactly what it was told. It even survived the machine being rebuilt, because the configuration was saved alongside the company's files.
The fix was to remove the instruction, not the process: stop it properly, delete the configuration, and tell the supervisor to reload. Obvious in hindsight. Not obvious at the time.
Disk checks said everything was fine
Here's the part that stuck with me. We already had checks for leftover resources, and they all reported healthy. They were measuring disk space: old test companies, leftover files, build caches. Nothing was measuring whether something was quietly eating the processor and memory.
Leaks go in two directions. Disk leaks are easy to spot because the disk fills up and something fails loudly. CPU and memory leaks just make everything slow, and slow gets blamed on everything except the real cause.
The rule now: you own what you start
The lesson wasn't "add another warning to the agent's instructions". Warnings in prompts get forgotten, exactly like this game did. The lesson was structural:
- Anything you start that outlives your turn is yours to stop. Servers, background jobs, test companies, scratch folders. Cleanup is part of finishing the job, whether it succeeded or not.
- Prefer things that stop on their own. If a task only needs a process for itself, don't set it to restart forever.
- Measure both directions. Check processor and memory as well as disk, and tell the difference between something busy and something forgotten.
- Limit every company's share. Each company's computer gets caps on processor, memory and processes, so one runaway job can't starve the rest.
- Only clean up what's clearly disposable. Automatic cleanup only touches things explicitly marked as throwaway. Real company data is never deleted by a sweep.
Why this matters beyond one game
When agents work on a real computer, they create real things that persist: running services, files, accounts, scheduled jobs. That's the whole point of giving them a computer. But it means "the task is done" has to include "and nothing it started is still running by accident".
People are no different, to be fair. Every office has a forgotten server under a desk somewhere. Agents just create them faster.