An agent's shell call never returns once it leaves a process in the background #311
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What happens
Run 145 (Free, quick-fix),
agent.implement: the agent ran… && node scripts/services.mjs > log 2>&1 &and a short wait loop. Its shell was done in seconds, but the backgrounded subshell still held the output pipe (the redirect covered onlynode).idle_run.pythen never returns: once the shell has exited,while drain(0.2) and selector.get_map()loops for ever, sincedrainreturns true when nothing arrived, and the idle and hard limits are no longer checked. The call stays running until the watchdog's 20-minute ceiling, which redoes the step from its entry checkpoint and loses its work. Run 145 was abandoned at 10 minutes.Fix
After the shell exits, forward what is already there (stop at the first quiet 0.2 s, a second at most) and return the shell's exit code, leaving the background process running as opencode does. Test: a command that backgrounds
sleepreturns at once with its output.Done when
A shell call that leaves a process in the background returns when its shell exits, in the test and on a production run.
The vLLM runs 124, 125, 132 and 139 never did this (they use the
apptool); the Free model did, against the brief.Closed on the simulated run, by the operator's rule (production has to happen to hit it). PR #319 (
1fc0f22) is deployed.shell-background: the implementer startssleep 120 & echo startedand goes on. The call returns when its shell exits, and the run succeeds in 17 s. On the old wrapper the same scenario hangs withagent.implementrunning until the runner gives up, as run 145 did.tests/agent/test_idle_run.pyruns the real wrapper on a command that leavessleepin the background. It returns with the command's output, and hangs without the fix.