Skip to main content

Python client SDK for Sandbox Agent — universal API for automatic coding agents in sandboxes

Project description

sandboxagent

Python client SDK for Sandbox Agent — the universal API for automatic coding agents in sandboxes.

Installation

pip install sandbox-agent-sdk

Quick Start

import asyncio
from sandboxagent import SandboxAgent

async def main():
    # Connect to a running sandbox-agent server
    agent = await SandboxAgent.connect("http://localhost:2468")
    
    # Check health
    health = await agent.health()
    print(f"Health: {health}")
    
    # Filesystem operations
    await agent.write_file("/tmp/hello.txt", "Hello from Python!")
    content = await agent.read_file("/tmp/hello.txt")
    print(f"File content: {content}")
    
    # Run a process
    result = await agent.run_process({
        "command": "/bin/echo",
        "args": ["hello", "world"],
        "cwd": "/tmp"
    })
    print(f"stdout: {result['stdout']}")
    
    # List available agents
    agents = await agent.list_agents()
    print(f"Available agents: {[a['id'] for a in agents]}")
    
    # Get inspector URL
    print(f"Inspector: {agent.inspector_url}")
    
    await agent.dispose()

asyncio.run(main())

Starting a Local Server

from sandboxagent import SandboxAgent

# Download and start a local sandbox-agent binary
agent = await SandboxAgent.start()
print(f"Server running at {agent._base_url}")
print(f"Inspector: {agent.inspector_url}")

# ... use the agent ...

await agent.dispose()

ACP Sessions

# Create an ACP session with an agent
session = await agent.create_session(agent="claude")

# Send a prompt
response = await session.prompt("Write a Python function to calculate factorial")
print(response)

# Configure session settings
await session.set_model("claude-sonnet-4-20250514")
await session.set_mode("code")

# Destroy the session
await agent.destroy_session(session.id)

API Coverage

Core APIs

  • Health: health(), wait_for_health()
  • Filesystem: read_file(), write_file(), list_entries(), stat(), move(), delete_entry(), mkdir_fs()
  • Processes: create_process(), run_process(), list_processes(), get_process(), stop_process(), kill_process(), delete_process()
  • Agents: list_agents(), get_agent(), install_agent()
  • Config: get_mcp_config(), set_mcp_config(), get_skills_config(), set_skills_config(), get_process_config(), set_process_config()

Session Management

  • create_session(), resume_session(), destroy_session(), list_sessions(), get_session()
  • Session helpers: prompt(), set_model(), set_mode(), set_thought_level(), set_config_option()

Process Helpers

  • Logs: follow_process_logs() — SSE streaming with log subscription
  • Terminal: connect_process_terminal() — WebSocket interactive terminal

Sandbox Lifecycle

  • pause_sandbox(), resume_sandbox(), restart_sandbox(), destroy_sandbox(), kill_sandbox()

Development

# Setup
uv sync

# Run tests
uv run pytest

# Run integration tests (requires local server)
uv run pytest -m integration

# Lint and format
uv run ruff check
uv run ruff format

# Type check
uv run mypy sandboxagent

License

Apache-2.0

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

sandbox_agent_sdk-0.1.1.tar.gz (73.8 kB view details)

Uploaded Source

Built Distribution

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

sandbox_agent_sdk-0.1.1-py3-none-any.whl (75.4 kB view details)

Uploaded Python 3

File details

Details for the file sandbox_agent_sdk-0.1.1.tar.gz.

File metadata

  • Download URL: sandbox_agent_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 73.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for sandbox_agent_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 4e2046e7b99cdd7480452053afea13d17f2a54902dbd1883e6844c253d20a466
MD5 fddec8c697c2b5eb00c9c5c27c87c2cd
BLAKE2b-256 1d4677820ef1f728ac8055b4a2a5921e168d1c629ade74633b6de4ff236fa6de

See more details on using hashes here.

File details

Details for the file sandbox_agent_sdk-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: sandbox_agent_sdk-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 75.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for sandbox_agent_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a5b0661d9cd9b022e59f1a79c57380785b6ebd59dfb431f80c6f4062ee0629f1
MD5 15a576ee8c40c88cefff959eced4a6fb
BLAKE2b-256 f9cac5d0af99f6c7bd5553a97564f06856f4d36d9adccc12e0f71299fcadfce0

See more details on using hashes here.

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