You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Should not have giant hacks to reuse sandbox for validation loop #6961
I know dropping the validation loop would be a big change, but the only other non-hacky way I can think of to fix this is to not terminate the agent process - the agent has a MCP tool it calls that says "I think I'm done" which runs the validation loop.
Updated 2026-09-06. Rewritten after measuring the runner's exact sandbox setup on a live OpenShell 0.0.116 gateway (podman driver). Key changes from the original comment:
The proposal is now stop the sandbox, not the processes: sandbox stop at a deadline instead of the enumeration sweep, and a validation retry that never kills anything.
Several claims in the original were wrong; they are listed at the end.
Every claim below is either read from OpenShell v0.0.116 source (d1155aa) or measured on that gateway. My reply on the PR thread is superseded by this comment.
When the runner must stop an agent, it issues sandbox stop. That is the budget deadline, and later a Codex mid-turn steer. Stop is the one released, driver-enforced operation that ends every process in the sandbox, detached children included, and keeps everything on disk. Then start (about a second) and either resume the session with a wrap-up steer, validated on all three runtimes, or extract and delete.
This matches what OpenShell told us on #3159: a caller that reuses a sandbox owns cleanup, and the platform's tool for that is the sandbox lifecycle, not the exec channel.
What we measured
Enumeration sweep (today)
Fresh sandbox per iteration
Stop, then resume
Kills detached children
best effort: warning-only, races new spawns, needs a working exec channel
yes
yes, kernel-enforced, no exec channel needed
Keeps working tree and session
yes
no; re-upload, new session
yes, /sandbox and /tmp both kept
Cost
under a second
13–24 s create + 5–7 s bootstrap + repo upload
45 s stop today + ~1 s start
Resume after
n/a
n/a
Claude 21 s, pi 8 s, Codex 9 s, same session
The 45 s is upstream bug #2855: the podman driver drops CAP_KILL, so the supervisor cannot signal its main process and waits out the SIGKILL grace. Fixed by #3036, merged 2026-09-01, not yet in a release. fullsend already pays that 45 s on every sandbox delete.
Honest limits
The agent tree gets SIGKILL, never TERM. Codex resumed with one tool call left without output, logging a warning; a stop landing mid-write was not exercised.
Measured on podman only. Docker and Kubernetes stop timing and retention are unmeasured.
45 s per stop is fine for a budget deadline and a different trade for a steer; the steer keeps the sweep until setup-gcp action uses scripts/ path that breaks per-repo installs after #3000 #3036 ships. When it moves, the Codex interrupt seam is a command runner inside the sandbox, so wiring the lifecycle call in is an injection change, not a one-line swap.
What the runner changes
Treat its own stop as a branch in the loop, not a message to relabel. The in-flight exec returns a relay-closed error that today ends the run (reported as "Agent exited with code 1"). On a steer that would end the run before the resume turn, so the loop has to distinguish "I stopped this to resume it" from "the sandbox went away", which reach the same error now. The deadline comes from the steer budget the runner already tracks.
start before extraction, since download needs Ready.
Hold the sandbox lock across stop and start so credential refreshers do not upload into a stopped sandbox.
Never run the run-scoped provider cleanup on a stop. It expires the OpenAI credential in place and the resumed turn fails; cleanup belongs to the real end of the run. Our first Codex resume failed exactly this way.
No MCP server for this, remote or sidecar: it costs context per turn, VM resources and a second control surface next to the harness. The agent's early signal is the existing in-sandbox fullsend-check-output; the turn boundary is the contract the runner relies on; the host-side validation script and post-script keep the schema and outcome checks.
What changed from the original version of this comment
The original proposal was live-session validation plus a process-group interrupt; the interrupt is replaced by sandbox stop, since a --no-tty exec inherits the supervisor's process group and a group kill from inside the sandbox would hit PID 1.
Turn ends are observed per runtime, not uniformly: Claude per turn, pi per prompt, Codex only at process exit. Live validation is a runner-loop change plus a Codex idle-aware next-turn path, not "no runtime change".
max_iterations and feedback_mode keep their names but change meaning, from process re-runs to turns.
fullsend-check-output is installed, not enforced.
The working-tree cost of a fresh sandbox was overstated; the runner already downloads the dirty tree every iteration. The real cost is the provisioning time in the table.
The second ADR was cited with a number that collides with a merged ADR; PR numbers only now.
Status (2026-10-03): still open. This closes with #6965, which delivers validation feedback as the next turn of the live session, so the validation loop no longer kills the agent or runs the stray-process sweep. #6965 lands after the steer stack (#7007 → #7461); the stack alone does not change the validation path.
One update to the numbers in the comment above: fullsend now pins OpenShell 0.1.2 (#7233), where sandbox stop takes well under a second on podman when processes honour TERM, instead of 45 s. Exec'd processes also get their own process group. That makes stop-instead-of-sweep cheap for any remaining kill, such as the deadline or the Codex interrupt. One caveat: a stop issued right after a start can leave the sandbox in Error (ai-openshell/openshell#3776), so a restarted sandbox needs a short post-start check.
Activity
waynesun09 commentedon Sep 3, 2026
Proposal
sandbox stop. That is the budget deadline, and later a Codex mid-turn steer. Stop is the one released, driver-enforced operation that ends every process in the sandbox, detached children included, and keeps everything on disk. Thenstart(about a second) and either resume the session with a wrap-up steer, validated on all three runtimes, or extract and delete.This matches what OpenShell told us on #3159: a caller that reuses a sandbox owns cleanup, and the platform's tool for that is the sandbox lifecycle, not the exec channel.
What we measured
/sandboxand/tmpboth keptThe 45 s is upstream bug #2855: the podman driver drops
CAP_KILL, so the supervisor cannot signal its main process and waits out the SIGKILL grace. Fixed by #3036, merged 2026-09-01, not yet in a release. fullsend already pays that 45 s on everysandbox delete.Honest limits
What the runner changes
startbefore extraction, since download needsReady.Related
fullsend-check-output; the turn boundary is the contract the runner relies on; the host-side validation script and post-script keep the schema and outcome checks.What changed from the original version of this comment
sandbox stop, since a--no-ttyexec inherits the supervisor's process group and a group kill from inside the sandbox would hit PID 1.max_iterationsandfeedback_modekeep their names but change meaning, from process re-runs to turns.fullsend-check-outputis installed, not enforced.waynesun09 commentedon Oct 3, 2026
Status (2026-10-03): still open. This closes with #6965, which delivers validation feedback as the next turn of the live session, so the validation loop no longer kills the agent or runs the stray-process sweep. #6965 lands after the steer stack (#7007 → #7461); the stack alone does not change the validation path.
One update to the numbers in the comment above: fullsend now pins OpenShell 0.1.2 (#7233), where
sandbox stoptakes well under a second on podman when processes honour TERM, instead of 45 s. Exec'd processes also get their own process group. That makes stop-instead-of-sweep cheap for any remaining kill, such as the deadline or the Codex interrupt. One caveat: a stop issued right after a start can leave the sandbox in Error (ai-openshell/openshell#3776), so a restarted sandbox needs a short post-start check.