Skip to main content

Adaptive Intelligence Mesh - A distributed coordination system for AI deployment and interaction

Project description

AIM Framework: Adaptive Intelligence Mesh

Python Version License Documentation

A distributed coordination system for AI deployment and interaction that revolutionizes how AI systems collaborate and scale.

Overview

The AIM Framework creates a mesh network of AI agents that can:

  • Dynamic Capability Routing: Route queries to specialized micro-agents based on context, urgency, and required expertise
  • Persistent Context Weaving: Create "context threads" that persist across sessions and can be selectively shared between agents
  • Adaptive Resource Scaling: Automatically spawn or hibernate agents based on demand patterns
  • Cross-Agent Learning Propagation: Share knowledge gained by one agent across the mesh without centralized retraining
  • Confidence-Based Collaboration: Enable agents to detect their uncertainty and automatically collaborate with other agents

The core innovation of AIM is the Intent Graph - a real-time graph of user intentions, project contexts, and capability needs that allows the system to anticipate requirements and pre-position resources.

Key Features

🔀 Dynamic Capability Routing

Instead of having one large model handle everything, AIM routes queries to specialized micro-agents based on context, urgency, and required expertise. A coding question might route through a code-specialist agent, then to a security-review agent, then to a documentation agent.

🧵 Persistent Context Weaving

Each interaction creates "context threads" that persist across sessions and can be selectively shared between agents. Your conversation about a project continues seamlessly whether you're asking about code, design, or deployment.

📈 Adaptive Resource Scaling

The mesh automatically spawns or hibernates agents based on demand patterns. During high coding activity, more programming agents activate. During research phases, more analysis agents come online.

🧠 Cross-Agent Learning Propagation

When one agent learns something valuable (like a common error pattern), it propagates this knowledge through the mesh without centralized retraining.

🤝 Confidence-Based Collaboration

Agents can detect their uncertainty and automatically collaborate with other agents, creating dynamic expert panels for complex problems.

🎯 Intent Graph

Builds a real-time graph of user intentions, project contexts, and capability needs to anticipate requirements and pre-position resources.

Installation

From PyPI (Recommended)

pip install aim-framework

From Source

git clone https://github.com/jasonviipers/aim-framework.git
cd aim-framework
pip install -e .

Development Installation

git clone https://github.com/jasonviipers/aim-framework.git
cd aim-framework
pip install -e ".[dev,docs,api,visualization]"

Quick Start

1. Basic Usage

import asyncio
from aim import AIMFramework, Config

async def main():
    # Create and initialize framework
    framework = AIMFramework()
    await framework.initialize()
    
    # Create a request
    from aim import Request
    request = Request(
        user_id="user_123",
        content="Create a Python function to calculate prime numbers",
        task_type="code_generation"
    )
    
    # Process the request
    response = await framework.process_request(request)
    print(f"Response: {response.content}")
    
    # Shutdown
    await framework.shutdown()

if __name__ == "__main__":
    asyncio.run(main())

2. Using the CLI

Start the AIM server:

aim-server --host 0.0.0.0 --port 5000

Initialize a new project:

aim-init my-aim-project
cd my-aim-project
pip install -r requirements.txt
python main.py

Run benchmarks:

aim-benchmark --benchmark-type latency --num-requests 100

3. Creating Custom Agents

from aim import Agent, AgentCapability, Request, Response

class CustomCodeAgent(Agent):
    def __init__(self):
        super().__init__(
            capabilities={AgentCapability.CODE_GENERATION},
            description="Custom code generation agent",
            version="1.0.0"
        )
    
    async def process_request(self, request: Request) -> Response:
        # Your custom logic here
        result = f"Generated code for: {request.content}"
        
        return Response(
            request_id=request.request_id,
            agent_id=self.agent_id,
            content=result,
            confidence=0.9,
            success=True
        )

# Register with framework
framework.register_agent(CustomCodeAgent())

4. Configuration

from aim import Config

# Load from file
config = Config("config.json")

# Or create programmatically
config = Config({
    "framework": {
        "name": "My AIM Framework",
        "log_level": "INFO"
    },
    "api": {
        "host": "0.0.0.0",
        "port": 5000
    },
    "agents": {
        "max_agents_per_type": 5
    }
})

framework = AIMFramework(config)

Architecture

The AIM Framework consists of five main layers:

  1. Interface Layer: APIs and user interfaces
  2. Coordination Layer: Dynamic routing, context weaving, and collaboration
  3. Agent Layer: Specialized micro-agents for different capabilities
  4. Resource Management Layer: Adaptive scaling and load balancing
  5. Knowledge Layer: Learning propagation and Intent Graph

API Reference

Core Classes

  • AIMFramework: Main orchestrator class
  • Agent: Base class for creating custom agents
  • Request/Response: Communication primitives
  • ContextThread: Persistent context management
  • Config: Configuration management

Agent Capabilities

The framework supports various built-in capabilities:

  • CODE_GENERATION: Generate code in various languages
  • SECURITY_REVIEW: Security analysis and vulnerability detection
  • DOCUMENTATION: Generate and maintain documentation
  • DATA_ANALYSIS: Analyze and visualize data
  • DESIGN: UI/UX design and prototyping
  • RESEARCH: Information gathering and analysis
  • TESTING: Test generation and execution
  • DEPLOYMENT: Application deployment and DevOps

Examples

Multi-Agent Collaboration

# Request that requires multiple agents
request = Request(
    user_id="user_123",
    content="Create a secure web API with documentation",
    task_type="code_generation"
)

# Framework automatically routes through:
# 1. Code generation agent
# 2. Security review agent  
# 3. Documentation agent

response = await framework.process_request(request)

Context Persistence

# Create a context thread
thread_id = await framework.create_context_thread(
    user_id="user_123",
    initial_context={"project": "web_api", "language": "python"}
)

# First request
request1 = Request(
    user_id="user_123",
    content="Create a Flask API",
    task_type="code_generation",
    context_thread_id=thread_id
)

# Second request (context is maintained)
request2 = Request(
    user_id="user_123", 
    content="Add authentication to the API",
    task_type="code_generation",
    context_thread_id=thread_id  # Same thread
)

Performance Monitoring

# Get performance metrics
metrics = await framework.get_performance_metrics()
print(f"Average latency: {metrics['avg_latency']}")
print(f"Throughput: {metrics['avg_throughput']}")

# Get framework status
status = framework.get_framework_status()
print(f"Active agents: {status['active_agents']}")

Configuration

The framework supports extensive configuration through JSON files or environment variables:

{
  "framework": {
    "name": "AIM Framework",
    "version": "1.0.0",
    "log_level": "INFO"
  },
  "agents": {
    "min_agents_per_type": 1,
    "max_agents_per_type": 5,
    "default_timeout": 30.0
  },
  "context": {
    "max_threads_per_user": 10,
    "default_ttl": 86400.0
  },
  "api": {
    "host": "0.0.0.0",
    "port": 5000,
    "cors_enabled": true
  },
  "performance": {
    "cache_size": 10000,
    "load_balancing_strategy": "predictive"
  }
}

Environment variables:

  • AIM_LOG_LEVEL: Set logging level
  • AIM_API_HOST: Set API host
  • AIM_API_PORT: Set API port
  • AIM_CACHE_SIZE: Set cache size

Testing

Run the test suite:

pytest tests/

Run with coverage:

pytest --cov=aim tests/

Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Setup

  1. Clone the repository
  2. Install development dependencies: pip install -e ".[dev]"
  3. Install pre-commit hooks: pre-commit install
  4. Run tests: pytest

Documentation

Full documentation is available at https://aim-framework.readthedocs.io/

Building Documentation Locally

cd docs/
make html

Performance

The AIM Framework is designed for high performance and scalability:

  • Latency: Sub-second response times for most requests
  • Throughput: Handles thousands of concurrent requests
  • Scalability: Horizontal scaling through agent mesh architecture
  • Memory: Efficient memory usage with intelligent caching
  • CPU: Optimized for multi-core systems

Roadmap

  • Support for more agent types and capabilities
  • Enhanced Intent Graph with machine learning
  • Distributed deployment across multiple nodes
  • Integration with popular AI/ML frameworks
  • Advanced security and authentication features
  • Real-time collaboration features
  • Plugin system for third-party extensions

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

Citation

If you use the AIM Framework in your research, please cite:

@software{aim_framework,
  title={AIM Framework: Adaptive Intelligence Mesh},
  author={jasonviipers},
  year={2025},
  url={https://github.com/jasonviipers/aim-framework}
}

Acknowledgments

  • Thanks to all contributors and the open-source community
  • Inspired by distributed systems and multi-agent architectures
  • Built with modern Python async/await patterns

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

aim-framework-1.0.0.tar.gz (50.3 kB view details)

Uploaded Source

Built Distribution

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

aim_framework-1.0.0-py3-none-any.whl (56.1 kB view details)

Uploaded Python 3

File details

Details for the file aim-framework-1.0.0.tar.gz.

File metadata

  • Download URL: aim-framework-1.0.0.tar.gz
  • Upload date:
  • Size: 50.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for aim-framework-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d9033083dcccd4528a154953996be9cd54568a1a116effac414e2dbf86fbb125
MD5 6171fea66962cf2ea7aa789d40fd4bb4
BLAKE2b-256 b456a624069c569b41d4a7da4762b02653e47776b67022254fc43e9dd1296ca2

See more details on using hashes here.

File details

Details for the file aim_framework-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: aim_framework-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 56.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for aim_framework-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c406132636fdf638d840d1ac62aaee92040f2099227a6ff5eb98a9f5df481299
MD5 3885c6438ae6a27d3a964d6e7c69439a
BLAKE2b-256 d6c824d44c39654853caf0f6fa2dedf7fbb8c0d4a0270e288edc81ef7d861252

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