Skip to main content

Agent Sandbox Python SDK

A Python SDK for the All-in-One Sandbox API, providing access to sandbox, shell, file, jupyter, nodejs, and mcp services.

Installation

pip install agent-sandbox

Usage

from agent_sandbox import Sandbox

client = Sandbox(base_url="http://localhost:8091")

ctx = client.sandbox.get_context()
print(ctx)

result = client.shell.exec_command(command="ls -la")
print(result)

Async Support

The SDK also provides async support through the AsyncSandbox class:

import asyncio
from agent_sandbox import AsyncSandbox

async def main():
    client = AsyncSandbox(base_url="http://localhost:8091")
    
    # Get sandbox context
    ctx = await client.sandbox.get_context()
    print(ctx)

    result = await client.shell.exec_command(command="ls -la")
    print(result)

asyncio.run(main())

Cloud Providers

Volcengine

Create a sandbox instance using the Volcengine provider. For more details, please refer to examples/provider_volcengine.py.

from __future__ import print_function

import os
import sys

# Add the parent directory to Python path so we can import agent_sandbox
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

from agent_sandbox.providers import VolcengineProvider


def main():
    """
    Main function demonstrating Volcengine provider usage.
    """
    # Configuration - replace with your actual credentials
    access_key = os.getenv("VOLC_ACCESSKEY")
    secret_key = os.getenv("VOLC_SECRETKEY")
    region = os.getenv("VOLCENGINE_REGION", "cn-beijing")
    
    # Initialize the Volcengine provider
    provider = VolcengineProvider(
        access_key=access_key,
        secret_key=secret_key,
        region=region
    )
    
    print("=== Volcengine Sandbox Provider Example ===\n")
    
    function_id = "yatoczqh"
    
    print("1. Creating a sandbox...")
    sandbox_id = provider.create_sandbox(function_id=function_id)
    print(f"Create response: {sandbox_id}")


if __name__ == "__main__":
    main()

Features

  • Sandbox: Access sandbox environment information and installed packages
  • Shell: Execute shell commands with session management
  • File: Read, write, search, and manage files
  • Jupyter: Execute Python code in Jupyter kernels
  • Node.js: Execute JavaScript code in Node.js environment
  • MCP: Interact with Model Context Protocol servers

Requirements

  • Python 3.8+
  • httpx
  • pydantic
  • typing_extensions (for Python < 3.10)

Release files for agent-sandbox 0.0.30

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agent-sandbox 0.0.30
File Size Uploaded
agent_sandbox-0.0.30.tar.gz 111.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for agent-sandbox 0.0.30
File Interpreter ABI Platform
agent_sandbox-0.0.30-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 355.5 kB

Release files / agent_sandbox-0.0.30.tar.gz

Download URL agent_sandbox-0.0.30.tar.gz
Size 111.8 kB
Tags Source
SHA-256 checksum
How to use checksums
29677beca8fabf9ee1ec7c0e5637d15ba37a7e1f58cc8deb82611772fdec43bb
BLAKE2b-256 checksum
How to use checksums
325c94d924db07da1e4f0925dd593939e652bb45d60cc749756bcce2d302817d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / agent_sandbox-0.0.30-py2.py3-none-any.whl

Download URL agent_sandbox-0.0.30-py2.py3-none-any.whl
Size 243.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
bbcca45a202abb7cd01162473f01f3218de5037745ef4fa539e617a3cc973896
BLAKE2b-256 checksum
How to use checksums
5bbcb83d625cf8cb9611c379b452d60da47a26fb7ccfa6c56c63cde4e45214c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release history Release notifications | RSS feed

This release

0.0.30 This release

2 release files

0.0.29

2 release files

0.0.28

2 release files

0.0.27

2 release files

0.0.24

2 release files

0.0.23

2 release files

0.0.22

2 release files

0.0.21

2 release files

0.0.20

2 release files

0.0.19

2 release files

0.0.16

2 release files

0.0.15

2 release files

0.0.14

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page