Skip to main content

Secure WASM runtime to isolate and manage AI agent tasks

Project description

capsule-run

A secure, durable runtime for agentic workflows

Overview

Capsule is a runtime for coordinating AI agent tasks in isolated environments. It is designed to handle long-running workflows, large-scale processing, autonomous decision-making securely, or even multi-agent systems.

Each task runs inside its own WebAssembly sandbox, providing:

  • Isolated execution: Each task runs isolated from your host system
  • Resource limits: Set CPU, memory, and timeout limits per task
  • Automatic retries: Handle failures without manual intervention
  • Lifecycle tracking: Monitor which tasks are running, completed, or failed

Installation

pip install capsule-run

Quick Start

Create hello.py:

from capsule import task

@task(name="main", compute="LOW", ram="64MB")
def main() -> str:
    return "Hello from Capsule!"

Run it:

capsule run hello.py

How It Works

Simply annotate your Python functions with the @task decorator:

from capsule import task

@task(name="analyze_data", compute="MEDIUM", ram="512MB", timeout="30s", max_retries=1)
def analyze_data(dataset: list) -> dict:
    """Process data in an isolated, resource-controlled environment."""
    return {"processed": len(dataset), "status": "complete"}

When you run capsule run main.py, your code is compiled into a WebAssembly module and executed in a dedicated sandbox.

Documentation

Task Configuration Options

Parameter Type Description Example
name str Task identifier "process_data"
compute str CPU level: "LOW", "MEDIUM", "HIGH" "MEDIUM"
ram str Memory limit "512MB", "2GB"
timeout str Maximum execution time "30s", "5m"
max_retries int Retry attempts on failure 3

Compute Levels

  • LOW: Minimal allocation for lightweight tasks
  • MEDIUM: Balanced resources for typical workloads
  • HIGH: Maximum fuel for compute-intensive operations
  • CUSTOM: Specify exact fuel value (e.g., compute="1000000")

HTTP Client

Standard requests library isn't compatible with WASM. Use Capsule's HTTP client:

from capsule import task
from capsule.http import get, post

@task(name="fetch", compute="MEDIUM", timeout="30s")
def main() -> dict:
    response = get("https://api.example.com/data")
    return {"status": response.status_code, "ok": response.ok()}

Compatibility

Supported:

  • Pure Python packages and standard library
  • json, math, re, datetime, collections, etc.

⚠️ Not yet supported:

  • Packages with C extensions (e.g numpy, pandas)

Links

License

Apache-2.0

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

capsule_run-0.2.2.tar.gz (71.8 kB view details)

Uploaded Source

Built Distributions

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

capsule_run-0.2.2-py3-none-win_amd64.whl (8.0 MB view details)

Uploaded Python 3Windows x86-64

capsule_run-0.2.2-py3-none-manylinux_2_39_x86_64.whl (8.4 MB view details)

Uploaded Python 3manylinux: glibc 2.39+ x86-64

capsule_run-0.2.2-py3-none-macosx_11_0_arm64.whl (7.6 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

Details for the file capsule_run-0.2.2.tar.gz.

File metadata

  • Download URL: capsule_run-0.2.2.tar.gz
  • Upload date:
  • Size: 71.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.10.2

File hashes

Hashes for capsule_run-0.2.2.tar.gz
Algorithm Hash digest
SHA256 ca820f633781f4b6c1bfc5cc6660c5f741b4f060eb2e4e2279cfac95e0d2f533
MD5 6f0cccd5867c02e7eeb18d92d50b8750
BLAKE2b-256 1184fcc181cbb1f07fb4f028d6aa6c78fc72d34466c4f15338f64c8ef0e720db

See more details on using hashes here.

File details

Details for the file capsule_run-0.2.2-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for capsule_run-0.2.2-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 95544b58857aa533657f01e30ae6693e28da8cdc9dbaeefc74d9940f648e32d0
MD5 7bdc29f2b4d3ce48b1ea61905cbfbb04
BLAKE2b-256 d53cf14fdc9a6217406c14d0c4eb9d7f423f52400bdf0fd27a31f6f2169b7d81

See more details on using hashes here.

File details

Details for the file capsule_run-0.2.2-py3-none-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for capsule_run-0.2.2-py3-none-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 aa68e986538dbb530daec4baa7d04bdc13b2c431f91d3ce8e6cc949e6b133f0a
MD5 4a5e025652508b93c1605f78332f004e
BLAKE2b-256 5b6780e902ef71de02813b3deca12af0e569de7c9ac6ef85f1d7c4be2659eba3

See more details on using hashes here.

File details

Details for the file capsule_run-0.2.2-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for capsule_run-0.2.2-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7cbfc65fd92d585be1ce670cacd527d98363d71aba435d0ac863bbb9a6476b14
MD5 0921f39a59780b922731f7d98ef8f7ed
BLAKE2b-256 1ef3ff9361e78219491d9e9e0d2226126c26aa993a109750a0fc4dae48d050e4

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