Skip to main content

A library for agent and environment protocol interactions

Project description

Interaxions

A modern, extensible framework for orchestrating AI agents and environments on Kubernetes/Argo Workflows, inspired by HuggingFace Transformers.

Python 3.10+ License: MIT

โœจ Features

  • ๐ŸŽฏ Job-Based Configuration - Unified Job schema for complete workflow definition
  • ๐Ÿš€ Dynamic Loading - Load components from built-in, local, or remote Git repositories
  • ๐Ÿ”„ Unified API - All Auto* classes use consistent from_repo() interface
  • ๐Ÿ“ฆ Three-Layer Architecture - Scaffolds, Environments, and Workflows
  • ๐Ÿท๏ธ Version Control - Support for Git tags, branches, and commits
  • ๐Ÿ”’ Multi-Process Safe - File locks for concurrent access
  • ๐Ÿ’พ Smart Caching - Three-level cache system for optimal performance
  • ๐ŸŒ Flexible Sources - GitHub, GitLab, Gitea, or any Git service via IX_ENDPOINT
  • โœ… Comprehensive Testing - 99 tests with 72% coverage

๐Ÿš€ Quick Start

Installation

# Basic installation
pip install interaxions

# With optional dependencies
pip install interaxions[hf]    # HuggingFace datasets
pip install interaxions[oss]   # OSS storage support

# For development
pip install -e ".[dev]"

Basic Usage (Job-Based API)

from interaxions import AutoWorkflow
from interaxions.schemas import Job, Scaffold, Environment, Workflow, Runtime, LiteLLMModel

# Define a complete job configuration
job = Job(
    name="fix-django-bug",
    description="Fix Django bug using SWE-agent",
    tags=["swe-bench", "django"],
    labels={"priority": "high", "team": "research"},
    
    # Model configuration
    model=LiteLLMModel(
        type="litellm",
        provider="openai",
        model="gpt-4",
        base_url="https://api.openai.com/v1",
        api_key="your-api-key",
    ),
    
    # Scaffold (agent) configuration
    scaffold=Scaffold(
        repo_name_or_path="swe-agent",
        params={"max_iterations": 10},
    ),
    
    # Environment configuration
    environment=Environment(
        repo_name_or_path="swe-bench",
        environment_id="astropy__astropy-12907",
        source="hf",
        params={
            "dataset": "princeton-nlp/SWE-bench",
            "split": "test",
        },
    ),
    
    # Workflow configuration
    workflow=Workflow(
        repo_name_or_path="rollout-and-verify",
        params={},
    ),
    
    # Runtime configuration
    runtime=Runtime(
        namespace="experiments",
        service_account="argo-workflow",
        ttl_seconds_after_finished=3600,
    ),
)

# Create and submit workflow
workflow_template = AutoWorkflow.from_repo(job.workflow.repo_name_or_path)
workflow = workflow_template.create_workflow(job)
workflow.create()  # Submit to Argo

Quick API (One-Step Loading)

from interaxions import AutoScaffold, AutoEnvironment, AutoWorkflow

# Load scaffold
scaffold = AutoScaffold.from_repo("swe-agent")

# Load environment (unified API)
env = AutoEnvironment.from_repo(
    repo_name_or_path="swe-bench",
    environment_id="astropy__astropy-12907",
    source="hf",
    dataset="princeton-nlp/SWE-bench",
    split="test",
)

# Load workflow
workflow_template = AutoWorkflow.from_repo("rollout-and-verify")

๐Ÿ“š Core Concepts

1. Job - Unified Configuration

Job is the central schema that encapsulates all information needed to run a workflow:

from interaxions.schemas import Job

job = Job(
    # Metadata
    name="my-job",
    description="Job description",
    tags=["tag1", "tag2"],
    labels={"key": "value"},
    
    # Components (all use from_repo pattern)
    model=...,        # LLM configuration
    scaffold=...,     # Agent/scaffold configuration
    environment=...,  # Environment/data configuration  
    workflow=...,     # Workflow orchestration
    runtime=...,      # Kubernetes/Argo settings
)

2. Three-Layer Architecture

Scaffolds (formerly Agents)

  • High-level orchestration logic
  • Can manage single or multiple agents internally
  • Example: swe-agent

Environments

  • Test environments and evaluation datasets
  • Support HuggingFace, OSS, and custom sources
  • Example: swe-bench

Workflows

  • Define execution order and dependencies
  • Generate Argo Workflows
  • Example: rollout-and-verify

3. Dynamic Loading

All components use the unified from_repo() pattern:

# Built-in (by name, no path separators)
component = Auto*.from_repo("component-name")
component = Auto*.from_repo("swe-agent")  # Uses default config

# Local path (contains /, ., or ~)
component = Auto*.from_repo("./my-component")
component = Auto*.from_repo("/absolute/path/to/component")

# Remote repository (Github/Gitlab)
component = Auto*.from_repo("username/repo-name")

# With specific version
component = Auto*.from_repo("username/repo", revision="v1.0.0")

Loading Logic:

  1. If name contains no path separators (/, ., ~) โ†’ Try as built-in first
  2. If built-in not found or path provided โ†’ Load from filesystem/remote
  3. Built-in modules use default config; external modules require config.yaml
  4. Remote repositories (format: username/repo) use IX_ENDPOINT (defaults to GitHub)

๐ŸŽจ Loading Sources

Built-in Components

Built-in components are Python packages in interaxions/scaffolds/, interaxions/environments/, etc.

Two ways to load:

# Method 1: Direct import (for advanced customization)
from interaxions.scaffolds.swe_agent import SWEAgent, SWEAgentConfig

config = SWEAgentConfig(max_iterations=20)
scaffold = SWEAgent(config=config)

# Method 2: Unified interface (uses default config)
from interaxions import AutoScaffold, AutoWorkflow

scaffold = AutoScaffold.from_repo("swe-agent")  # name only, no paths
workflow = AutoWorkflow.from_repo("rollout-and-verify")

Characteristics:

  • โœ… No config.yaml needed (config in Python code)
  • โœ… Use simple name: "swe-agent", "swe-bench", "rollout-and-verify"
  • โœ… Automatically use default configuration
  • โŒ Cannot use paths: "./swe-agent" will load from filesystem

External Components

External components are loaded from filesystem paths or remote repositories.

from interaxions import AutoScaffold

# From local directory
scaffold = AutoScaffold.from_repo("./my-custom-scaffold")
scaffold = AutoScaffold.from_repo("/absolute/path/to/scaffold")

# From remote Git repository (GitHub by default)
scaffold = AutoScaffold.from_repo("username/my-scaffold")
scaffold = AutoScaffold.from_repo("username/my-scaffold", revision="v1.0.0")

# From GitLab or other Git services (set IX_ENDPOINT)
# export IX_ENDPOINT=https://gitlab.com
scaffold = AutoScaffold.from_repo("username/my-scaffold")

Characteristics:

  • โœ… Must have config.yaml file
  • โœ… Must have specific filename: scaffold.py, env.py, or workflow.py
  • โœ… Can specify version via revision parameter
  • โœ… Supports Git tags, branches, commits
  • โœ… Uses IX_ENDPOINT env var to specify Git service (defaults to GitHub)
  • ๐Ÿ“ฆ Cached in ~/.interaxions/hub/

Built-in vs External Comparison

Feature Built-in External
Loading from_repo("swe-agent") from_repo("./my-scaffold") or from_repo("user/repo")
Location interaxions/scaffolds/ Filesystem / Remote (GitHub/GitLab/etc.)
Config Python code config.yaml required
Versioning Package version Git revision (tags, branches, commits)
Git Service N/A Configurable via IX_ENDPOINT (default: GitHub)
Customization Direct import + custom config Via config.yaml
Use Case Production-ready, battle-tested Custom experiments, research

Environment Loading (Unified API)

from interaxions import AutoEnvironment

# From HuggingFace
env = AutoEnvironment.from_repo(
    repo_name_or_path="swe-bench",
    environment_id="astropy__astropy-12907",
    source="hf",
    dataset="princeton-nlp/SWE-bench",
    split="test",
)

# From OSS (optional dependency)
env = AutoEnvironment.from_repo(
    repo_name_or_path="swe-bench",
    environment_id="astropy__astropy-12907",
    source="oss",
    dataset="swe-bench-data",
    split="test",
    oss_region="cn-hangzhou",
    oss_endpoint="oss-cn-hangzhou.aliyuncs.com",
    oss_access_key_id="your-key-id",
    oss_access_key_secret="your-secret",
)

Batch Loading (Factory Pattern)

from interaxions import AutoEnvironmentFactory

# Load factory once
factory = AutoEnvironmentFactory.from_repo("swe-bench")

# Create multiple environments efficiently
env1 = factory.get_from_hf("astropy__astropy-12907", "dataset", "test")
env2 = factory.get_from_hf("django__django-11039", "dataset", "test")
env3 = factory.get_from_hf("sympy__sympy-18199", "dataset", "test")

๐Ÿ”ง Environment Variables (Optional)

All environment variables have sensible defaults and are optional:

Variable Description Default
IX_HOME Base directory for Interaxions data ~/.interaxions
IX_HUB_CACHE Cache directory for hub modules ~/.interaxions/hub
IX_OFFLINE Enable offline mode (no network) false
IX_ENDPOINT Git service endpoint for remote repos https://github.com

Using Custom Git Services

By default, remote repositories use GitHub. To use GitLab, Gitea, or enterprise Git:

# GitLab
export IX_ENDPOINT=https://gitlab.com
scaffold = AutoScaffold.from_repo("username/my-scaffold")
# โ†’ Clones from https://gitlab.com/username/my-scaffold.git

# Enterprise GitLab
export IX_ENDPOINT=https://git.company.com
scaffold = AutoScaffold.from_repo("team/project")
# โ†’ Clones from https://git.company.com/team/project.git

# Gitea
export IX_ENDPOINT=https://gitea.io

Note: The system automatically appends .git to repository paths.

๐Ÿ“ฆ Creating Custom Components

Custom components are external modules loaded via filesystem paths or remote repositories.

See Repository Standards for detailed requirements.

Minimum Requirements

Scaffold Repository:

my-scaffold/
โ”œโ”€โ”€ config.yaml           # Required: type: my-scaffold, templates: {...}
โ”œโ”€โ”€ scaffold.py           # Required: Class inheriting from BaseScaffold
โ””โ”€โ”€ templates/            # Optional: Jinja2 templates
    โ””โ”€โ”€ main.j2

Example config.yaml:

type: my-scaffold
image: my-scaffold:latest
templates:
  main: templates/main.j2
  sidecar: templates/sidecar.j2

Environment Repository:

my-environment/
โ”œโ”€โ”€ config.yaml           # Required: type: my-environment, templates: {...}
โ”œโ”€โ”€ env.py                # Required: Factory inheriting from BaseEnvironmentFactory
โ””โ”€โ”€ templates/            # Optional: Jinja2 templates
    โ””โ”€โ”€ verify.j2

Example config.yaml:

type: my-environment
templates:
  evaluation: templates/evaluation.j2
  setup: templates/setup.j2

Workflow Repository:

my-workflow/
โ”œโ”€โ”€ config.yaml           # Required: type: my-workflow, templates: {...}
โ”œโ”€โ”€ workflow.py           # Required: Class inheriting from BaseWorkflow
โ””โ”€โ”€ templates/            # Optional: Jinja2 templates
    โ””โ”€โ”€ main.j2

Example config.yaml:

type: my-workflow
templates:
  main: templates/main.j2
  verify: templates/verify.j2

Key Points:

  • โœ… config.yaml is required for external components
  • โœ… Use specific filenames: scaffold.py, env.py, workflow.py
  • โœ… Classes must inherit from base classes: BaseScaffold, BaseEnvironmentFactory, BaseWorkflow
  • โœ… Implement required methods: create_task() for scaffolds/environments, create_workflow() for workflows
  • โœ… templates/ directory is optional but recommended for all component types
  • โœ… Templates in config.yaml are loaded as strings (e.g., templates/main.j2)
  • โœ… Built-in components don't need config.yaml (config in Python code)

๐Ÿงช Testing

# Run all tests (99 passed, 4 skipped)
pytest

# Run specific test categories
pytest -m unit          # Unit tests
pytest -m integration   # Integration tests
pytest -m e2e           # End-to-end tests

# With coverage (currently 72%)
pytest --cov=interaxions --cov-report=html

# View coverage report
open htmlcov/index.html

Test Statistics:

  • โœ… 99 tests passing
  • โญ๏ธ 4 tests skipped (3 OSS optional dependency, 1 needs mock environment)
  • ๐Ÿ“Š 72% code coverage
  • โšก ~4s total runtime

See tests/README.md for detailed testing documentation.

๐Ÿ“ Project Structure

interaxions/
โ”œโ”€โ”€ scaffolds/          # Agent scaffold implementations
โ”‚   โ”œโ”€โ”€ base_scaffold.py
โ”‚   โ””โ”€โ”€ swe_agent/
โ”œโ”€โ”€ environments/       # Environment implementations
โ”‚   โ”œโ”€โ”€ base_environment.py
โ”‚   โ””โ”€โ”€ swe_bench/
โ”œโ”€โ”€ workflows/          # Workflow implementations
โ”‚   โ”œโ”€โ”€ base_workflow.py
โ”‚   โ””โ”€โ”€ rollout_and_verify/
โ”œโ”€โ”€ schemas/            # Pydantic schemas (Job, Scaffold, etc.)
โ”‚   โ”œโ”€โ”€ job.py
โ”‚   โ””โ”€โ”€ models.py
โ””โ”€โ”€ hub/                # Dynamic loading system
    โ”œโ”€โ”€ auto.py         # Auto* classes
    โ”œโ”€โ”€ hub_manager.py  # Repository management
    โ””โ”€โ”€ constants.py    # Configuration

tests/                  # Comprehensive test suite (99 passed, 72% coverage)
โ”œโ”€โ”€ unit/               # Unit tests (schemas, models)
โ”œโ”€โ”€ integration/        # Integration tests (auto loading, factories)
โ”œโ”€โ”€ e2e/                # End-to-end tests (full pipeline)
โ”œโ”€โ”€ fixtures/           # Test data and mock repositories
โ”‚   โ”œโ”€โ”€ mock_repos/     # Mock scaffold/workflow repos for testing
โ”‚   โ””โ”€โ”€ sample_data.py  # Sample data generators
โ””โ”€โ”€ conftest.py         # Shared fixtures and test configuration

examples/               # Usage examples
โ””โ”€โ”€ quickstart.py       # Complete tutorial

๐Ÿ”„ Development Workflow

# Clone repository
git clone https://github.com/Hambaobao/interaxions.git
cd interaxions

# Install with dev dependencies
pip install -e ".[dev]"

# Run tests (should see 99 passed, 4 skipped)
pytest

# Run specific test categories
pytest -m unit          # Fast unit tests
pytest -m integration   # Integration tests
pytest -m e2e           # End-to-end tests

# Check coverage
pytest --cov=interaxions --cov-report=term

# Run examples
python examples/quickstart.py

# Build package
python -m build

# Check package
twine check dist/*

๐Ÿ“– Documentation

๐Ÿค Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for new functionality
  4. Ensure all tests pass: pytest -m unit
  5. Submit a pull request

๐Ÿ“„ License

MIT License - see LICENSE for details

๐Ÿ™ Acknowledgments

๐Ÿ”— Links


Made with โค๏ธ for the AI agent research community

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

interaxions-0.0.3.tar.gz (42.9 kB view details)

Uploaded Source

Built Distribution

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

interaxions-0.0.3-py3-none-any.whl (44.5 kB view details)

Uploaded Python 3

File details

Details for the file interaxions-0.0.3.tar.gz.

File metadata

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

File hashes

Hashes for interaxions-0.0.3.tar.gz
Algorithm Hash digest
SHA256 1dd5022a7ae10b947ce8a89942e2927ea092982c55276232321da5b8c850206c
MD5 93d40bd7574c59ac408cd349cc027aa1
BLAKE2b-256 7a3fabc347489fb88f98b9ad823998cc800f87d620bdf28e9adc5b6c23be71ef

See more details on using hashes here.

Provenance

The following attestation bundles were made for interaxions-0.0.3.tar.gz:

Publisher: python-publish.yaml on Hambaobao/interaxions

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

File details

Details for the file interaxions-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: interaxions-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 44.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for interaxions-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 313c98ddc03fb31df9a826d7a6f02a6b1946b5eb81e082165769210404738e37
MD5 c9456522090af26666ac3f4509d0b190
BLAKE2b-256 5d66d207177cba8a1f57908f043326071669ddedd37d67ad7b9e7490d7f1969b

See more details on using hashes here.

Provenance

The following attestation bundles were made for interaxions-0.0.3-py3-none-any.whl:

Publisher: python-publish.yaml on Hambaobao/interaxions

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