Repository navigation
Conversation
opencode_sandboxed_agent installs OpenCode by downloading it from opencode.ai inside the sandbox unless a binary is mounted or preinstalled. A sandbox without internet access, such as the SWE agent sandbox with its egress blocked, then fails at setup. local_opencode_binary_path and local_opencode_binary_sha256 upload a host-local executable instead, the way local_ripgrep_binary_path uploads rg. The digest is checked at startup, and the sandbox installs the uploaded copy only if its SHA-256 matches and it answers --version, using opencode_agent's staging script. The ripgrep upload helper now stages either binary, with the same retry and concurrency bound. Signed-off-by: Ananth Subramaniam <[email protected]>
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
On the local and Apptainer providers an absolute /tmp upload lands in the host's /tmp, and closing the sandbox does not remove it, so every rollout left its OpenCode binary (about 167 MB) and its ripgrep copy behind. Setup now removes each upload once it is staged, whatever the outcome, and keeps the staging status. A removal that fails, as for a root-owned upload in a sticky /tmp, is ignored. The OpenCode staging copy gets a unique name, since rollouts may share $HOME on those providers. The config also refuses the musl binary and the install script paths next to a local binary, which would otherwise be ignored, and the README says the uploaded binary serves one C library. Signed-off-by: Ananth Subramaniam <[email protected]>
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP WITH CARE
I completed the source review of all three changed files and their affected installation and cleanup paths. I did not execute tests or verify current CI results.
RISK: Supply the required real smoke-rollout evidence
The PR's rollout-evidence section still says “Pending.” The new installation test uses a shell-script executable and a mocked sandbox. It does not validate the real OpenCode runtime, provider upload, model connection or verifier in the intended egress-blocked deployment. This is missing validation, not a demonstrated runtime failure. AGENTS.md requires representative real model rollouts for behavior-changing agent work.
Could you run the planned smoke on the final head and attach its command, effective configuration, binary version/digest and rollout artifacts, including the inspected agent/verifier outcome? Acceptance is installation through the new local-binary fields without downloading OpenCode, a real model/tool interaction, a captured trajectory and completed verification with sandbox egress blocked. Include the upload timing at the tested concurrency as planned. Supplying that evidence is the correction; no implementation rewrite is requested.
Keep the existing digest/conflict validation and the default installation behavior when neither new field is configured. Retain the successful-install and altered-upload assertions alongside the real smoke.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
| install_str = ":" | ||
| if not self.config.preinstalled_opencode: | ||
| if self.config.local_opencode_binary_path is not None: | ||
| opencode_remote_path = await self._stage_binary( |
There was a problem hiding this comment.
RISK: Clean up the completed OpenCode upload when later preparation fails.
After this upload succeeds, configuration creation and the remaining uploads can still raise before the setup shell runs. For a minimal trigger, configure a valid pinned local binary and opencode_plugins=["missing.js"]: _plugin_uploads raises during configuration creation, so the removal embedded in install_str never executes. The local provider writes the absolute path into host /tmp, while stop() deletes only its workspace. Each failed rollout therefore leaves another full OpenCode executable behind, rather than removing the completed upload where permitted.
Could you give the completed OpenCode upload cleanup ownership inside responses, with bounded, cancellation-safe best-effort removal on preparation failures before caller teardown? Fixing only _run would miss the inherited VibenchAgent.run caller. Keep the original preparation exception, never remove the installed executable, and continue tolerating permission-denied removal. Do not delete an ambiguous timeout path while its upload may still be writing. The exact cancellation-safe implementation needs verification against the provider contracts, so I am not proposing replacement code.
Proposed regression: after a successful local OpenCode upload, trigger the missing-plugin error and assert that its removable upload is absent after /run fails, the original error propagates, no agent or verifier starts, and the sandbox is stopped. Also cover cancellation after a completed upload and failure while staging optional ripgrep. Retain successful installation, SHA-256 rejection, read-only-upload tolerance and fresh-path retry behavior.
| upload_dir.chmod(0o755) | ||
| assert completed.returncode == 0, completed.stderr | ||
| # A read-only upload cannot be removed, and that does not fail setup. | ||
| assert uploaded.is_file() |
There was a problem hiding this comment.
RISK: Allow successful cleanup when this test runs as root.
With ordinary root DAC-override capability, the generated rm -f removes uploaded despite the directory's 0555 mode. This new assertion then fails, and the following uploaded.read_bytes() cannot succeed. The cleanup is correct; directory permissions do not make the fixture undeletable for root. This affects the stage_ripgrep=True cases, including execution in the Gym image, which defaults to root.
Replace the existence assertion and chained byte comparison with:
installed = bin_dir / "rg"
assert installed.read_bytes() == binary.read_bytes()Keep the mode, owner and agent-start assertions. Before changing opencode to report wrong-version, recreate the upload if the first launch removed it:
if not uploaded.is_file():
shutil.copyfile(binary, uploaded)That keeps the second launch testing version rejection rather than failing because its upload is missing. Retain its assertions that the agent never starts and the now-removable upload disappears.
Proposed acceptance: run the stage_ripgrep=True cases as both an ordinary user and root. Both must install identical 0755 bytes and start the first invocation; the second invocation must reach the version check, reject wrong-version, remove the upload and not start the agent. This failure is source-derived, not an executed result.
|
|
||
| removable = run_launch_command(binary.read_bytes(), tmp_path / "removable", read_only=False) | ||
| assert removable.returncode == 0, removable.stderr | ||
| assert not (tmp_path / "removable/uploads/opencode").exists() |
There was a problem hiding this comment.
NOTE, suggested test correction: make these assertions inspect the real filesystem.
This test calls _mock_sandbox, which replaces Path.exists globally with a function returning False. Both removable-upload assertions therefore pass even if the local OpenCode branch stops removing uploads. The tampered-install absence assertion at line 929 is ineffective for the same reason.
For these regular-file fixtures, replace .exists() with .is_file() in the assertions at lines 929, 934 and 940. For example:
assert not (tmp_path / "removable/uploads/opencode").is_file()This keeps the sandbox mock intact while restoring the filesystem checks. Retain the installed-byte/mode assertions, SHA-256 mismatch diagnostic and agent-start marker checks.
Proposed acceptance: temporarily bypass _then_remove_upload only in the local OpenCode installation branch. The removable-upload assertion must then fail because the file is still present. Restore the wrapper and require both valid and altered removable uploads to disappear, while altered bytes still fail without installing or starting OpenCode. I did not execute this mutation.
What changed
opencode_sandboxed_agentgets two config fields,local_opencode_binary_pathandlocal_opencode_binary_sha256. Together they upload an OpenCode executable from the agent-server host into each sandbox, so the agent doesn't download OpenCode there.local_opencode_binary_sha256. It refuses one field without the other. It also refuses the upload together with anyremote_opencode_*path orpreinstalled_opencode, which the upload would otherwise silently override./tmp/nemo-gym-opencode-binary-*path before the launch command runs. A timed-out upload is retried at a new path.opencode_agent's staging script (STAGE_EXECUTABLEinresponses_api_agents/opencode_agent/pinned.py). It copies the upload, keeps the copy only if its SHA-256 matches, checks that it answers--version, and then installs it as$HOME/.opencode/bin/opencode. The staging copy has a unique name, because rollouts may share$HOMEon the local and Apptainer providers. The existing check that the installed version equalsopencode_versionstill runs after that._stage_ripgrepbecame_stage_binary). The ripgrep log lines and failure reasons read as before./tmpupload lands in the host's/tmp, and closing the sandbox doesn't remove it, so each rollout used to leave its copies behind (about 167 MB for OpenCode 1.17.11). A removal that fails is ignored: a non-root user can't remove a root-owned upload in a sticky/tmp.Why
Without a mounted binary or
preinstalled_opencode, the agent runscurl https://opencode.ai/installinside the sandbox. A sandbox without internet access fails at that step, before the model is ever called. One example is the SWE agent sandbox with egress blocked (#6177). The recipes that already run without network mount OpenCode from deployment storage, but an OpenSandbox deployment with no such mount had no way to get the binary in. Checking the digest in the sandbox, not only on the host, catches a truncated or altered upload.No issue: this unblocks the OpenCode rollout with egress blocked for #6177.
Compatibility
Both fields default to
null, so existing configs behave as before.opencode_sandboxed_agentis deprecated. This option supports the setups the deprecation notice still sends here: SWE resources servers that return only asandbox_handle.Validation
pytest responses_api_agents/opencode_sandboxed_agent/tests/(the worktree venv, withPYTHONPATHset to the checkout): all pass.opencode_agent.pinned, which uses only the standard library.pre-commit runon the changed files passes.Rollout evidence
Pending. The first real run will be the OpenCode smoke for #6177 with egress blocked, on a Slurm CPU node against OpenSandbox. Its results will be added here, including the logged upload duration and queue time at the run's concurrency.