eXtreme OPTimization - More optimizing agentic AI
Project description
xopt - eXtreme OPTimization
More optimizing agentic AI with modular, isolated execution environments.
Overview
xopt is a modular AI framework that allows you to package, distribute, and run AI modules in isolated virtual environments. Each module can have its own dependencies, configurations, and tunables - perfect for optimization workflows where parameters need to be adjusted between runs.
Key Features
- Isolated Execution: Each module runs in its own virtual environment
- Lightweight Packaging: Modules packaged as
.xoptarchives (~5-20MB vs 100-500MB containers) - Persistent Configuration: Tunables and configurables survive between runs
- Project-Based Dependencies: Declare dependencies once, run many times
- Optimization-Friendly: Modify parameters without reinstalling modules
Installation
git clone <repository>
cd xoptpy
poetry install
Quick Start
1. Install Example Modules
# Package the React reasoning module
python3 -m xopt package examples/modules/react
# Package the Calculator module
python3 -m xopt package examples/modules/calculator
# Install both modules
python3 -m xopt install xopt_react-0.1.0.xopt
python3 -m xopt install xopt_calculator-0.1.0.xopt
2. Run Modules
# Run calculator module
python3 -m xopt run "xopt/calculator" "sqrt(16) + 2 * pi"
# Run React reasoning module
python3 -m xopt run "xopt/react" "What is the area of a circle with radius 5?"
CLI Commands
Module Management
xopt package <module_dir>
Package a module directory into a .xopt archive.
python3 -m xopt package examples/modules/react
python3 -m xopt package examples/modules/calculator -o my-calc.xopt
xopt install <package.xopt>
Install a module package with isolated virtual environment.
python3 -m xopt install xopt_react-0.1.0.xopt
xopt uninstall <module_name>
Remove an installed module.
python3 -m xopt uninstall "xopt/react"
xopt list
List all installed modules.
python3 -m xopt list
# Output:
# Installed modules:
# xopt/react@0.1.0 - /home/user/.xopt/modules/xopt_react
# xopt/calculator@0.1.0 - /home/user/.xopt/modules/xopt_calculator
Running Modules
xopt run <module> "<input>"
Run an installed module with input.
python3 -m xopt run "xopt/calculator" "2 + 2"
python3 -m xopt run "xopt/react" "What is 5 times 7?"
# With config overrides
python3 -m xopt run "xopt/react" "Hello" -c '{"tunables": {"react_prompt": "Be very concise"}}'
xopt dev <module_dir> <module> "<input>"
Run a module directly from development directory (no installation required).
python3 -m xopt dev examples/modules/react "xopt/react" "What is 2+2?"
Project-Based Workflow
xopt init
Initialize a new xopt project with dependency management.
python3 -m xopt init
Creates:
.xopt/
deps.toml # Dependency declarations
xopt sync
Install all project dependencies declared in .xopt/deps.toml.
python3 -m xopt sync
xopt prun <module> "<input>"
Run module using project-specific configuration.
python3 -m xopt prun "xopt/react" "What is the square root of 144?"
Project Structure
Basic Project Setup
# 1. Initialize project
python3 -m xopt init
# 2. Edit dependencies
cat > .xopt/deps.toml << EOF
[modules]
"xopt/react" = "0.1.0"
"xopt/calculator" = "0.1.0"
[sources]
"xopt/react" = { path = "examples/modules/react" }
"xopt/calculator" = { path = "examples/modules/calculator" }
EOF
# 3. Create module configurations
cat > .xopt/xopt-react.toml << EOF
[tunables]
react_prompt = "You are a helpful math tutor. Show your work step by step."
[configurables]
tool_list = ["xopt/calculator:0.1.0"]
EOF
# 4. Install dependencies
python3 -m xopt sync
# 5. Run with project config
python3 -m xopt prun "xopt/react" "Calculate 15% of 240"
Configuration Files
.xopt/deps.toml - Dependency Declaration
[modules]
"xopt/react" = "0.1.0"
"xopt/calculator" = "0.1.0"
# For development - reference local source
[sources]
"xopt/react" = { path = "examples/modules/react" }
"xopt/calculator" = { path = "examples/modules/calculator" }
# Future: Module registries
[registries]
default = "https://registry.xopt.ai"
.xopt/xopt-<module>.toml - Module Configuration
# .xopt/xopt-react.toml
[tunables]
react_prompt = """Custom prompt for this project..."""
[configurables]
tool_list = ["xopt/calculator:0.1.0", "xopt/websearch:1.0.0"]
Module Development
Creating a Module
- Create module directory:
mkdir my-module
cd my-module
- Add module metadata (
xopt.yaml):
my-org/my-module@1.0.0:
configurables:
some_list: []
tunables:
some_param: "default value"
- Add dependencies (
pyproject.toml):
[project]
name = "my-module"
version = "1.0.0"
dependencies = [
"xopt @ file:///path/to/xoptpy"
]
- Implement module (
my_module.py):
import xopt
from xopt.models import Module, StepResult
@xopt.module
def my_module() -> Module:
module = Module(
name="my-org/my-module",
version="1.0.0",
description="My custom module"
)
@xopt.step
def process(input_data: str) -> StepResult:
# Your module logic here
return StepResult(
action="response",
content=f"Processed: {input_data}"
)
module.register("process", process, str)
module.set_start_step("process")
return module
xopt.register(my_module)
- Package and install:
python3 -m xopt package .
python3 -m xopt install my-org_my-module-1.0.0.xopt
Examples
Math Calculation Chain
python3 -m xopt run "xopt/react" "First calculate 12 * 15, then find the square root of that result"
Custom Configuration
# Create custom React configuration
cat > .xopt/xopt-react.toml << EOF
[tunables]
react_prompt = "You are a precise mathematician. Always show detailed calculations."
[configurables]
tool_list = ["xopt/calculator:0.1.0"]
EOF
# Run with custom config
python3 -m xopt prun "xopt/react" "What is 25% of 480?"
Optimization Workflow
# optimization.py - Example parameter tuning
import subprocess
import json
prompts = [
"Be concise and direct.",
"Show detailed step-by-step reasoning.",
"Focus on accuracy over speed."
]
for i, prompt in enumerate(prompts):
config = {"tunables": {"react_prompt": f"You are helpful. {prompt}"}}
result = subprocess.run([
"python3", "-m", "xopt", "run", "xopt/react",
"Calculate the area of a circle with radius 7",
"-c", json.dumps(config)
], capture_output=True, text=True)
print(f"Config {i+1}: {result.stdout}")
Architecture
- Virtual Environment Isolation: Each module gets its own Python environment (~/.xopt/modules/)
- Process-Level Execution: Modules run in separate processes for crash safety
- Persistent Configuration: Tunables stored in module directories survive restarts
- Dependency Management: Poetry-style dependency resolution with .xopt/deps.toml
- Trace Generation: Automatic execution tracing for debugging and optimization
Development
# Install in development mode
poetry install
# Run tests
poetry run pytest
# Package for distribution
poetry build
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
License
MIT License - see LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xoptpy-0.1.0.tar.gz.
File metadata
- Download URL: xoptpy-0.1.0.tar.gz
- Upload date:
- Size: 19.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.12.3 Linux/6.6.87.2-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42adffe6d63d102e2a6aefafa4aea342f77f367a6ef9d6b15494b11121600270
|
|
| MD5 |
2d8eb95caa6a57b732a5c40ae2770302
|
|
| BLAKE2b-256 |
f9f5b1bdd2e3d782307f795c05a3e64ff9a20e00e6af146c31ccafbb78a20936
|
File details
Details for the file xoptpy-0.1.0-py3-none-any.whl.
File metadata
- Download URL: xoptpy-0.1.0-py3-none-any.whl
- Upload date:
- Size: 19.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.12.3 Linux/6.6.87.2-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3601ad95a928f7b07ec088bbec9515286ded38522675ae4559c716ac316dda8
|
|
| MD5 |
de77947b454ba5c7e00af7dd0fe2357d
|
|
| BLAKE2b-256 |
0ba7e6485049ca0c352062a6c1b7c4e12441c10cdb7bff3f3aad5f51bb701c0c
|