Sandboxed

Running isolated environments for executing code for agents

Published: Oct 27, 2025 | Author: System32 AI Labs | Reading time: ~3 min
sandboxed.md
Why Sandboxed?

So we have built a self hostable language-agnostic framework to execute code in isolated environments for your AI agents.

It uses your existing kubernetes cluster to spin up isolated sandboxes for executing code securely. Each sandbox is ephemeral and destroyed after use, ensuring no residual data or state persists.



https://github.com/system32-ai/sandboxed
how-it-works.md
How does it work?

Agents can invoke sandboxed environments to run code securely and independently. The sandboxes are created in the kubernetes that's integrated with the system.

The lifecycle of these sandboxes is managed automatically - they are created when an agent needs to execute code, and destroyed when the task is complete. This allows for efficient resource usage and scalability.

Primitive to control the sandboxes are provided via APIs, allowing agents to request sandbox creation, execute code within them, and retrieve results.

example.md
Using API

curl -L https://github.com/system32-ai/sandboxed/releases/download/v1.0.8/sandboxed-v1.0.0-darwin-amd64.tar.gz -o
sandboxed.tar.gz
tar -xzf sandboxed.tar.gz
mv sandboxed-v1.0.8-darwin-arm64 sandboxed
sudo mv sandboxed /usr/local/bin/
sudo chmod +x /usr/local/bin/sandboxed
rm sandboxed.tar.gz
sandboxed version 
Start the sandboxed server:

sandboxed server
Create a sandbox, execute code and destroy it:

Create a sandbox
curl -X POST http://localhost:8080/api/v1/sandbox/create \
-H "Content-Type: application/json" \
-d '{
    "language": "python",
    "name": "data-processing",
}'
Execute code in the sandbox
curl -X POST http://localhost:8080/api/v1/execute \
-H "Content-Type: application/json" \
-d '{
    "sandbox_id": "data-processing-1698765432",
    "code": "import pandas as pd\nimport numpy as np\n\n# Create sample data\ndata = np.random.randn(100, 3)\ndf =
    pd.DataFrame(data, columns=[\"A\", \"B\", \"C\"])\nprint(f\"Dataset shape: {df.shape}\")\nprint(f\"Mean
    values:\\n{df.mean()}\")",
}'
Destroy the sandbox
curl -X POST http://localhost:8080/api/v1/sandbox/destroy \
-H "Content-Type: application/json" \
-d '{
    "sandbox_id": "data-processing-1698765432",
    "namespace": "development",
    "force": false
}'
Tool's list in MCP

Tool Purpose Parameters Returns
create_sandbox Create new sandbox name, language, namespace?, labels? success, message
run_code Execute code in sandbox sandbox_name, code success, output, exit_code
destroy_sandbox Clean up sandbox sandbox_name success, message
list_sandboxes List active sandboxes none sandboxes[], count

Using Native SDK

Here's a simple example of how an AI agent can use the sandboxed environment to execute Python code securely using the SDK:


package main

import (
    "log"
    "github.com/system32-ai/sandboxed/pkg/sdk"
)

func main() {

    sandbox, err := sdk.CreateSandbox("debug-generated-code", sdk.Python)
    if err != nil {
    log.Fatalf("failed to create sandbox: %v", err)
    }

    defer sandbox.Destroy()

    code := `python -c 'print("Hello, World!")'`

    output, err := sandbox.Run(code)
    if err != nil {
    log.Fatal(err)
    }

    log.Printf("Output: %s", output.Result)

    code = `python --version`
    output, err = sandbox.Run(code)
    if err != nil {
    log.Fatal(err)
    }

    log.Printf("Output: %s", output.Result)
}

═══════════════════════════════════════════════════════════════════════════════════
Back to Blogs