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

  • ๐ŸŽฏ XJob-Based Configuration - Unified XJob 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 (XJob-Based API)

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

# Define a complete job configuration
job = XJob(
    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. XJob - Unified Configuration

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

from interaxions.schemas import XJob

job = XJob(
    # Metadata
    name="my-job",
    description="XJob 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.

Accessing Private Repositories

All Auto*.from_repo() methods support authentication for private repositories using username and token parameters:

from interaxions import AutoScaffold

# Load from private repository
scaffold = AutoScaffold.from_repo(
    repo_name_or_path="company/private-agent",
    username="your-username",
    token="ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"  # GitHub PAT
)

# With custom Git service (GitLab)
import os
os.environ["IX_ENDPOINT"] = "https://gitlab.company.com"

scaffold = AutoScaffold.from_repo(
    repo_name_or_path="team/private-agent",
    username="gitlab-user",
    token="glpat-xxxxxxxxxxxxxxxxxxxx"  # GitLab token
)

# Best practice: Use environment variables
git_username = os.getenv("GIT_USERNAME")
git_token = os.getenv("GIT_TOKEN")

scaffold = AutoScaffold.from_repo(
    repo_name_or_path="company/private-agent",
    username=git_username,
    token=git_token
)

Supported: AutoScaffold, AutoEnvironmentFactory, AutoEnvironment, AutoWorkflow

Authentication format: The system constructs URLs like https://username:token@host/repo.git, similar to:

git clone https://username:token@gitlab.company.com/test-user/Demo-Agent.git

Token generation:

๐Ÿ“ฆ 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 (XJob, 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.5.post3.tar.gz (44.3 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.5.post3-py3-none-any.whl (45.9 kB view details)

Uploaded Python 3

File details

Details for the file interaxions-0.0.5.post3.tar.gz.

File metadata

  • Download URL: interaxions-0.0.5.post3.tar.gz
  • Upload date:
  • Size: 44.3 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.5.post3.tar.gz
Algorithm Hash digest
SHA256 43945ddca77c0b13b3fde365037003eddbb62264c573df7fe94adc757313ae43
MD5 a76e1e54228782017b8fdc3b96bed10f
BLAKE2b-256 377f4a0424ad8fb2550b9af5817d404542e3e704293df7ed48ba83a9c60e44a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for interaxions-0.0.5.post3.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.5.post3-py3-none-any.whl.

File metadata

File hashes

Hashes for interaxions-0.0.5.post3-py3-none-any.whl
Algorithm Hash digest
SHA256 62a7e316648e394b19edd2131262b81878c4a6aabc8dd9ab5e22ee68e2a0b7c1
MD5 a69a28f25f1dc066e730c8c78330747b
BLAKE2b-256 831b4e73e7657546ea8cbc20d6aa388b80876d31e75fc0e3d302ccbfc8cebb3d

See more details on using hashes here.

Provenance

The following attestation bundles were made for interaxions-0.0.5.post3-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