Skip to content

Isolate sandbox commands from the SWE-ReX server - #470

Merged
abhishekraok merged 28 commits into
mainfrom
codex/lcb-command-isolation
Oct 30, 2026
Merged

abhishekraok merged 28 commits into
mainfrom
codex/lcb-command-isolation

Conversation

@abhishekraok

@abhishekraok abhishekraok commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Codex · codex://threads/01a1326f-ed81-75e3-80e4-661392dbe4b5

Description

Execute supported Docker/Podman commands independently of SWE-ReX's blocking HTTP server so long-running programs cannot block file staging or health checks. A Linux child subreaper cleans descendants, including setsid/double-fork children; uncertain cleanup quarantines the slot. Kernels without proc-children files use parent-PID discovery through /proc/*/stat.

Stage source through bounded stdin writes and retain bounded output diagnostics. Unsupported images and custom shells retain the HTTP route tracked in remove-blocking-http (#483).

Based on drain-sandbox-container (#515). Recovery remains separate in recover-quarantined-sandbox (#471).

Affected results

Task hashes and graders are unchanged. Preserve main's count-scoring-failures (#492) failure-budget policy; infrastructure errors remain unscored and explicit.

Type of Change

  • Bug fix

Validation

  • Exact-head Python 3.12/3.13 CI at e1775a43, Ruff, formatting and source types.
  • Fourteen real Docker integration cases and 128 replay-verifier tests passed before the cleanup-only update; 21 focused adapter 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 merge. Retarget the recovery child before merging this PR. Related to livecodebench-stalled-execution (#457).

@abhishekraok
abhishekraok marked this pull request as ready for review October 13, 2026 23:13
@abhishekraok
abhishekraok requested a review from a team as a code owner October 13, 2026 23:13
@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:30:13.059849Z e3d93c9 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-scoring-failures branch from b6eeba4 to c75589a Compare October 13, 2026 23:16
@abhishekraok
abhishekraok force-pushed the codex/lcb-command-isolation branch from 335be85 to 9978dc6 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: 335be85953

ℹ️ 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-scoring-failures branch from c75589a to a62c4f1 Compare October 13, 2026 23:24
@abhishekraok
abhishekraok force-pushed the codex/lcb-command-isolation branch from 6f02cb5 to 880fbb5 Compare October 13, 2026 23:24

@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: 880fbb5724

ℹ️ 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 880fbb5 to 3181c7d Compare October 13, 2026 23:31

@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: 3181c7d864

ℹ️ 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".

@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! This fixes the root cause of the #457 cascade for Docker/Podman sandboxes. One failure-visibility issue should be fixed before merge, and I'd like two pieces of run evidence.

Root cause, confirmed. SWE-ReX's /execute route is an async def that calls blocking subprocess.run, so the server handles one request at a time. I started a local swerex.server and sent two concurrent sleep 2 commands plus a write_file 0.3s later. All three finished at 4.03s. RemoteRuntime._request posts with aiohttp's default ClientTimeout(total=300), and LCB's grader ceiling is 900s. So one long grade blocks every file write and is_alive on that sandbox for more than 5 minutes. That matches the issue's timeline: transport failures during file writes about 5 minutes after the stall, then failed health checks, then quarantine. Running commands through the container CLI removes that blocking. --kill-after is a reasonable extra guard.

Verification. ruff check, ruff format --check and ty check src/ are clean. The only ty diagnostic is the unused type: ignore on the swerex import, which is already on main. The unit suite passes (3368 passed, 35 skipped). I could not run the Docker integration tests here. CI has not run on this PR: it targets codex/lcb-scoring-failures, and ci.yml only triggers for PRs into main. Only GitGuardian reported. The description's "Full Python 3.12/3.13 CI passes" applies to #469, not to this branch.

Overlap with #469 and #471. No real conflict. #470 shares no files with #469. Its commit also applies cleanly to current origin/main without #469 (git merge-tree --merge-base=a62c4f10 origin/main review-pr-470 succeeds), so the stated dependency is a stacking choice. The two PRs work together: the SandboxTransportError this PR raises is a SandboxInfrastructureError, so #469's format_scoring_error counts it as infrastructure. #471 edits manager.py, which #469 also touches, so #471 needs #469 first. #471's slot replacement calls executor.start(), which now runs this PR's capability probe. Suggested order: merge #469, retarget #470 to main so full CI runs (and rebase if #469 is squash-merged, so a62c4f10 drops out of the diff), then #471.

Blocking

  1. src/olmo_eval/harness/sandbox/executor.py:622
    When the runtime CLI does not return by timeout + 10, the result is reported as an ordinary command timeout. The in-container timeout --kill-after=5s ends the command by timeout + 5, so reaching the client deadline means the runtime is wedged, or a detached process is holding the pipe open. I reproduced this by making _execute_stream_control raise TimeoutError for the setsid call and succeed for cleanup. execute_code("print(1)", timeout=3) returned ExecutionResult(success=False, error='timeout') and the sandbox stayed is_running. CodeExecutionScorer scores that as 0.0, and nothing marks it as infrastructure. That is the silent-zero class from #457 in a new place. LCB is unaffected because a missing verdict raises ScoringIncompleteError. On main the same wedge reached SandboxTransportError through the transport retries. Please treat a missed client deadline as an infrastructure failure: run _quarantine_if_unresponsive, then raise SandboxTransportError. Please also update test_local_deadline_kills_the_process_group and test_slow_cleanup_uses_health_checks_before_quarantine, which currently assert error == "timeout" for this path.
    except TimeoutError as exc:
        await self._quarantine_if_unresponsive(exc)
        raise SandboxTransportError(
            f"Container command did not return within {timeout + 10.0}s"
        ) from exc

Non-blocking

  1. Grading concurrency per sandbox changes, which can move scores.
    On main, the blocking /execute handler runs one command at a time in each sandbox. With this PR, each sandbox runs up to max_concurrency commands at once (default 4, so 16 graders across the codex_python pool). The LCB grader enforces per-test limits with ITIMER_REAL, which measures wall-clock time, so CPU contention can turn passes into Time Limit Exceeded. CodeExecutionScorer tasks behave the same way. This is probably fine on a large host, but it affects persisted results. Could you replay a saved k=1 LCB run (for example the outputs of 01M42X0PXJ5RWPH1QG9DQH8QSW) through main and this branch, and post pass@1 plus the count of TLE verdicts for each?

  2. Please confirm the fix against the issue's own reproduction.
    The PR tests real Docker, but the failing runs used Podman. The replay in #457 brings the cascade back deterministically on CPU-only jobs. Please rerun one of them (for example 01M4CSG2W9NBQAHDN006XNB1G2) on this branch with Podman. Post the SandboxRequiredError and transport-failure counts and the wall time.

  3. src/olmo_eval/harness/sandbox/executor.py:496
    execute_command and execute_code now kill every process left in the command's session when the command returns, including after success. Codex raised this (the comment on lines 639-640) and it has no reply yet. I found no in-repo caller that depends on background processes surviving. The diagnostics monitor uses _runtime.execute directly, and agent scaffolds use execute_in_session. Please reply on that thread, and state the new contract in both docstrings so the next caller knows about it.

  4. src/olmo_eval/harness/sandbox/executor.py:635
    The "timeout" label depends on exit code and elapsed time, and no unit test covers it. Please add a test where the command exits 124 before the deadline (no label) and one where it exits 124 or 137 after the deadline (labeled). Also, which case produces exit code 9? timeout reports a KILL as 137.

  5. src/olmo_eval/harness/sandbox/executor.py:526, :1026
    The local-route predicate is copied into execute_command and execute_code. mode == DOCKER and container_name also appears in start, _execute_stream_control and _quarantine_if_unresponsive. Could this be one _uses_container_cli property, so a future change to the route lands in one place?

  6. Follow-up issue for the remaining HTTP paths.
    Modal sandboxes, images without GNU setsid --wait and timeout --kill-after, and configs with exec_shell still send commands over HTTP, so they still serialize and can still cascade. The fallback only logs a warning. execute_in_session has the same problem: SWE-ReX's session runner calls blocking pexpect.expect inside an async def. Please file an issue that names these paths and link it here.

Nits

  • Nit: _execute_stream_control's docstring still says "short streaming-control command", but it now carries full commands up to the caller's timeout. The class docstring ("via SWE-ReX") is also no longer accurate for Docker mode.
  • Nit: the PID file is named _sandbox_pgid_*, but it records the session leader's stat line. _sandbox_session_* would match what cleanup reads.

Before merge

Please fix the blocking item and its tests, and post the two replays from Non-blocking 1 and 2. Then merge #469, retarget this PR to main, and let full CI run. You may merge once CI is green. Please file the follow-up issue from item 6 and link it here.

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-scoring-failures branch from a62c4f1 to 16f9e73 Compare October 15, 2026 19:34
@abhishekraok
abhishekraok force-pushed the codex/lcb-command-isolation branch from 3181c7d to aac7036 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.
@abhishekraok

Copy link
Copy Markdown
Collaborator Author

Codex · codex://threads/01a1326f-ed81-75e3-80e4-661392dbe4b5

The reviewed code findings are fixed, with regression tests and independent review. Five real Docker tests pass, including normal background-process lifetime; a controlled setsid/timeout command also confirms signal exit status 9. The original saved-output Podman bundle and replay spec are reachable and were inspected, but the full replay and paired k=1 pass/TLE comparison have not been run in this update. Those validation requests remain explicitly pending before this PR merges. Current Python CI is linked in the PR description.

@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: 94074a78b0

ℹ️ 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".

Verify command-session cleanup before returning sandbox capacity

@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: 7b7b076dc3

ℹ️ 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".

Bound local sandbox output capture while preserving completion markers
@gregorybchris

Copy link
Copy Markdown
Collaborator

Written by Claude Code for @gregorybchris.

Current state, now that #492 is merged (d60f81f) and #469 is superseded:

@abhishekraok
abhishekraok changed the base branch from codex/lcb-scoring-failures to main October 27, 2026 22:40
@abhishekraok

Copy link
Copy Markdown
Collaborator Author

Codex · codex://threads/01a1326f-ed81-75e3-80e4-661392dbe4b5

Resolved against current main at f23bc99: the PR now targets main and its diff excludes the superseded scoring-gate changes. Main's failure-budget files are preserved. The recovery stack passes 4,498 unit tests and ten Docker regressions; independent review found no blockers.

The earlier smoke used HTTP fallback, so it is not isolation evidence. A strict diagnostic now checks the actual local path and saved-output identity: https://beaker.org/ex/01M5ZSPJ52VHTK7E9691YMB3RZ

@abhishekraok

Copy link
Copy Markdown
Collaborator Author

Codex · codex://threads/01a1326f-ed81-75e3-80e4-661392dbe4b5

The strict diagnostic identified the target incompatibility: Neptune lacks /proc/.../children; the other capability predicates passed. Fixed in bbd13ed, propagated into the recovery stack at 9706e61. Child discovery falls back to /proc/*/stat, retaining bounded cleanup, subreaping, ownership checks and the kernel's no-children proof.

Both exact-head CI runs pass. The full stack has 4,504 unit tests and twelve real Docker regressions passing, including timeout/cancel with the children file absent; the timeout regression fails on the old supervisor. Independent review found no blockers.

The strict Podman smoke now passes the strict gate: four local-ready executor attempts, two actual grader results, exact source provenance, and trusted saved-input checksum. This replaces the earlier HTTP-fallback receipt. Full saved-output comparisons are running: baseline k=1, stack k=1, and stack k=8. Their results remain pending before merge; no new inference or upload is involved.

@abhishekraok
abhishekraok changed the base branch from main to codex/drain-sandbox-logs October 28, 2026 00:43
@abhishekraok
abhishekraok changed the base branch from codex/drain-sandbox-logs to main October 30, 2026 21:20
@abhishekraok
abhishekraok merged commit aef5539 into main Oct 30, 2026
8 checks passed
@abhishekraok
abhishekraok deleted the codex/lcb-command-isolation branch October 30, 2026 21:31
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