mas-framework


Namemas-framework JSON
Version 0.1.14 PyPI version JSON
download
home_pageNone
SummaryA Multi-Agent System Framework
upload_time2025-01-09 21:38:29
maintainerNone
docs_urlNone
authorNone
requires_python>=3.11
licenseMIT
keywords ai agent framework multi-agent
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # MAS AI - Experimental Multi-Agent System Framework

⚠️ **EXPERIMENTAL STATUS**: This project is in early development and APIs are subject to breaking changes. Not recommended for production use.

MAS AI is a Python framework for building multi-agent systems, focusing on reliable message passing and state management between agents.

## Core SDK Features

-   **Simple Agent Creation** - Declarative agent definition with capabilities
-   **Type-Safe State Management** - Immutable state management with Pydantic models
-   **Message Routing** - Reliable agent-to-agent communication
-   **Agent Discovery** - Find agents by capabilities
-   **Lifecycle Management** - Controlled agent startup/shutdown

## Quick Start

1. Prerequisites:

```bash
# Required: Redis server for message transport
redis-server

# Install package
pip install mas-framework
```

2. Create an Agent:

```python
from mas.sdk.agent import Agent
from mas.sdk.decorators import agent
from mas.protocol import Message
from mas.sdk.state import AgentState
from pydantic import Field

# Optional: Define custom state model
class MyState(AgentState):
    counter: int = Field(default=0)
    name: str = Field(default="")

@agent(
    agent_id="example_agent",
    capabilities=["math", "storage"],
    metadata={"version": "0.1.0"},
    state_model=MyState  # Optional custom state model
)
class ExampleAgent(Agent):
    async def on_message(self, message: Message) -> None:
        # Handle incoming messages
        print(f"Got message: {message.payload}")

        # Update agent's state
        await self.update_state({
            "counter": 42,
            "name": "example"
        })

        # Access current state
        current_state = self.state
        print(f"Counter: {current_state.data['counter']}")
```

3. Run the Agent:

```python
import asyncio
from mas import mas_service

async def main():
    async with mas_service() as context:
        agent = await ExampleAgent.build(context)
        try:
            while True:
                await asyncio.sleep(1)
        finally:
            await agent.stop()

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

## Key SDK Components

### State Management

Agents maintain immutable state with type-safe updates:

```python
# Define custom state model
class MyState(AgentState):
    counter: int = Field(default=0)
    status: str = Field(default="idle")

# Update state
await agent.update_state({
    "counter": 42,
    "status": "ready"
})

# Access state
current_state = agent.state
print(f"Counter: {current_state.data['counter']}")

# Reset state to initial values
await agent.reset_state()

# Subscribe to state changes
async def on_state_change(new_state: MyState) -> None:
    print(f"State changed: {new_state.model_dump()}")

agent.subscribe_to_state(on_state_change)
```

### Message Handling

Pattern matching for message types:

```python
async def on_message(self, message: Message) -> None:
    match message.message_type:
        case MessageType.AGENT_MESSAGE:
            await self.handle_agent_message(message)
        case MessageType.DISCOVERY_RESPONSE:
            await self.handle_discovery(message)
```

### Agent Discovery

Find other agents by capabilities:

```python
# Find agents with specific capabilities
await agent.runtime.discover_agents(capabilities=["math"])
```

### Lifecycle Hooks

```python
class MyAgent(Agent):
    async def on_start(self) -> None:
        """Called when agent starts"""
        await self.update_state({"status": "starting"})

    async def on_stop(self) -> None:
        """Called when agent stops"""
        await self.cleanup_resources()
```

## Current Limitations

As this is experimental software, there are several limitations:

-   No authentication/authorization system yet
-   Limited error recovery mechanisms
-   Message delivery is not guaranteed
-   No persistent storage (in-memory only)
-   APIs may change without notice
-   Limited testing in distributed environments
-   No proper documentation yet

## Development Status

This project is under active development. Current focus areas:

-   Stabilizing core APIs
-   Improving error handling
-   Adding authentication
-   Adding persistent storage
-   Documentation
-   Testing infrastructure

## Contributing

This project is in experimental phase and we welcome feedback and contributions:

1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Run tests: `pytest`
5. Submit a pull request

## License

MIT License - see LICENSE file for details

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "mas-framework",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": null,
    "keywords": "AI, agent, framework, multi-agent",
    "author": null,
    "author_email": "Lemuel Boyce <lemuel@vokality.com>",
    "download_url": "https://files.pythonhosted.org/packages/f0/27/db60d301bc4bd6fbc6523a03059fa1ab08482894fbf9abf390f1cd64620c/mas_framework-0.1.14.tar.gz",
    "platform": null,
    "description": "# MAS AI - Experimental Multi-Agent System Framework\n\n\u26a0\ufe0f **EXPERIMENTAL STATUS**: This project is in early development and APIs are subject to breaking changes. Not recommended for production use.\n\nMAS AI is a Python framework for building multi-agent systems, focusing on reliable message passing and state management between agents.\n\n## Core SDK Features\n\n-   **Simple Agent Creation** - Declarative agent definition with capabilities\n-   **Type-Safe State Management** - Immutable state management with Pydantic models\n-   **Message Routing** - Reliable agent-to-agent communication\n-   **Agent Discovery** - Find agents by capabilities\n-   **Lifecycle Management** - Controlled agent startup/shutdown\n\n## Quick Start\n\n1. Prerequisites:\n\n```bash\n# Required: Redis server for message transport\nredis-server\n\n# Install package\npip install mas-framework\n```\n\n2. Create an Agent:\n\n```python\nfrom mas.sdk.agent import Agent\nfrom mas.sdk.decorators import agent\nfrom mas.protocol import Message\nfrom mas.sdk.state import AgentState\nfrom pydantic import Field\n\n# Optional: Define custom state model\nclass MyState(AgentState):\n    counter: int = Field(default=0)\n    name: str = Field(default=\"\")\n\n@agent(\n    agent_id=\"example_agent\",\n    capabilities=[\"math\", \"storage\"],\n    metadata={\"version\": \"0.1.0\"},\n    state_model=MyState  # Optional custom state model\n)\nclass ExampleAgent(Agent):\n    async def on_message(self, message: Message) -> None:\n        # Handle incoming messages\n        print(f\"Got message: {message.payload}\")\n\n        # Update agent's state\n        await self.update_state({\n            \"counter\": 42,\n            \"name\": \"example\"\n        })\n\n        # Access current state\n        current_state = self.state\n        print(f\"Counter: {current_state.data['counter']}\")\n```\n\n3. Run the Agent:\n\n```python\nimport asyncio\nfrom mas import mas_service\n\nasync def main():\n    async with mas_service() as context:\n        agent = await ExampleAgent.build(context)\n        try:\n            while True:\n                await asyncio.sleep(1)\n        finally:\n            await agent.stop()\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n```\n\n## Key SDK Components\n\n### State Management\n\nAgents maintain immutable state with type-safe updates:\n\n```python\n# Define custom state model\nclass MyState(AgentState):\n    counter: int = Field(default=0)\n    status: str = Field(default=\"idle\")\n\n# Update state\nawait agent.update_state({\n    \"counter\": 42,\n    \"status\": \"ready\"\n})\n\n# Access state\ncurrent_state = agent.state\nprint(f\"Counter: {current_state.data['counter']}\")\n\n# Reset state to initial values\nawait agent.reset_state()\n\n# Subscribe to state changes\nasync def on_state_change(new_state: MyState) -> None:\n    print(f\"State changed: {new_state.model_dump()}\")\n\nagent.subscribe_to_state(on_state_change)\n```\n\n### Message Handling\n\nPattern matching for message types:\n\n```python\nasync def on_message(self, message: Message) -> None:\n    match message.message_type:\n        case MessageType.AGENT_MESSAGE:\n            await self.handle_agent_message(message)\n        case MessageType.DISCOVERY_RESPONSE:\n            await self.handle_discovery(message)\n```\n\n### Agent Discovery\n\nFind other agents by capabilities:\n\n```python\n# Find agents with specific capabilities\nawait agent.runtime.discover_agents(capabilities=[\"math\"])\n```\n\n### Lifecycle Hooks\n\n```python\nclass MyAgent(Agent):\n    async def on_start(self) -> None:\n        \"\"\"Called when agent starts\"\"\"\n        await self.update_state({\"status\": \"starting\"})\n\n    async def on_stop(self) -> None:\n        \"\"\"Called when agent stops\"\"\"\n        await self.cleanup_resources()\n```\n\n## Current Limitations\n\nAs this is experimental software, there are several limitations:\n\n-   No authentication/authorization system yet\n-   Limited error recovery mechanisms\n-   Message delivery is not guaranteed\n-   No persistent storage (in-memory only)\n-   APIs may change without notice\n-   Limited testing in distributed environments\n-   No proper documentation yet\n\n## Development Status\n\nThis project is under active development. Current focus areas:\n\n-   Stabilizing core APIs\n-   Improving error handling\n-   Adding authentication\n-   Adding persistent storage\n-   Documentation\n-   Testing infrastructure\n\n## Contributing\n\nThis project is in experimental phase and we welcome feedback and contributions:\n\n1. Fork the repository\n2. Create a feature branch\n3. Make your changes\n4. Run tests: `pytest`\n5. Submit a pull request\n\n## License\n\nMIT License - see LICENSE file for details\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Multi-Agent System Framework",
    "version": "0.1.14",
    "project_urls": null,
    "split_keywords": [
        "ai",
        " agent",
        " framework",
        " multi-agent"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "cf8eb32ffb6af8d67f4e62aa85a8f9c15439804df58c599f19c8eb011aa5a81d",
                "md5": "63660fe9151ca77dc12edb9dc4ddf590",
                "sha256": "288073e075ea12ce0e8f0388a7e3f3e28b18d9024d95219d41f711cc33bda947"
            },
            "downloads": -1,
            "filename": "mas_framework-0.1.14-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "63660fe9151ca77dc12edb9dc4ddf590",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 29892,
            "upload_time": "2025-01-09T21:38:28",
            "upload_time_iso_8601": "2025-01-09T21:38:28.799559Z",
            "url": "https://files.pythonhosted.org/packages/cf/8e/b32ffb6af8d67f4e62aa85a8f9c15439804df58c599f19c8eb011aa5a81d/mas_framework-0.1.14-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "f027db60d301bc4bd6fbc6523a03059fa1ab08482894fbf9abf390f1cd64620c",
                "md5": "d8c21e1a288f52faa39e2d68c766b9a7",
                "sha256": "75477925000a04232ffc31765c49d04a1754ec1ef02a8db73b69e84f1b1efcbf"
            },
            "downloads": -1,
            "filename": "mas_framework-0.1.14.tar.gz",
            "has_sig": false,
            "md5_digest": "d8c21e1a288f52faa39e2d68c766b9a7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 42271,
            "upload_time": "2025-01-09T21:38:29",
            "upload_time_iso_8601": "2025-01-09T21:38:29.955375Z",
            "url": "https://files.pythonhosted.org/packages/f0/27/db60d301bc4bd6fbc6523a03059fa1ab08482894fbf9abf390f1cd64620c/mas_framework-0.1.14.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-09 21:38:29",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "mas-framework"
}
        
Elapsed time: 2.18161s