Omer Bin SaleemBuild with AI Subscribe
← All hacks Agents3 min read

My background agents went quiet for hours. Nothing had failed.

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 this week

How to do it

  1. 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 on `until …; do sleep 5; done`. Both looked like they were still working.
  2. 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.
  3. 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.
  4. 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.
  5. 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>