An agent's shell call never returns once it leaves a process in the background #311

Closed
opened 2026-10-29 16:38:50 -04:00 by cmoriarty · 1 comment
Owner

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 only node). idle_run.py then never returns: once the shell has exited, while drain(0.2) and selector.get_map() loops for ever, since drain returns 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 sleep returns 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 app tool); the Free model did, against the brief.

**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 only `node`). `idle_run.py` then never returns: once the shell has exited, `while drain(0.2) and selector.get_map()` loops for ever, since `drain` returns 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 `sleep` returns 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 `app` tool); the Free model did, against the brief.
Author
Owner

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 starts sleep 120 & echo started and goes on. The call returns when its shell exits, and the run succeeds in 17 s. On the old wrapper the same scenario hangs with agent.implement running until the runner gives up, as run 145 did.
  • The medium test tests/agent/test_idle_run.py runs the real wrapper on a command that leaves sleep in the background. It returns with the command's output, and hangs without the fix.
**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 starts `sleep 120 & echo started` and goes on. The call returns when its shell exits, and the run succeeds in 17 s. On the old wrapper the same scenario hangs with `agent.implement` running until the runner gives up, as run 145 did. - **The medium test** `tests/agent/test_idle_run.py` runs the real wrapper on a command that leaves `sleep` in the background. It returns with the command's output, and hangs without the fix.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
cmoriarty/braid#311
No description provided.