feat: add OpenSandbox as secure code execution backend#1710
Open
hellomypastor wants to merge 1 commit intoopeninterpreter:mainfrom
Open
feat: add OpenSandbox as secure code execution backend#1710hellomypastor wants to merge 1 commit intoopeninterpreter:mainfrom
hellomypastor wants to merge 1 commit intoopeninterpreter:mainfrom
Conversation
Integrate OpenSandbox SDK as an optional execution backend so that Python, Shell and JavaScript code can run in isolated containers instead of directly on the host machine. Enabled via --sandbox flag or interpreter.sandbox_mode = True. New files: - SandboxManager: owns sandbox lifecycle, streaming execution, contexts - SandboxLanguage base + SandboxPython/Shell/JavaScript subclasses Modified: - Terminal: conditionally routes to sandbox language handlers - OpenInterpreter: sandbox_mode, sandbox_api_key, sandbox_domain config - CLI: --sandbox, --sandbox_api_key, --sandbox_domain arguments - pyproject.toml: opensandbox optional dependency group Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe the changes you have made:
Integrate [OpenSandbox](https://github.com/alibaba/OpenSandbox) as an optional secure code execution backend. When enabled, Python, Shell, and JavaScript code runs inside isolated containers instead of directly on the host machine.
New files:
interpreter/core/computer/terminal/languages/sandbox/sandbox_manager.py— Manages OpenSandbox lifecycle: lazy sandbox creation, per-language execution contexts, streaming output via queue-based generator (mirrorsSubprocessLanguagepattern), interrupt support, and cleanup.interpreter/core/computer/terminal/languages/sandbox/sandbox_language.py—SandboxLanguagebase class extendingBaseLanguage, delegates execution to the sharedSandboxManager.interpreter/core/computer/terminal/languages/sandbox/__init__.py— Concrete subclasses:SandboxPython,SandboxShell,SandboxJavaScript.Modified files:
terminal.py— Conditionally swapsPython/Shell/JavaScripthandlers with sandbox variants whensandbox_mode=True; adds sandbox-aware instantiation in_streaming_run; skips localimport_computer_apiin sandbox mode; callssandbox_manager.terminate()on cleanup.core.py— Addssandbox_mode,sandbox_api_key,sandbox_domainconstructor parameters.start_terminal_interface.py— Adds--sandbox,--sandbox_api_key,--sandbox_domainCLI arguments.pyproject.toml— Addsopensandbox+opensandbox-code-interpreteras optional[sandbox]extras.Usage:
Design decisions:
sandbox_modedefaults toFalse, zero impact on existing behavior.SandboxManagerowns one sandbox container; multiple languages share it via separate execution contexts, minimizing resource overhead.ImportErrormessage.Reference any relevant issues (e.g. "Fixes #000"):
N/A
Pre-Submission Checklist (optional but appreciated):
docs/CONTRIBUTING.mddocs/ROADMAP.mdOS Tests (optional but appreciated):