Skip to content

Recover quarantined sandbox slots with bounded retries - #471

Merged
abhishekraok merged 46 commits into
mainfrom
codex/lcb-sandbox-recovery
Oct 30, 2026
Merged

abhishekraok merged 46 commits into
mainfrom
codex/lcb-sandbox-recovery

Conversation

@abhishekraok

@abhishekraok abhishekraok commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

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

  • Bug fix

Validation

  • Exact-head Python 3.12/3.13 CI at bb6d667c, Ruff, formatting and source types.
  • Fourteen real Docker integration cases and 128 replay-verifier tests passed before the cleanup-only update; 51 owned-deployment/manager cases pass after integration. Independent source review found no blockers.
  • Full saved-output grading at 679ae849: all 612 k=1 inputs match baseline; all 4,896 k=8 outputs accounted for, including 4,480 actual grades and 416 no-code responses, with zero scoring errors or replacements.
  • The later cleanup-only target probe at inherited 4181e5b1 independently confirms all four Podman/alias containers removed and attached clients/capture threads reaped. No new inference or upload.

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).

@abhishekraok
abhishekraok marked this pull request as ready for review October 13, 2026 23:14
@abhishekraok
abhishekraok requested a review from a team as a code owner October 13, 2026 23:14
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T21:34:37.126822Z 8162a2a New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@abhishekraok
abhishekraok force-pushed the codex/lcb-command-isolation branch from 335be85 to 9978dc6 Compare October 13, 2026 23:16
@abhishekraok
abhishekraok force-pushed the codex/lcb-sandbox-recovery branch from 21bf160 to 0a96cb5 Compare October 13, 2026 23:16

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

@abhishekraok
abhishekraok force-pushed the codex/lcb-command-isolation branch from 9978dc6 to 6f02cb5 Compare October 13, 2026 23:20
@abhishekraok
abhishekraok force-pushed the codex/lcb-sandbox-recovery branch from 0a96cb5 to 0685fb1 Compare October 13, 2026 23:20

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

@abhishekraok
abhishekraok force-pushed the codex/lcb-command-isolation branch from 6f02cb5 to 880fbb5 Compare October 13, 2026 23:24
@abhishekraok
abhishekraok force-pushed the codex/lcb-sandbox-recovery branch 2 times, most recently from ed55780 to 1ef06cb Compare October 13, 2026 23:28
@abhishekraok
abhishekraok force-pushed the codex/lcb-command-isolation branch from 880fbb5 to 3181c7d Compare October 13, 2026 23:31
@abhishekraok
abhishekraok force-pushed the codex/lcb-sandbox-recovery branch from 1ef06cb to 32e3316 Compare October 13, 2026 23:31

@gregorybchris gregorybchris left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 on main. Please merge #469, then #470, then this PR, retargeting each one to main and rebasing after the previous squash merge. Then let CI run before merging. This PR has had no CI run so far.
  • #469's depleted test sets _MAX_SANDBOX_RESTARTS to 0 with raising=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

  1. src/olmo_eval/harness/sandbox/manager.py:440 (root cause in src/olmo_eval/harness/sandbox/executor.py:449-464 and SWE-ReX DockerDeployment.stop)
    Recovery stops the old executor before starting the replacement. But DockerDeployment.stop() first calls await self._runtime.close(), an HTTP request to the SWE-ReX server. It only runs podman kill after that request succeeds. A quarantined sandbox is one whose server is not responding, so close() raises. SandboxExecutor.stop() logs that at DEBUG and sets _deployment = None, and the container is never killed. I reproduced this with a DockerDeployment whose runtime.close raises ConnectionResetError: subprocess.check_call was 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 existing executor.stop(), but this PR is the first code path that stops a wedged sandbox in the middle of a run and relies on it. Could SandboxExecutor.stop() fall back to [container_runtime, "rm", "-f", container_name] with a timeout when deployment.stop() raises in DOCKER mode? Please add a test that a failed runtime.close() still removes the container.

  2. 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 with SandboxInfrastructureError. 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 a SandboxConfig field? Please also run the CPU-only replay jobs from #457 (for example the E2 replay 01M4CSH1AN0HYGVYJ0YXD7NTYS) on the stacked branch. Post the count of SandboxInfrastructureError samples and the restarts used. That shows whether #470 prevents the wedge, and whether this budget ever runs out on real data.

  3. 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.

  4. 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() sets running = False, but no test asserts that it was called.

Nits

  • Nit: src/olmo_eval/harness/sandbox/manager.py:402: the has_executor docstring 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 named sb-...-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_recover and _schedule_recovery have no docstrings. _schedule_recovery has 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.
@abhishekraok
abhishekraok force-pushed the codex/lcb-command-isolation branch from 3181c7d to aac7036 Compare October 15, 2026 19:34
@abhishekraok
abhishekraok force-pushed the codex/lcb-sandbox-recovery branch from 32e3316 to 1778c7b Compare October 15, 2026 19:34
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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

@abhishekraok
abhishekraok force-pushed the codex/lcb-sandbox-recovery branch 2 times, most recently from f386dff to 538a586 Compare October 15, 2026 19:49
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.
@abhishekraok
abhishekraok force-pushed the codex/lcb-sandbox-recovery branch from 538a586 to 4fb6d30 Compare October 15, 2026 19:52
@abhishekraok
abhishekraok changed the base branch from codex/lcb-command-isolation to main October 30, 2026 21:31
@abhishekraok
abhishekraok merged commit cabbf14 into main Oct 30, 2026
8 checks passed
@abhishekraok
abhishekraok deleted the codex/lcb-sandbox-recovery branch October 30, 2026 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants