Opensandbox backend for DeepAgents
Project description
deepagents-opensandbox
OpenSandbox backend for the DeepAgents framework. This package enables DeepAgents to launch and control isolated sandbox environments using OpenSandbox.
Key Features
- Sandbox Provider: Manages the lifecycle of OpenSandbox instances (create, connect, delete) via the
SandboxProviderinterface fromdeepagents-cli. - Sandbox Backend: Provides a standard interface for command execution and file operations within a sandbox using the synchronous OpenSandbox SDK (
SandboxSync). - DeepAgents Integration: Fully compatible with
BaseSandboxandSandboxProviderinterfaces.
Installation
pip install deepagents-opensandbox
Usage
from deepagents_opensandbox import OpensandboxProvider
# Initialize the provider (uses OPEN_SANDBOX_API_KEY and OPEN_SANDBOX_DOMAIN env vars)
provider = OpensandboxProvider()
# Create a new sandbox
sandbox = provider.get_or_create(image="python:3.11")
# Execute a command
result = sandbox.execute("echo 'Hello World'")
print(result.output)
# Clean up
provider.delete(sandbox_id=sandbox.id)
Using the backend directly
from opensandbox.sync.sandbox import SandboxSync
from deepagents_opensandbox import OpensandboxBackend
sandbox = SandboxSync.create("python:3.11")
backend = OpensandboxBackend(sandbox=sandbox)
result = backend.execute("python --version")
print(result.output)
sandbox.kill()
sandbox.close()
Configuration
| Environment Variable | Description | Default |
|---|---|---|
OPEN_SANDBOX_API_KEY |
API key for authentication | (none) |
OPEN_SANDBOX_DOMAIN |
OpenSandbox server domain | localhost:8080 |
Server proxy mode
By default, the SDK connects directly to sandbox container IPs. This works when the client and sandbox containers share the same network (e.g. both on the host, or in the same Docker/Kubernetes network).
When the OpenSandbox server runs inside Docker and the client runs on the host machine, container IPs (like host.docker.internal) are not reachable from the host. In this case, enable server proxy mode so that all execd requests are routed through the server:
provider = OpensandboxProvider(use_server_proxy=True)
| Deployment | use_server_proxy |
|---|---|
| Server native on host, client on host | False (default) |
| Server in Docker, client on host | True |
| Server in Docker, client in same network | False |
| Kubernetes with proper networking | False |
Note: OpenSandbox server
v0.1.4and earlier have a bug where the proxy handler drops query parameters on GET requests, causing file downloads to fail with400 MISSING_QUERY. The fix is merged intomainbut not yet released. If you hit this issue, build the server image from source (server/directory).
Development
This project uses uv for dependency management.
Prerequisites
- uv installed.
- Python 3.11 or higher.
Setup
Install dependencies:
uv sync
Testing
Tests are split into unit tests (mocked) and integration tests (requiring a real server).
Run Unit Tests (Mocked)
These tests mock the OpenSandbox SDK calls and do not require a running server.
uv run python -m pytest deepagents_opensandbox/ -v
Run Integration Tests
These tests verify behavior against a real OpenSandbox server. They use use_server_proxy=True since the test runner is on the host while the server is in Docker.
OPEN_SANDBOX_DOMAIN=localhost:8090 uv run python -m pytest deepagents_opensandbox/ -v -k integration
Linting
uv run ruff check deepagents_opensandbox/
uv run ruff format --check deepagents_opensandbox/
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file deepagents_opensandbox-1.0.1.tar.gz.
File metadata
- Download URL: deepagents_opensandbox-1.0.1.tar.gz
- Upload date:
- Size: 204.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c8cea6c540dc3e244f6009a95389a295f619fe6104250cda14a111f42d432cc
|
|
| MD5 |
048aaf6ce0ecef46c1ba2c620cd518ee
|
|
| BLAKE2b-256 |
e5f8d41a287adc5f6bc6a446816f19f4d775c76a29da51f4264ee50a5e376f38
|
Provenance
The following attestation bundles were made for deepagents_opensandbox-1.0.1.tar.gz:
Publisher:
publish-to-pypi.yml on shkarupa-alex/deepagents-opensandbox
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
deepagents_opensandbox-1.0.1.tar.gz -
Subject digest:
1c8cea6c540dc3e244f6009a95389a295f619fe6104250cda14a111f42d432cc - Sigstore transparency entry: 1044758093
- Sigstore integration time:
-
Permalink:
shkarupa-alex/deepagents-opensandbox@516319a6920adcd418ab8911a89579441e54ee8f -
Branch / Tag:
refs/tags/1.0.1 - Owner: https://github.com/shkarupa-alex
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@516319a6920adcd418ab8911a89579441e54ee8f -
Trigger Event:
push
-
Statement type:
File details
Details for the file deepagents_opensandbox-1.0.1-py3-none-any.whl.
File metadata
- Download URL: deepagents_opensandbox-1.0.1-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8a19d247f0e4f3ce21a1d6f13e080013d68665fef5c644cc2ef690bae7a17db
|
|
| MD5 |
b1d46ca8c31436e10aa2ea4ce9a65f4d
|
|
| BLAKE2b-256 |
7ea346540299b14ed7d985a61e9cb489f7fbe2bbc6a6af8dbe57850ca640ef14
|
Provenance
The following attestation bundles were made for deepagents_opensandbox-1.0.1-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on shkarupa-alex/deepagents-opensandbox
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
deepagents_opensandbox-1.0.1-py3-none-any.whl -
Subject digest:
f8a19d247f0e4f3ce21a1d6f13e080013d68665fef5c644cc2ef690bae7a17db - Sigstore transparency entry: 1044758140
- Sigstore integration time:
-
Permalink:
shkarupa-alex/deepagents-opensandbox@516319a6920adcd418ab8911a89579441e54ee8f -
Branch / Tag:
refs/tags/1.0.1 - Owner: https://github.com/shkarupa-alex
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@516319a6920adcd418ab8911a89579441e54ee8f -
Trigger Event:
push
-
Statement type: