End a worker that lingers after its final result by stopping the quiet background shells it left #611

Merged
lilleman merged 8 commits from item-420 into main 2026-11-19 08:15:48 +01:00
Owner

loop-claude ends a worker that printed its final result and then lingers on a background shell. Every 5 minutes without output after the result, it stops each shell of the worker's claude, and what runs below it, unless a shell wrote output in the last 3 minutes, runs chunk-pr or run-heavy, or has a process holding a heavy slot. It prints each stop and appends it, with the UTC time, to lingering-workers.md in the project's transcript archive.

BASH_MAX_TIMEOUT_MS and BASH_DEFAULT_TIMEOUT_MS only raise the limit, and a call's own timeout of up to 2 hours replaces it, so they can't bound the wait (bin/agent_cycle/lingering_workers.py).

  • The check lives in run_claude (bin/agent_cycle/worker.py), not in run_loop, since item 401 moved the worker code. The /compact run passes no record and gets no check.
  • The record goes to the project's transcript archive instead of the judge's records: the judge reads a worker's transcript, and the archive is where the pattern can be counted for item 421 (a rule-hook ban).
  • Shells of a subagent are children of the same claude and count like the worker's own.
  • Checked against the process layout of a real claude -p run (bash -c source <snapshot> … eval '<command>' below claude, output in a regular file); the 3-minute rule itself was not yet seen end to end in a live loop.
loop-claude ends a worker that printed its final result and then lingers on a background shell. Every 5 minutes without output after the result, it stops each shell of the worker's claude, and what runs below it, unless a shell wrote output in the last 3 minutes, runs `chunk-pr` or `run-heavy`, or has a process holding a heavy slot. It prints each stop and appends it, with the UTC time, to `lingering-workers.md` in the project's transcript archive. `BASH_MAX_TIMEOUT_MS` and `BASH_DEFAULT_TIMEOUT_MS` only raise the limit, and a call's own `timeout` of up to 2 hours replaces it, so they can't bound the wait (`bin/agent_cycle/lingering_workers.py`). - The check lives in `run_claude` (`bin/agent_cycle/worker.py`), not in `run_loop`, since item 401 moved the worker code. The `/compact` run passes no record and gets no check. - The record goes to the project's transcript archive instead of the judge's records: the judge reads a worker's transcript, and the archive is where the pattern can be counted for item 421 (a rule-hook ban). - Shells of a subagent are children of the same claude and count like the worker's own. - Checked against the process layout of a real `claude -p` run (`bash -c source <snapshot> … eval '<command>'` below `claude`, output in a regular file); the 3-minute rule itself was not yet seen end to end in a live loop.
lilleman added 1 commit 2026-11-18 16:53:34 +01:00
lilleman added 6 commits 2026-11-19 08:09:26 +01:00
lilleman marked the pull request as ready for review 2026-11-19 08:10:40 +01:00
lilleman added 1 commit 2026-11-19 08:10:55 +01:00
Finish item 420 in the plan
CI / tests (pull_request) Successful in 4m45s
a559bbfcbf
lilleman merged commit a559bbfcbf into main 2026-11-19 08:15:48 +01:00
lilleman deleted branch item-420 2026-11-19 08:15:48 +01:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: lilleman/claude-config#611