豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

feat: add BoxLite as a sandbox provider#2964

Open
DorianZheng wants to merge 1 commit intoopenai:mainfrom
DorianZheng:feat/boxlite-sandbox
Open

feat: add BoxLite as a sandbox provider#2964
DorianZheng wants to merge 1 commit intoopenai:mainfrom
DorianZheng:feat/boxlite-sandbox

Conversation

@DorianZheng
Copy link
Copy Markdown

Summary

  • Adds BoxliteSandboxClient / BoxliteSandboxClientOptions / BoxliteSandboxSession / BoxliteSandboxSessionState under src/agents/extensions/sandbox/boxlite/, backed by boxlite.SimpleBox (local-first micro-VM sandbox with hardware isolation — https://github.com/boxlite-ai/boxlite).
  • Wires the new backend into src/agents/extensions/sandbox/__init__.py with the standard optional-import guard (_HAS_BOXLITE) and conditional __all__ extension, matching the pattern used by the other cloud backends.
  • Declares the optional extra boxlite = ["boxlite>=0.8.2"] in pyproject.toml plus a mypy ignore_missing_imports override.
  • Implements the six required BaseSandboxSession overrides: _exec_internal via box.exec; read/write via base64-over-exec; persist_workspace/hydrate_workspace via tar-over-exec; running via box.info().state.

Test plan

  • make format
  • make lint
  • uv run mypy src/agents/extensions/sandbox/boxlite tests/extensions/test_sandbox_boxlite.py — clean
  • uv run pytest tests/extensions/test_sandbox_boxlite.py — 7/7 passing (options serialization, state round-trip via registry, create validation, exec translation, running probe, shutdown, base64 read)
  • Manual smoke test on a KVM/HVF host with pip install boxlite and a real python:slim box

Wire boxlite (https://github.com/boxlite-ai/boxlite) into the extension
sandbox registry as an optional provider. Adds BoxliteSandboxClient /
Options / Session / State backed by boxlite.SimpleBox, with exec, read,
write, persist_workspace, and hydrate_workspace implemented via the
existing exec + tar + base64 pattern used by the Vercel backend.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

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: 2418bc3a34

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

context={"backend": "boxlite", "box_id": self.state.box_id},
),
)
buf = await self.read(Path(archive_path))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Read snapshot archive without workspace path checks

persist_workspace() writes the tarball to /tmp and then calls self.read(Path(archive_path)), but read() enforces _validate_remote_path_access and rejects absolute paths outside manifest.root unless an explicit extra path grant exists. With the default /workspace root and no /tmp grant, persistence fails deterministically; hydrate_workspace() has the same issue via self.write(Path(archive_path), ...).

Useful? React with 👍 / 👎.

Comment on lines +267 to +271
box.exec(
normalized[0],
*normalized[1:],
cwd=self.state.manifest.root,
),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Propagate sandbox environment into command execution

BoxliteSandboxSession stores options.env in state, but _exec_internal() executes box.exec(...) with only argv and cwd and never merges either state.env or manifest.environment. This means user-configured environment variables are silently ignored in BoxLite sessions, so commands that depend on variables like API tokens or proxy settings will break.

Useful? React with 👍 / 👎.

Comment on lines +516 to +519
state.workspace_root_ready = False
inner = BoxliteSandboxSession.from_state(state)
await inner._ensure_box()
return self._wrap_session(inner, instrumentation=self._instrumentation)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reattach to existing BoxLite session on resume

resume() always clears workspace_root_ready and immediately starts a new SimpleBox path without using state.box_id (or any persisted reuse flag), so it cannot target the previously running sandbox identity. In resume flows without a restorable snapshot, this drops prior workspace state and can leave the original box orphaned.

Useful? React with 👍 / 👎.

@DorianZheng
Copy link
Copy Markdown
Author

@seratch Could you please take a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant