Move the shared sandbox layer to openenv.core.sandbox - #1022
Move the shared sandbox layer to openenv.core.sandbox#1022sergiopaniego wants to merge 3 commits into
Conversation
The sandbox protocol (SandboxBackend/SandboxHandle/BgJob/ExecResult), the E2B and Hugging Face backends, the interception proxy, and build_template move from envs/opencode_env/sandbox/ to src/openenv/core/sandbox/, so environments import them from core rather than from opencode_env. opencode_env now imports from openenv.core.sandbox. interception.py is no longer baked into the opencode pre-baked image (the harness uploads it at rollout start from core), and the opencode hf_image dir moves out of sandbox/ to opencode_env/hf_image/. e2b stays a lazy import so core keeps no hard e2b dependency. No backward-compat shim, opencode_env is experimental. AI-assisted.
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
The sandbox module moved to openenv.core, so the relative-import fallback must keep importing the backend from the installed package, not the removed local sandbox module.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit f363315. Configure here.
| from config import OpenCodeConfig # type: ignore | ||
| from harness import OpenCodeSessionFactory # type: ignore | ||
| from sandbox import E2BSandboxBackend # type: ignore | ||
| from openenv.core.sandbox import E2BSandboxBackend |
There was a problem hiding this comment.
Docker builds lose sandbox module
High Severity
Sandbox code was removed from the env package and both import paths now load E2BSandboxBackend from openenv.core.sandbox, but the env still depends on openenv>=0.3.0 with a frozen lock on 0.3.1. CI Docker builds use only the env context plus that lock, so the published image no longer contains the sandbox layer and rollouts fail on import.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit f363315. Configure here.


What does this PR do?
Moves the shared sandbox layer (the
SandboxBackend/SandboxHandle/BgJob/ExecResultprotocols, the E2B and Hugging Face backends, the interception proxy, andbuild_template) fromenvs/opencode_env/sandbox/tosrc/openenv/core/sandbox/, so environments import it from core instead of one env peer-depending on another.opencode_envnow imports fromopenenv.core.sandbox,interception.pyis uploaded at rollout start from core (no longer baked into the opencode image), and the opencodehf_imagedir moves toopencode_env/hf_image/.e2bstays a lazy import so core keeps no harde2bdependency.This is the standalone version of #1010 (which was stacked on #999), rebuilt on current main so it can land on its own. #1010 will be closed in favor of this.
AI-assisted.
Note
Medium Risk
Touches sandbox rollout bootstrap (proxy staging and HF image contents) and breaks any external imports of
opencode_env.sandbox; core lazye2b/HF imports preserve optional deps but behavior changes need validation in real rollouts.Overview
Moves the shared sandbox stack (protocols, E2B/HF backends,
interception.py,build_template.py) fromenvs/opencode_env/sandbox/intosrc/openenv/core/sandbox/, so harness environments depend on core instead of env-local code.opencode_envis updated to importE2BSandboxBackend,HFSandboxBackend, and related types fromopenenv.core.sandbox;pyproject.tomldrops theopencode_env.sandboxpackage mapping. The harness now resolves the proxy source fromopenenv.core.sandbox/interception.pyand uploads it at rollout start when it is not already in the image.HF pre-baked image layout changes: CI and docs point at
envs/opencode_env/hf_image/Dockerfile(wassandbox/hf_image/). The image no longer bakes ininterception.py—only opencode + proxy Python deps and directory layout—matching the harness upload behavior.Docs and tests switch import paths and document
src/openenv/core/sandbox/build_template.pyfor the E2B template builder.Reviewed by Cursor Bugbot for commit f363315. Bugbot is set up for automated code reviews on this repo. Configure here.