Skip to content

Move the shared sandbox layer to openenv.core.sandbox - #1022

Open
sergiopaniego wants to merge 3 commits into
huggingface:mainfrom
sergiopaniego:move-sandbox-to-core
Open

Move the shared sandbox layer to openenv.core.sandbox#1022
sergiopaniego wants to merge 3 commits into
huggingface:mainfrom
sergiopaniego:move-sandbox-to-core

Conversation

@sergiopaniego

@sergiopaniego sergiopaniego commented Jul 30, 2026

Copy link
Copy Markdown
Member

What does this PR do?

Moves the shared sandbox layer (the SandboxBackend / SandboxHandle / BgJob / ExecResult protocols, the E2B and Hugging Face backends, the interception proxy, and build_template) from envs/opencode_env/sandbox/ to src/openenv/core/sandbox/, so environments import it from core instead of one env peer-depending on another.

opencode_env now imports from openenv.core.sandbox, interception.py is uploaded at rollout start from core (no longer baked into the opencode image), and the opencode hf_image dir moves to opencode_env/hf_image/. e2b stays a lazy import so core keeps no hard e2b dependency.

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 lazy e2b/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) from envs/opencode_env/sandbox/ into src/openenv/core/sandbox/, so harness environments depend on core instead of env-local code.

opencode_env is updated to import E2BSandboxBackend, HFSandboxBackend, and related types from openenv.core.sandbox; pyproject.toml drops the opencode_env.sandbox package mapping. The harness now resolves the proxy source from openenv.core.sandbox/interception.py and 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 (was sandbox/hf_image/). The image no longer bakes in interception.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.py for the E2B template builder.

Reviewed by Cursor Bugbot for commit f363315. Bugbot is set up for automated code reviews on this repo. Configure here.

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.
Copilot AI review requested due to automatic review settings July 30, 2026 08:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Comment thread envs/opencode_env/server/opencode_environment.py
Comment thread envs/opencode_env/__init__.py
@bot-ci-comment

Copy link
Copy Markdown

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.
Copilot AI review requested due to automatic review settings July 30, 2026 11:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings July 31, 2026 07:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f363315. Configure here.

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