shield-checkSandbox Filesystem

Run agents in an isolated, ephemeral environment. Perfect for executing untrusted code, CI/CD pipelines, and security-critical workflows.

circle-check

Quick Start

from glaip_sdk import Agent
from glaip_sdk.models.filesystem import SandboxConfig

agent = Agent(
    name="secure-runner",
    instruction="Execute code safely in an isolated environment.",
    filesystem=SandboxConfig(),  # Uses defaults
)

result = agent.run("""
Create a Python script that calculates factorial,
run it with the execute tool, and save the result to /workspace/output.txt
""")

When to Use Sandbox

Use Case
Why Sandbox?

Untrusted Code

Run arbitrary code without host risk

CI/CD Automation

Clean environment for each run

Data Processing

Isolated workspace for sensitive data

Remote Execution

Same isolation as local

Configuration

Parameters

  • base_dir - Absolute path (e.g., /workspace). Auto-created.

  • timeout_seconds - Must be > 0. Session expires after this duration.

  • allow_execute - True (default): Agent can run commands. False: File operations only.

Prerequisites

Local Execution

Get your key from the provider dashboard (e.g., e2b.devarrow-up-right).

Remote Execution

  • Platform must support sandbox filesystem backend

  • No additional setup needed (platform manages the sandbox)

Examples

Run Code Safely

File Operations Only

Long-Running Tasks

How It Works

  1. Provisioning - Isolated environment is provisioned (may take a few seconds on first use)

  2. Execution - Commands run inside the isolated environment

  3. Cleanup - Environment is destroyed after run or timeout

circle-exclamation

Limitations

  • Ephemeral - Files lost after run ends

  • Resource Limits - Subject to provider quotas

  • No Persistence - Cannot save state between runs

Troubleshooting

"ModuleNotFoundError: Sandbox filesystem backend requires..."

Fix:

"E2B_API_KEY not set" or tests skipped

Cause: Sandbox provider API key not configured

Fix:

"base_dir must not contain parent directory traversal"

Fix: Use absolute path without ..:

Comparison with Local Disk

Aspect
Local Disk
Sandbox

Execute

Disabled by default

Enabled by default

Persistence

Yes

No (ephemeral)

Isolation

None

Full container

Cleanup

Manual

Automatic

Best For

Trusted dev

Untrusted code

Last updated

Was this helpful?