Skip to main content

coreason-sandbox

Project description

coreason-sandbox

A secure, ephemeral execution environment designed to give CoReason Agents the ability to write and run code safely.

License: Prosperity 3.0 CI/Status Code Style: Ruff Documentation

coreason-sandbox serves as the "Hands" for the "Brains" of the CoReason system. It solves the problem of hallucinated math and missing visuals by providing a real, isolated Linux runtime where Python and R scripts can be executed deterministically. It abstracts the underlying compute engine, allowing seamless switching between local Docker containers (for development/on-prem) and cloud-based microVMs (E2B for production).

Features

  • Deterministic Execution: Agents write Python code to calculate, ensuring 100% mathematical accuracy.
  • Strict Isolation: Code runs in disposable, network-isolated sandboxes that are destroyed immediately after use (preventing RCE).
  • Artifact Capture: Automatically captures filesystem changes (e.g., plot.png) and pipes them back to the user UI.
  • Runtime Agnostic: Switch seamlessly between local Docker containers and E2B Cloud microVMs using a Strategy Pattern.
  • Lifecycle Management: Automatic provisioning, keep-alive for iterative execution, and background reaping of idle sessions.
  • Security: Network isolation by default, strict package allowlisting (PyPI only), and resource throttling (CPU/Memory).

Installation

pip install coreason-sandbox

Usage

Here is a simple example of how to initialize and use the library to execute Python code:

import asyncio
from coreason_sandbox.config import SandboxConfig
from coreason_sandbox.factory import SandboxFactory

async def main():
    # 1. Configure (defaults to Docker)
    config = SandboxConfig(
        runtime="docker",
        docker_image="python:3.12-slim"
    )

    # 2. Create Runtime
    runtime = SandboxFactory.get_runtime(config)

    # 3. Start & Execute
    await runtime.start()
    try:
        result = await runtime.execute("print(2 + 2)", language="python")
        print(f"Result: {result.stdout.strip()}")  # Output: Result: 4
    finally:
        await runtime.terminate()

if __name__ == "__main__":
    asyncio.run(main())

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

coreason_sandbox-0.1.0.tar.gz (21.4 kB view details)

Uploaded Source

Built Distribution

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

coreason_sandbox-0.1.0-py3-none-any.whl (30.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: coreason_sandbox-0.1.0.tar.gz
  • Upload date:
  • Size: 21.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for coreason_sandbox-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e721580f3fd84be2fe3234a70fe61df7d8195417ff9c6091fff0352536cb95ce
MD5 5e24783d33ba21d937c03fe92a036aae
BLAKE2b-256 fd3f78741d5dc7a4d44a08d6c12e0aaefb7d9a99f0b733b3c5dce56765835241

See more details on using hashes here.

Provenance

The following attestation bundles were made for coreason_sandbox-0.1.0.tar.gz:

Publisher: publish.yml on CoReason-AI/coreason-sandbox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for coreason_sandbox-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c8c8db33b3d8906cb670ab30900de0aa79bd7ae3894554093fe83b709fede7e1
MD5 4d15c70c303c7f4633eda97944a38bc1
BLAKE2b-256 46359e9c77c837af5329c31c94aca4ecb27ac1b4adf1d109081a91b01763fb58

See more details on using hashes here.

Provenance

The following attestation bundles were made for coreason_sandbox-0.1.0-py3-none-any.whl:

Publisher: publish.yml on CoReason-AI/coreason-sandbox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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