Platform Service

Sandbox Service

Secure code execution for AI agents. Run TypeScript and Python in isolated containers with configurable resource controls, network policies, and full audit logging.

Sandbox Profiles

Configure sandbox profiles with resource limits and security policies

Why It Matters

AI agents generate and execute code. Data analysis scripts, file transformations, API integrations. Without isolation, one mistake — or one malicious prompt — can compromise your infrastructure. Building sandbox environments from scratch means managing container lifecycles, implementing resource limits, configuring network policies, and wiring up audit logging.

The Sandbox Service provides pre-configured execution environments where code runs safely, with every execution logged for audit. Define profiles with specific language runtimes, resource limits, and network access rules. Your agents execute code by referencing a profile name — the service handles container provisioning, isolation, execution, cleanup, and audit recording automatically.

Key Capabilities

Sandbox Execution Architecture

How code flows from agent request to isolated execution and back

Agent Request
Code + Profile
Sandbox Service
Profile + Limits
Container Pool
Warm containers
Isolated Container
Execute + Audit

How it works: When an agent submits code for execution, the Sandbox Service resolves the execution profile (language, harness, resource limits, network policy), provisions an isolated container from the pool, executes the code with enforced constraints, captures stdout, stderr, and return data, then records the full execution in the audit log. The container is cleaned up after execution completes or times out.

Execution Profiles

Profiles are pre-configured execution environments that define the language runtime, available libraries, resource limits, network access, and timeout. Select a profile by name when executing code — the service handles everything else.

Python

python-analysis

Python with pandas, numpy, and matplotlib pre-installed. Designed for data analysis, statistical computation, and visualization generation.

Network: None (fully isolated)
Timeout: 60 seconds
Harness: finance
TypeScript

typescript-general

TypeScript/Node.js runtime for general-purpose code execution. Supports npm packages and modern ES module syntax.

Network: Whitelist (configurable endpoints)
Timeout: 30 seconds
Harness: finance
Custom

Custom Profiles

Define your own profiles with per-field configuration. Choose the language, resource limits, network policy, and timeout that match your specific use case.

Network: Configurable per profile
Timeout: Configurable per profile
Harness: Configurable per profile

Running Code in the Sandbox

Agents generate analysis code and execute it in an isolated environment. The sandbox handles container provisioning, file injection, execution, and result collection automatically.

Data analysis with Python sandbox:
import { Bot, sandbox } from '@firefoundry/agent-sdk';

@Bot({ name: 'data-analyst' })
class DataAnalyst {
  async analyzeData(dataset: string, question: string) {
    // Generate analysis code
    const code = await this.generateAnalysisCode(dataset, question);

    // Execute in isolated sandbox
    const result = await sandbox.execute({
      profile: 'python-analysis',
      language: 'python',
      code: code,
      timeout: 60000,
      files: {
        'data.csv': await this.fetchDataset(dataset)
      }
    });

    return {
      output: result.stdout,
      charts: result.files['output.png'], // Generated visualizations
      exitCode: result.exitCode,
      executionTime: result.durationMs
    };
  }
}

Security Model

The Sandbox Service implements defense in depth. Every layer operates independently so that no single failure compromises the system.

MCP Integration

The Sandbox Service is available as an MCP tool through the MCP Gateway. External agents and integrations can execute code using the standard MCP protocol without the SDK. The sandbox_execute_code tool accepts code, language, and harness as inputs.

Tool Name Description
sandbox_execute_code Execute code in a secure sandbox environment. Supports TypeScript and Python with configurable harness selection.

Parameters: code (string, required) — the code to execute. language (enum, required) — typescript or python. harness (enum, required) — execution harness to use. Returns success status, stdout, stderr, return data, and errors.

Use Cases

Data Analysis

Let agents run Python scripts for statistical analysis, visualization, and data transformation. Pre-installed libraries like pandas, numpy, and matplotlib handle common analysis tasks. Generated charts and files are captured and returned alongside text output.

Code Validation

Test generated code in isolation before applying to production systems. Run unit tests, validate transformations, and verify output format — all in a sandboxed environment where failures cannot affect the rest of the platform.

API Integration

Execute code that calls external APIs in a controlled environment. Whitelist specific endpoints per profile so agents can fetch data from approved services while blocking all other network access. Response data is captured and returned alongside execution output.

File Processing

Transform, convert, and analyze files in sandboxed environments. Inject input files into the sandbox, run processing code, and collect output files — all with full isolation and audit logging. CSV parsing, JSON transformation, and format conversion run safely.

Learn More