My background agents went quiet for hours. Nothing had failed.
Originally published at omerbinsaleem.com by Omer Bin Saleem (Omer Saleem). Two background agents each sat on one command for about two and a half hours, with no error and no completion notice. Here is the brief rule an
Originally published at omerbinsaleem.com by Omer Bin Saleem (Omer Saleem).
Two background agents each sat on one command for about two and a half hours, with no error and no completion notice. Here is the brief rule and the silence check I use now.
What changed
- Every build brief now bans wait loops and rm -rf.
- Any agent quiet for about 30 minutes gets a timestamp check instead of more waiting.
How to do it
- Know the failure mode. In a background agent, a command that needs a permission prompt, or a blocked foreground sleep, does not fail. It just waits forever. One of my agents stopped on
cp ... && rm -rf ..., the other onuntil ...; do sleep 5; done. Both looked like they were still working. - Ban the risky shapes in every brief: no sleep, until or while wait loops, and no rm -rf. Plain rm on named files is allowed, so the agent can still clean up.
- Give long jobs a real ending. Run them in the foreground with a timeout, or with run_in_background and wait for its completion notification instead of polling in a loop.
- Check silence, do not trust it. If an agent has been quiet for more than about 30 minutes, grep the last "timestamp" in its output file and compare it with the file mtimes in its working folder.
- If both are stale, stop the agent and relaunch it with "continue from build-progress.md". This only works if the agent wrote a progress file as it went, so ask for one in the brief from the start.
Prompt to copy
You are a background build agent. Follow these rules for every shell command:
- Never use sleep, until or while loops to wait for something.
- Never use rm -rf. Use plain rm on named files only.
- Run long jobs in the foreground with a timeout, or with run_in_background and wait for its completion notification.
- After each finished step, update build-progress.md with what is done, what is next and which files changed.
- If you are told "continue from build-progress.md", read it first and resume from the next step without redoing finished work.
Task: <describe the build here>
I am Omer Bin Saleem, a frontend chapter lead who builds with AI every day. One practical AI hack a day at omerbinsaleem.com. LinkedIn: omer-bin-saleem ยท Instagram: @iomerbinsaleem.
Written with AI assistance, from my own work notes.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes โ full credit and traffic to the original publisher.