Skip to main content

A lightweight, framework-agnostic safe code execution library for AI agents

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

openagentworld-sandbox

A lightweight, framework-agnostic safe code execution library for AI agents.

No lock-in. Swap backends in one line. Works with AutoGen, LangChain, or standalone.


The Problem

Every AI agent framework needs to execute code. But:

  • AutoGen's executor only works with AutoGen
  • LangChain has no safe execution built in
  • E2B is cloud-only and paid
  • exec() is dangerous with no isolation

openagentworld-sandbox is the missing abstraction layer.


Install

pip install openagentworld-sandbox

With Docker support:

pip install openagentworld-sandbox[docker]

With all backends:

pip install openagentworld-sandbox[all]

Quick Start

from openagentworld_sandbox import SafeExecutor

# Local subprocess (dev/testing)
executor = SafeExecutor(backend="local")
result = executor.run("print('hello from sandbox')")
print(result.output)   # hello from sandbox
print(result.exit_code)  # 0

# Docker (isolated, production-safe)
executor = SafeExecutor(backend="docker")
result = executor.run("print(2 ** 32)")
print(result.output)   # 4294967296

# E2B cloud
executor = SafeExecutor(backend="e2b")
result = executor.run("print('running in cloud')")

Security Profiles

from openagentworld_sandbox import SafeExecutor, SecurityProfile

# STRICT: blocks dangerous imports, no network, 128MB RAM cap, wipes on exit
executor = SafeExecutor(backend="docker", security=SecurityProfile.STRICT)

# DEFAULT: sane defaults, nothing blocked
executor = SafeExecutor(backend="local", security=SecurityProfile.DEFAULT)

# PERMISSIVE: minimal restrictions for trusted code
executor = SafeExecutor(backend="local", security=SecurityProfile.PERMISSIVE)

AutoGen Integration

from openagentworld_sandbox.integrations.autogen import AutoGenSandbox
from autogen_agentchat.agents import AssistantAgent

executor = AutoGenSandbox(backend="docker", security=SecurityProfile.STRICT)

agent = AssistantAgent(
    name="coder",
    code_executor=executor
)

LangChain Integration

from openagentworld_sandbox.integrations.langchain import LangChainSandbox
from langchain.agents import initialize_agent

tool = LangChainSandbox(backend="docker")

agent = initialize_agent(
    tools=[tool],
    llm=llm,
    agent="zero-shot-react-description"
)

ExecutionResult

Every .run() call returns:

@dataclass
class ExecutionResult:
    output: str         # stdout
    exit_code: int      # 0 = success
    is_timeout: bool    # True if killed by timeout
    error: str | None   # stderr if any
    backend_used: str   # "local" | "docker" | "e2b"

Backends

Backend Isolation Cost Requires
local Low (subprocess) Free Nothing
docker High (container) Free Docker Desktop
e2b High (cloud VM) Paid tiers E2B API key

Roadmap

  • Firecracker backend
  • Multi-language support (JS, bash)
  • Session persistence across .run() calls
  • CrewAI integration
  • OpenManus integration

Contributing

Issues and PRs welcome at openagentworld/openagentworld-sandbox


License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openagentworld_sandbox-0.1.0.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

openagentworld_sandbox-0.1.0-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file openagentworld_sandbox-0.1.0.tar.gz.

File metadata

  • Download URL: openagentworld_sandbox-0.1.0.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for openagentworld_sandbox-0.1.0.tar.gz
Algorithm Hash digest
SHA256 951096a55b5d1b3516e296e274f9e769cc7c6561009e03af967db3b476bcaf25
MD5 fa4f0562d1f806ec5fefb0975ddf738c
BLAKE2b-256 0658c31ae0d29fe4851348a7cc9885c7513250eeaf08c9125cc98c6879a5cf1a

See more details on using hashes here.

File details

Details for the file openagentworld_sandbox-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for openagentworld_sandbox-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 405d3000384cabdf76dc496e1d5ddcb2712ee2a73719481ade5ae7a7e4b0fe07
MD5 5e93ad9c6e722aec63b7a2c0a52797b8
BLAKE2b-256 ab9beecbcd89f73bf94577f6987e59144c08e2532ee4195ddb13f7c8db108a4b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page