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.1.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.1-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

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

Hashes for deepagents_opensandbox-1.0.1.tar.gz
Algorithm Hash digest
SHA256 1c8cea6c540dc3e244f6009a95389a295f619fe6104250cda14a111f42d432cc
MD5 048aaf6ce0ecef46c1ba2c620cd518ee
BLAKE2b-256 e5f8d41a287adc5f6bc6a446816f19f4d775c76a29da51f4264ee50a5e376f38

See more details on using hashes here.

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

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.1-py3-none-any.whl.

File metadata

File hashes

Hashes for deepagents_opensandbox-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f8a19d247f0e4f3ce21a1d6f13e080013d68665fef5c644cc2ef690bae7a17db
MD5 b1d46ca8c31436e10aa2ea4ce9a65f4d
BLAKE2b-256 7ea346540299b14ed7d985a61e9cb489f7fbe2bbc6a6af8dbe57850ca640ef14

See more details on using hashes here.

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

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