Repository navigation
fix(sandbox): support LAB harness sessions across sandbox providers - #5792
rystewart-nvidia wants to merge 16 commits into
Conversation
2374c94 to
f207071
Compare
f207071 to
0e6acc1
Compare
|
Some points on the provider changes, since these are shared by other benchmarks:
|
7e74e18 to
e20a872
Compare
|
@cmunley1 Thanks, I’ve addressed each of these and added tests. Also ran the SWE-bench Pro, DeepSWE, JobBench, and Terminal Bench 4 tests to check for effects on other users and confirmed they all pass |
e20a872 to
6648fb2
Compare
hemildesai
left a comment
There was a problem hiding this comment.
SHIP WITH CARE (sandbox provider changes)
Thanks. The provider work is careful, and all of cmunley1's points are fixed in the code: descriptors no longer carry env, a borrowed ECS close()/disconnect_handle only detaches, the tunnel reconnects on the same port, math.ceil is applied to disk_gib, and fchmod only runs on directories this user owns. On every path I traced the owner keeps control of the lifecycle. A borrower's disconnect() never reaches stop_task, enroot remove or an OpenShell delete, and the OpenShell orphan reap is keyed per process, so a borrower's aclose() can't reap the owner's sandboxes.
- Scope: this head also carries #5787 (legal-agent-bench layout) and #5790 (deferred dataset paths). As asked, I reviewed only the
nemo_gym/sandbox/*changes and their tests. - RISK — ECS borrowing on real AWS. The PR body says real AWS provisioning and SSH networking are unverified, and recovery from a dropped tunnel only works if the owner itself execs (inline). Could you run one real Fargate smoke (owner seed, then a borrowed harness exec, disconnect, owner verify), or mark ECS borrowing experimental until then?
- NOTE:
make_writablerecursion can break cleanup on a deep agent-written tree (inline, reproduced locally). - NOTE/question: ECS
connect()doesn't check which task answers on the port, unlike Enroot and OpenShell (inline).
The main CI hasn't run yet; copy-pr-bot is waiting on /ok to test.
hemildesai
left a comment
There was a problem hiding this comment.
Thanks for the quick turnaround. All three of my points are addressed in 3629a50 / 22f9a49 / d0cc617, and I've resolved those threads. Locally the changed sandbox tests pass (296 passed, 1 skipped).
Before I approve, the required Unit tests / Sandbox tests job is red on d0cc617 with one failure introduced by the rmtree-first change:
FAILED tests/unit_tests/test_sandbox_provider_utils.py::test_cleanup_root_replacement_after_open_cannot_redirect_chmod - Failed: DID NOT RAISE <class 'OSError'>
CI appears to run with privileges that let shutil.rmtree delete the 0o555 tree on the first try. So the chmod pass (and the racing fchmod) never runs. The other race tests already opt into require_permission_repair; this one just needs the same fixture (inline).
FYI: secrets-detector failed with a detect-secrets-hook usage error rather than an actual finding, so a re-run may be enough there.
Once Sandbox tests are green I'm happy to approve the sandbox-provider part. As before, I've only reviewed the nemo_gym/sandbox/* changes here, not the #5787/#5790 content carried on this branch.
Signed-off-by: Ryan Stewart <[email protected]>
Signed-off-by: Ryan Stewart <[email protected]>
Signed-off-by: Ryan Stewart <[email protected]>
hemildesai
left a comment
There was a problem hiding this comment.
LGTM on the sandbox provider changes. Thanks for the fast turnaround.
- 21af99c adds
require_permission_repairto the root-replacement race test, and CI is now fully green, including Sandbox tests. - The rebase onto main left the sandbox commits unchanged (checked with range-diff).
- All my earlier threads are resolved: deep-tree cleanup, the per-sandbox ECS identity check, and Fargate borrowing documented as experimental.
Scope note: I reviewed the nemo_gym/sandbox/* changes and their tests, as asked. The dataset-path commit (9abfeed, #5790) is outside what I looked at.
Signed-off-by: Ryan Stewart <[email protected]>
Signed-off-by: Ryan Stewart <[email protected]>
Signed-off-by: Ryan Stewart <[email protected]>
Signed-off-by: Ryan Stewart <[email protected]>
Signed-off-by: Ryan Stewart <[email protected]>
Signed-off-by: Ryan Stewart <[email protected]>
|
/ok to test 6d8a7e7 |
Signed-off-by: Ryan Stewart <[email protected]>
Signed-off-by: Ryan Stewart <[email protected]>
Signed-off-by: Ryan Stewart <[email protected]>
|
/ok to test ce3cfa0 |
hemildesai
left a comment
There was a problem hiding this comment.
Re-approving at ce3cfa0 after the merges from main dismissed my approval. The conflict resolution drops this PR's Enroot serialize/connect in favour of #6105's version now on main, and the remaining sandbox changes are the ones I reviewed. Required CI is green (a re-run cleared an unrelated flaky openclaw_agent test). As before, my review covers the nemo_gym/sandbox/* changes.
|
superseded by changes merged in #5791, closing |
What does this PR do?
Let agents use Enroot, ECS Fargate, and OpenShell sandboxes created by the Harbor Environment Server. When an agent disconnects, the sandbox stays running until the environment server finishes the task and deletes it.
--rc /dev/nullwith a script that runs Gym’s command when bypassing the image’s entrypoint.Builds on #5790 and will be rebased after 5790 merges. LAB's Environment Server integration is separate in #5788.
Validation
Run filesystem cleanup tests as a non-root user so root permissions do not hide failures.
All selected provider and connection tests passed, including ownership, descriptor validation, cleanup, and SSH reconnect checks. SWE-bench Pro, DeepSWE, JobBench, and Terminal Bench 4 regression suites also passed. All-files pre-commit and import checks passed.
uv sync --locked --project environment_servers/harbor source environment_servers/harbor/.venv/bin/activate uv pip install openshell==0.1.6 PYTHONPATH=. LITELLM_LOCAL_MODEL_COST_MAP=True uv run --active --no-sync python -m pytest \ tests/unit_tests/test_sandbox_provider_utils.py \ tests/unit_tests/sandbox/test_apptainer_provider.py \ tests/unit_tests/sandbox/test_ecs_fargate_engine.py \ tests/unit_tests/sandbox/test_ecs_fargate_provider.py \ tests/unit_tests/sandbox/test_enroot_provider.py \ tests/unit_tests/sandbox/test_openshell_provider.py \ tests/unit_tests/sandbox/test_sandbox_connect.py --import-mode=importlib -qLITELLM_LOCAL_MODEL_COST_MAP=Trueavoids downloading model prices during imports;--active --no-syncuses the activated environment.Rollouts
LocalEmu checks passed for ECS resource settings, S3 transfer and cleanup, separate borrowers sharing a provider, owner survival after disconnect, and teardown. Real AWS provisioning and SSH networking remain unverified; LocalEmu checks used a local exec server. Enroot and OpenShell also passed live checks for borrowed execution, environment inheritance, owner survival after disconnect, isolated output transfer, and teardown.
Reproduce the ownership check
Run from the repository root with the Gym
uvenvironment activated. The default example uses Docker; other backends need their own runtime or service. No model endpoint is needed. The script reads a file through a second connection, disconnects it, and checks that the owner can still read the file before cleanup.For Enroot, use the tested image-preparation and
/sandboxexample below.For other providers, set
LAB_SANDBOX_CONFIGto their configuredsandboxYAML,LAB_SANDBOX_IMAGEto a compatible image, andLAB_SANDBOX_WORKDIRto a writable directory.Reproduce the Enroot startup fix
Use a Linux host with working rootless Enroot and the activated Gym environment. Docker is needed only to build the test image and import it from the local Docker daemon. Once the
.sqshfile exists, running the Enroot sandbox does not require Docker; you can also prepare that file on another host. Createlifecycle.pyabove first, then setSANDBOX_REPRO_DIRto a writable scratch directory. No GPU or model endpoint is needed.Both
PASSchecks succeeded with this Python image as a non-root user. Without bypass, the same image exited with code 73 as intended. Docker was shut down before the Enroot run, and sandbox cleanup completed.Compatibility and benchmark impact
Existing provider APIs remain available. A borrower no longer needs to own the sandbox or close a provider shared by other connections. The cleanup helper is used only by Enroot and Apptainer; the other providers keep their cleanup paths.
Backend prerequisites still apply: local providers need the same host and user; Fargate borrowing requires exec-server mode and an active owner SSH forward.
Checklist
pre-commit run --all-files) (so CI lint/format checks pass).git commit -s) (so the DCO check passes).