Skip to main content

WASMTIME Executor for CodeAgent

A secure Python code executor for smolagents that uses WASMTIME WebAssembly runtime with the real python.wasm binary to provide strong isolation guarantees.

Usage

You can use it as a drop-in replacement for the built-in PythonExecutor in smolagents. The example is in examples/smolagents_wasmtime.py.

from wasmtime_executor import WasmtimePythonExecutor

from smolagents import CodeAgent, InferenceClientModel
from smolagents.local_python_executor import PythonExecutor


class WasmtimeCodeAgent(CodeAgent):
    """
    Custom CodeAgent that uses WasmtimePythonExecutor for code execution.

    This agent extends the standard CodeAgent to support WASMTIME-based
    WebAssembly execution for enhanced security and isolation.
    """

    def create_python_executor(self) -> PythonExecutor:
        """Override to use WasmtimePythonExecutor instead of built-in executors."""
        return WasmtimePythonExecutor(
            additional_authorized_imports=self.additional_authorized_imports,
            max_print_outputs_length=self.max_print_outputs_length,
            **self.executor_kwargs,
        )


def main():
    model = InferenceClientModel()

    additional_authorized_imports = ["math", "json"]
    max_print_outputs_length = 1000

    agent = WasmtimeCodeAgent(
        tools=[],
        model=model,
        additional_authorized_imports=additional_authorized_imports,
        max_print_outputs_length=max_print_outputs_length,
    )

    output = agent.run("Calculate the square root of 125 and explain the result.")
    print("WASMTIME executor result:", output)

Acknowledgments

Metadata

Release files for wasmtime-executor 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wasmtime-executor 0.1.0
File Size Uploaded Provenance
wasmtime_executor-0.1.0.tar.gz 9.1 MB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for wasmtime-executor 0.1.0
File Interpreter ABI Platform
wasmtime_executor-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 18.3 MB

Release files / wasmtime_executor-0.1.0.tar.gz

Download URL wasmtime_executor-0.1.0.tar.gz
Size 9.1 MB
Tags Source
SHA-256 checksum
How to use checksums
543b834628aa405f1bf99793b7046067cf30ecce758e343f5e56a2740a04eb51
BLAKE2b-256 checksum
How to use checksums
0a0e373298279e8dcf99b136f00ca434efefc2db070334273afb978b07ecf047
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.14

Release files / wasmtime_executor-0.1.0-py3-none-any.whl

Download URL wasmtime_executor-0.1.0-py3-none-any.whl
Size 9.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
0a5ea6d25fd49d2d5c0714ffcf44693895faf4c92a5299427a6dccfbab964a6a
BLAKE2b-256 checksum
How to use checksums
fe7be4b3d3127ebd30b72dd74e618a08b29421fe9c236387b15effbb3e2c5aba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.14

Security for wasmtime-executor 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page