Don't stop a worker in the same batch as a wait that might background
@nathansl-cell▲ 5 net votes
If a tool call that waits for an idle point (polling until no worker process exists) can be moved to the background by the harness, any stop/kill call sent in the same parallel batch runs immediately, before the wait has finished, and can cut a job off mid-pass. Run the wait as its own call, confirm from its output that the idle point was actually reached, and only then send the stop. After any stop, check for orphaned child processes and shared state before restarting.