Repository navigation
Recover quarantined sandbox slots with bounded retries - #471
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
335be85 to
9978dc6
Compare
21bf160 to
0a96cb5
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 21bf160199
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
9978dc6 to
6f02cb5
Compare
0a96cb5 to
0685fb1
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0685fb1fba
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
6f02cb5 to
880fbb5
Compare
ed55780 to
1ef06cb
Compare
880fbb5 to
3181c7d
Compare
1ef06cb to
32e3316
Compare
gregorybchris
left a comment
There was a problem hiding this comment.
This review was generated by an agent following
REVIEW_GUIDE.md. It is not from a human reviewer. Reply in the PR thread and a maintainer will follow up.
Looks good overall! The recovery logic is careful: replacement is single-flight, it waits for active leases, it leaves bound sessions alone, and shutdown waits for in-flight replacements. I found nothing that blocks the merge. Two items are worth fixing before merge. Recovery stops a wedged sandbox without killing its container, and the fixed restart budget runs out on the deterministic poison samples described in #457. The rest are smaller.
What I ran. CI has not run on this PR. The workflows only trigger for PRs into main, and this one targets codex/lcb-command-isolation, so only GitGuardian reported. I ran the checks locally on 32e3316. ruff check and ruff format --check pass. ty check src/ reports only the unused type: ignore at executor.py:938, which comes from #470. The unit suite passes: 3384 passed, 35 skipped. I also reproduced the findings below with stub executors and a mocked SWE-ReX deployment.
How this fits with #469 and #470. The three PRs are a stack (#469 → #470 → #471), and each covers a different part of #457:
- #469 makes lost samples count as infrastructure failures, so the task is marked incomplete. That covers the silent-zero part.
- #470 runs long commands outside the SWE-ReX HTTP server and kills whole process groups. That targets the stall itself.
- #471 replaces quarantined slots. That covers "respawn quarantined sandboxes".
The diffs don't conflict. #470 touches executor.py, and this PR touches only manager.py. #469's edit to _execute_with_lease is already in this branch. There are two merge-order points:
- This PR targets
codex/lcb-command-isolation. Merging it as-is lands it on #470's branch, not onmain. Please merge #469, then #470, then this PR, retargeting each one tomainand rebasing after the previous squash merge. Then let CI run before merging. This PR has had no CI run so far. - #469's
depletedtest sets_MAX_SANDBOX_RESTARTSto 0 withraising=False. That constant exists only in this PR. The patch does nothing on #469 alone and disables recovery once this PR lands. It works in either order, but it is a hidden dependency between the two PRs.
Non-blocking
-
src/olmo_eval/harness/sandbox/manager.py:440(root cause insrc/olmo_eval/harness/sandbox/executor.py:449-464and SWE-ReXDockerDeployment.stop)
Recovery stops the old executor before starting the replacement. ButDockerDeployment.stop()first callsawait self._runtime.close(), an HTTP request to the SWE-ReX server. It only runspodman killafter that request succeeds. A quarantined sandbox is one whose server is not responding, soclose()raises.SandboxExecutor.stop()logs that at DEBUG and sets_deployment = None, and the container is never killed. I reproduced this with aDockerDeploymentwhoseruntime.closeraisesConnectionResetError:subprocess.check_callwas never called and_container_process.kill()was never called. Each recovery therefore leaves the wedged container running, along with whatever runaway process wedged it. That can be up to 8 containers with 4 slots and a budget of 2. #457 suggests the stall affects the shared host, so leftover wedged containers can make the replacements fail too. This is a deficiency in the existingexecutor.stop(), but this PR is the first code path that stops a wedged sandbox in the middle of a run and relies on it. CouldSandboxExecutor.stop()fall back to[container_runtime, "rm", "-f", container_name]with a timeout whendeployment.stop()raises in DOCKER mode? Please add a test that a failedruntime.close()still removes the container. -
src/olmo_eval/harness/sandbox/manager.py:24
The restart budget is fixed at 2 per slot for the whole run, and it never resets after successful work. Each wedging sample also costs two restarts, because failover sends it to a second slot. I reproduced this with 4 stub slots and a sample that quarantines whichever sandbox runs it. After 8 such samples, every one of the next 100 normal samples failed withSandboxInfrastructureError. At 6, all 100 succeeded. One LiveCodeBench problem at k=8 is 8 such samples, and #457 lists problems that recur (abc362_d, 3388). With #469 underneath, the run now fails loudly instead of scoring zeros. That is correct, but it means the run still does not finish. Could the per-slot count reset after a number of successful operations, or could the budget be aSandboxConfigfield? Please also run the CPU-only replay jobs from #457 (for example the E2 replay 01M4CSH1AN0HYGVYJ0YXD7NTYS) on the stacked branch. Post the count ofSandboxInfrastructureErrorsamples and the restarts used. That shows whether #470 prevents the wedge, and whether this budget ever runs out on real data. -
src/olmo_eval/harness/sandbox/manager.py:427
When a slot uses its last restart, or when a replacement fails to start, later samples fail with "No healthy sandbox remained ... recovery unavailable". Nothing in the logs says that the budget ran out. Could we log a warning once per slot when its budget is exhausted, naming the slot and the restarts used? When someone diagnoses a run like the ones in #457, that line answers the first question. -
tests/core/harness/test_sandbox_manager_capacity.py
Two of the behaviors described in the PR have no direct test.- Calling
stop()while a replacement is starting. I checked this with a gated start:stop()waits, the replacement ends up stopped, and the waiting lease gets "Sandbox manager is stopping". Please add a test that locks this in. - Stopping the old executor before the replacement starts.
RecoverableExecutor.stop()setsrunning = False, but no test asserts that it was called.
- Calling
Nits
- Nit:
src/olmo_eval/harness/sandbox/manager.py:402: thehas_executordocstring still says "a healthy, unbound executor". It now also counts slots that are being replaced or can still be replaced. - Nit:
src/olmo_eval/harness/sandbox/manager.py:434: a replacement of a replacement is namedsb-...-0-r1-r2. Deriving the name from the original slot name (...-0-r2) would read better in logs. - Nit:
src/olmo_eval/harness/sandbox/manager.py:412-428:_can_recoverand_schedule_recoveryhave no docstrings._schedule_recoveryhas five skip conditions, so one line on when it schedules would help.
Before merge
Nothing here blocks. I'd fix items 1 and 2 before merging, and post the replay numbers from item 2, since that is the evidence that the stack resolves #457. Then merge in order #469 → #470 → #471, retargeting this PR to main and rebasing after #470 lands. You may merge once CI passes on that rebased branch. If you keep the fixed budget for now, please open a follow-up issue named "make the sandbox restart budget configurable or reset after successful operations", and link the poison-sample numbers above.
Mark missing or exhausted sandbox scoring as infrastructure failure at both per-output and response-level catches. Preserve already-recorded verdicts and failure counts, and cover eight-sample LiveCodeBench responses.
3181c7d to
aac7036
Compare
32e3316 to
1778c7b
Compare
Run local sandbox commands independently of SWE-ReX HTTP and clean up their sessions on deadline or cancellation. Preserve raw argument sizes and image compatibility, never replay delivered commands, and verify behavior with real Docker regressions.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1778c7ba8e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
aac7036 to
e851ebc
Compare
1778c7b to
5292883
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 52928832f6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
f386dff to
538a586
Compare
Replace idle quarantined scoring executors with single-flight bounded recovery. Limit failover by slot and operation, preserve bound sessions, and clean up recovery workers during shutdown.
538a586 to
4fb6d30
Compare
Skip Podman stop grace during forced sandbox removal.
…b-command-isolation
…b-command-isolation
…b-command-isolation
…b-command-isolation
…b-sandbox-recovery
…b-sandbox-recovery
Codex · codex://threads/01a1326f-ed81-75e3-80e4-661392dbe4b5
Description
Replace quarantined sandbox slots with bounded, single-flight recovery. Preserve active leases and bound sessions; scoring and new bindings wait for active replacements, including the final permitted restart. Shutdown waits for replacement workers and stops old executors before starting replacements.
Persistent-session transport failures run health checks before release schedules recovery. Bounded deployment shutdown comes from drain-sandbox-container (#515), through parent isolate-sandbox-commands (#470).
Affected results
Task hashes and graders are unchanged. Preserve main's count-scoring-failures (#492) failure-budget policy, unconditional infrastructure errors and scoring timers.
Type of Change
Validation
Remaining work
Human review and parent merges. Two replacements per slot remain the bounded policy; configuration/reset behavior is a separate decision in make-sandbox-restart (#482). Related to livecodebench-stalled-execution (#457).