Skip to main content

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 SandboxProvider interface from deepagents-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 BaseSandbox and SandboxProvider interfaces.

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.4 and earlier have a bug where the proxy handler drops query parameters on GET requests, causing file downloads to fail with 400 MISSING_QUERY. The fix is merged into main but 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

deepagents_opensandbox-1.0.2.tar.gz (204.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

deepagents_opensandbox-1.0.2-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file deepagents_opensandbox-1.0.2.tar.gz.

File metadata

  • Download URL: deepagents_opensandbox-1.0.2.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

Hashes for deepagents_opensandbox-1.0.2.tar.gz
Algorithm Hash digest
SHA256 cbb14afd0d7d76434ab90f6df412be008b58445c848334a9ae494ac81a4ea010
MD5 6597df03fc2666459531bb7b4972828f
BLAKE2b-256 afd62517608d17ed0bca75611c42f2b92d1c9d6ae0582f30e65936a84b14350a

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepagents_opensandbox-1.0.2.tar.gz:

Publisher: publish-to-pypi.yml on shkarupa-alex/deepagents-opensandbox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file deepagents_opensandbox-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for deepagents_opensandbox-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 68d5dbcfb6ff687789240a71fd6e9700501bbc79d9f92c93cbb866ffd42ce164
MD5 55b41e719f08016e90228415dc15bd1e
BLAKE2b-256 e8d7448167f6a25e763a36a729956e7b95b1863d6a566ae1440b4d4e0fbd72f2

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepagents_opensandbox-1.0.2-py3-none-any.whl:

Publisher: publish-to-pypi.yml on shkarupa-alex/deepagents-opensandbox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page