Skip to content

Forbid an Unbounded Shell Wait, and Say Who Reaps the Process It Leaves #1589

Closed

Description

@ptr727

AGENTS.md "Commands" ends its wait rule with "and bound it, so a condition that is never coming ends in a report rather than in another wait". That clause is the last six words of a 150-word paragraph, it names no mechanism, and it is the only thing standing between the fleet and an agent-authored loop that runs until the machine is rebooted. It is not enough, and this is the second machine-level incident it failed to prevent.

What happened

A backlog-burndown run in a carrier repository dispatched six workers over about five hours. Each worker brief told it, in these words, to "block and poll INLINE in a bounded loop" while waiting on a review subagent it had dispatched. Every worker complied with the letter and produced this:

until [ -s "<temp>/claude/<session>/tasks/<id>.output" ]; do sleep 30; done

Hours after the last worker had finished, reported, and had its worktree retired, seven of those loops were still running, forking a fresh sleep process every 15 to 30 seconds. Each awaited file existed at zero bytes, so [ -s ... ] and find -size +1c could never become true. The condition was not merely slow, it was unsatisfiable, which is the exact case the trailing clause names and the exact case nothing enforced.

An eighth shell had been running a full filesystem walk, find / -name "<tool>.py", for just under four hours, because that worker's brief named a hub tool without naming its path.

The maintainer reports that in a previous session the same shape exhausted the machine's resources and forced a reboot.

Measured at the point of discovery: 16 bash and 7 sleep processes alive, PIDs recycling every few seconds. All eight shells had to be killed by PID by hand.

Why the current rule does not prevent it

  1. "Bound it" is an adjective, not a mechanism. Every worker read it as a description of a good wait rather than as a thing to write into the command. None emitted a timeout, an iteration cap, or a deadline. A rule whose compliance is invisible in the artifact is a rule nothing can check, which is what the gate label exists to mark.
  2. The rule assumes the wait is the agent's to end. It says a wait "ends in a report", which presumes the process dies when the turn does. It does not. A shell started by a tool call outlives the subagent that started it, so the loop survives the agent, the report, the worktree, and the run. Nothing in the fleet rules says who reaps it.
  3. The forbidden shape is never named. until <cond>; do sleep <n>; done is the shape that leaks, it is what an agent writes when told to poll, and no rule text mentions it.
  4. It sits under "Commands", framed as a cost rule. The whole section is about context billing. The failure mode here is not tokens, it is the maintainer's machine, and nothing in the section's framing tells a reader that.

What I propose, and it should be a "never"

A new bullet in AGENTS.md "Commands", worded as a prohibition rather than as advice, roughly:

  • Never author a wait as an unbounded shell loop. until <condition>; do sleep <n>; done and while ! <condition>; do sleep <n>; done are forbidden outright, in a tool call, a script, or a brief handed to a subagent. Every wait carries its bound inside the command that runs it, as a timeout <seconds> wrapper or an explicit iteration counter, and every wait exits loudly when that bound is reached, since a wait that cannot distinguish "not yet" from "never" is the one that runs until the machine is rebooted. Prefer the mechanism that already signals. Where the dispatch mechanism reports a subagent's completion on its own, polling that subagent's transcript file is a second, unreliable channel for an answer already being delivered, and a file another process may never write is not a condition at all. The agent that starts a wait owns the process it leaves behind. A wait that outlives the turn that started it is a leak, and a run that dispatched workers sweeps for surviving shells before it reports itself done.

Three things that make it enforceable rather than decorative:

  • State the bound as a shape to copy, the way the briefing template in "Delegation" is a shape to copy. A worker reproduces a quoted form and does not reproduce an adjective.
  • Put the sweep in a procedure that runs, not only in the law. backlog-burndown's cleanup step already runs once per round from the base clone while no worker is live, and it already covers worktrees and branches, which are the other two things workers leave behind. Surviving shells belong in that same step.
  • Give it a mechanical layer. A scripts/ helper whose only interface takes a mandatory timeout would make the compliant form the shortest form to write, which is the only thing that reliably beats the shape agents reach for by default.

The half that is not ours

The harness contributes: a shell started by a tool call is not reaped when the subagent that started it completes, so an agent cannot clean up after itself even when it wants to, and the loops are invisible to every agent in the run. I am reporting that separately through the product channel. It does not reduce what the fleet rules owe here, since the rules are what decide whether an unkillable loop is ever written in the first place.

Related

Activity

  1. added
    agents
    gate
    prose
    on Sep 13, 2026
  2. added 2 commits that reference this issue on Sep 15, 2026
    e1559c9
    dbbb28f
  3. added a commit that references this issue on Sep 15, 2026
    3084c22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agentsgateprose

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions