Sandbox Protocol • AI Agent SDK
SandboxProtocol: Protocol for sandbox implementations.
SandboxProtocol
Defined in the protocols module.
AI Agent
Protocol for sandbox implementations.
Sandboxes provide isolated environments for safe code execution. Implementations can use Docker, subprocess isolation, or other containerization technologies.
Example usage (implementation in praisonai-sandbox):
from praisonai_sandbox import DockerSandbox
sandbox = DockerSandbox(image=”python:3.12-slim”) result = await sandbox.execute(“print(‘Hello, World!’)”) print(result.stdout)
Methods
Whether the sandbox backend is available.
sandbox_type()Type of sandbox (docker, subprocess, etc.).
start()Start/initialize the sandbox environment.
stop()Stop/cleanup the sandbox environment.
execute()Execute code in the sandbox.
execute_file()Execute a file in the sandbox.
run_command()Run a shell command in the sandbox.
write_file()Write a file to the sandbox.
read_file()Read a file from the sandbox.
list_files()List files in a sandbox directory.
get_status()Get sandbox status information.
cleanup()Clean up sandbox resources (files, processes, etc.).
reset()Reset sandbox to initial state.
Source
View on GitHubpraisonaiagents/sandbox/protocols.py at line 198