Skip to content

API Reference parrot_tools.sandboxtool

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_tools.sandboxtool

View source

AI-Parrot gVisor Sandbox Tool

Secure Python execution tool using gVisor (runsc) for complete kernel-level isolation. This tool provides safe code execution for untrusted LLM-generated code.

Class ExecutionResult

Result from sandbox execution

Parameter Type Default Description
success bool
stdout str
stderr str
exit_code int
execution_time_ms float
files_created Dict[str, bytes] dict()
dataframes Dict[str, pd.DataFrame] dict()
plots List[Dict[str, Any]] list()
notebook_path Optional[str] None
error_message Optional[str] None

Fields:

Field Type Default Description
success bool
stdout str
stderr str
exit_code int
execution_time_ms float
files_created Dict[str, bytes] field(default_factory=dict)
dataframes Dict[str, pd.DataFrame] field(default_factory=dict)
plots List[Dict[str, Any]] field(default_factory=list)
notebook_path Optional[str] None
error_message Optional[str] None

Class SandboxConfig

Configuration for gVisor sandbox

Parameter Type Default Description
runtime str 'runsc'
network str 'none'
max_memory str '2G'
max_cpu float 2.0
timeout int 30
python_image str 'python:3.11-slim'
enable_gpu bool False
mount_paths List[str] list()
pip_packages List[str] (lambda: ['pandas', 'numpy', 'altair', 'scikit-learn', 'scipy', 'plotly', 'jupyterlab', 'ipykernel'])()

Fields:

Field Type Default Description
runtime str 'runsc'
network str 'none'
max_memory str '2G'
max_cpu float 2.0
timeout int 30
python_image str 'python:3.11-slim'
enable_gpu bool False
mount_paths List[str] field(default_factory=list)
pip_packages List[str] field(default_factory=lambda: ['pandas', 'numpy', 'altair', 'scikit-learn', 'scipy', 'plotly', 'jupyterlab', 'ipykernel'])

Class SandboxPandasTool

Specialized version for Pandas operations with enhanced data handling. Drop-in replacement for PythonPandasTool with security.

Parameter Type Default Description
dataframes Optional[Dict[str, pd.DataFrame]] None
**kwargs {}

Method SandboxPandasTool.analyze_dataframe

Perform automated DataFrame analysis.

analyze_dataframe(df_name: str, analysis_type: str = 'summary') -> ToolResult

Parameter Type Default Description
df_name str Name of dataframe to analyze
analysis_type str 'summary' Type of analysis (summary, correlation, distribution)

Returns: ToolResult

Class SandboxTool

Secure Python execution using gVisor sandbox.

This tool provides kernel-level isolation for executing untrusted code generated by LLMs, preventing escape attempts and resource exhaustion.

Parameter Type Default Description
config Optional[SandboxConfig] None Sandbox configuration
workspace_dir Optional[str] None Directory for temporary files
dataframes Optional[Dict[str, pd.DataFrame]] None Initial dataframes to make available
enable_jupyter bool False Enable Jupyter notebook creation
logger Optional[logging.Logger] None Logger instance

Method SandboxTool.add_dataframe

Add a dataframe to be available in the sandbox

add_dataframe(name: str, df: pd.DataFrame)

Parameter Type Default Description
name str
df pd.DataFrame

Method SandboxTool.set_timeout

Set execution timeout in seconds

set_timeout(timeout: int)

Parameter Type Default Description
timeout int

Method SandboxTool.set_memory_limit

Set memory limit (e.g., '1G', '512M')

set_memory_limit(memory: str)

Parameter Type Default Description
memory str

Method SandboxTool.cleanup

Clean up all resources

cleanup()

Function create_sandbox_tool

Factory function to create gVisor tools.

create_sandbox_tool(tool_type: str = 'sandbox', **kwargs) -> Union[SandboxTool, SandboxPandasTool]

Parameter Type Default Description
tool_type str 'sandbox' Type of tool ('sandbox' or 'pandas')
**kwargs {} Configuration parameters

Returns: Union[SandboxTool, SandboxPandasTool] — Configured gVisor tool instance

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally