A powerful framework for orchestrating collaborative AI agents with sophisticated reasoning, planning, and autonomous capabilities
Project description
MARSYS - Multi-Agent Reasoning Systems
A powerful framework for orchestrating collaborative AI agents with sophisticated reasoning, planning, and autonomous capabilities
๐ Documentation | ๐ Quick Start | ๐ก Examples | ๐ค Contributing
๐ข Latest News & Updates
๐ MARSYS v0.1 Beta Released! (02/12/2025)
We're excited to announce the first beta release of MARSYS with major new features:
- ๐ง Flexibility: Build any multi-agent AI system design with flexible topology definitions that adapt to your specific workflow needs.
- โก Speed: Run agents in parallel with agent pools for true concurrency. No more waiting for sequential execution when tasks can run simultaneously.
- ๐ง Smart Memory: Context management that handles complex, long-running tasks without blowing up your token budget.
- ๐ Reliability: Human-in-the-loop support for when things go wrong, with intelligent error recovery.
- ๐ Dynamic Branching: Runtime parallel execution with branch spawning and convergence.
- ๐ฅ User Interaction: Built-in human-in-the-loop support for approval workflows and error recovery.
- ๐ Enhanced Monitoring: Real-time execution tracking with StatusManager and comprehensive metrics.
- ๐ฏ Rules Engine: Flexible constraint system for timeouts, resource limits, and custom business logic.
Read the full release notes โ
๐ Key Features
Core Capabilities
- ๐ค Multi-Agent Orchestration: Coordinate complex workflows with multiple specialized agents
- โก Parallel Execution: True parallel processing with AgentPool and dynamic branch spawning
- ๐ง Flexible Topologies: 7 pre-defined patterns (hub-and-spoke, pipeline, mesh, hierarchical, star, ring, broadcast)
- ๐ฌ Conversation Management: Sophisticated memory system with retention policies
- ๐ ๏ธ Tool Integration: Seamless integration with external tools and APIs
- ๐ Error Recovery: Intelligent error handling with retry strategies and user intervention
- ๐ Error Recovery & Observability: Advanced error handling, monitoring, and execution tracking
Advanced Features
- Dynamic Convergence: Automatic detection and synchronization of parallel branches
- Nested Execution: Hierarchical branch structures with parent-child relationships
- State Management: Persist and restore execution state across sessions
- Rule-Based Control: Define execution constraints and business logic
- Multi-Model Support: Works with OpenAI, Anthropic, Google, Groq, and local models
- Browser Automation: Built-in browser agents for web interaction
- Rich Communication: Enhanced terminal output with colors and formatting
๐ Quick Start
Installation
Recommended Setup with uv (10-100x faster than pip)
Step 1: Create and activate a virtual environment
uv is the recommended package manager for MARSYS. Install it first if you haven't:
# Install uv (Unix/macOS)
curl -LsSf https://astral.sh/uv/install.sh | sh
# Or on Windows (PowerShell)
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
Create and activate your virtual environment:
# Create virtual environment with uv
uv venv
# Activate (Unix/macOS)
source .venv/bin/activate
# Activate (Windows)
.venv\Scripts\activate
# Or use uv run without explicit activation
uv run python your_script.py
Step 2: Install MARSYS
Basic installation (recommended for most users):
uv pip install marsys
With local model support (PyTorch, Transformers):
uv pip install marsys[local-models]
For production inference (vLLM, Flash Attention):
uv pip install marsys[production]
For development:
uv pip install marsys[dev]
Alternative Installation Methods
Using pip (standard method)
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # Unix/macOS
# .venv\Scripts\activate # Windows
# Install
pip install marsys
From source (recommended for development)
git clone https://github.com/rezaho/MARSYS.git
cd MARSYS
# Basic installation (core framework with API model support)
pip install -e .
# Or with optional dependencies:
pip install -e .[local-models] # Add local model support (PyTorch, Transformers)
pip install -e .[dev] # Add development tools (testing, linting, docs)
Optional dependency groups:
local-models: Install if you want to use local LLMs/VLMs (PyTorch, Transformers, PEFT, etc.)production: Install for production inference with vLLM and Flash Attentiondev: Install for development (includes testing, linting, and documentation tools)
Required: API Key Configuration
โ ๏ธ Before running any examples, configure your API keys:
MARSYS requires API keys for model providers. Choose one of these methods:
Method 1: Environment variables (recommended for production)
# Unix/macOS/Linux
export OPENAI_API_KEY="your-key-here"
export ANTHROPIC_API_KEY="your-key-here"
export GOOGLE_API_KEY="your-key-here"
export OPENROUTER_API_KEY="your-key-here"
# Windows (Command Prompt)
set OPENAI_API_KEY=your-key-here
# Windows (PowerShell)
$env:OPENAI_API_KEY="your-key-here"
Method 2: .env file (recommended for development)
# Create .env file in your project root
cat > .env << EOF
OPENAI_API_KEY=your-key-here
ANTHROPIC_API_KEY=your-key-here
GOOGLE_API_KEY=your-key-here
OPENROUTER_API_KEY=your-key-here
EOF
MARSYS automatically loads .env files using python-dotenv.
!!! warning "Security"
Never commit .env files to version control. Add .env to your .gitignore file.
Optional: Playwright Setup (Only for BrowserAgent)
โ ๏ธ Only required if you plan to use BrowserAgent for web automation
After installing the playwright package, install browser binaries:
# Install Chromium (recommended)
playwright install chromium
# Or install all browsers
playwright install
# With system dependencies (Linux)
playwright install --with-deps chromium
If you don't use BrowserAgent, you can skip this step entirely.
Basic Usage
Here's a simple two-agent collaboration using allowed_peers:
import asyncio
from marsys.agents import Agent
from marsys.models import ModelConfig
async def main():
# Create a single model configuration
model_config = ModelConfig(
type="api",
name="anthropic/claude-haiku-4.5",
provider="openrouter"
)
# Create specialized agents with allowed_peers
researcher = Agent(
model_config=model_config,
name="Researcher",
goal="Expert at finding and analyzing information",
instruction="You are a research specialist. Find and analyze information thoroughly.",
allowed_peers=["Writer"] # Can invoke Writer
)
writer = Agent(
model_config=model_config,
name="Writer",
goal="Skilled at creating clear, engaging content",
instruction="You are a skilled writer. Create clear, engaging content based on research.",
allowed_peers=[] # Cannot invoke other agents
)
# Run with automatic topology creation from allowed_peers
result = await researcher.auto_run(
task="Research the latest AI breakthroughs and write a summary",
max_steps=20,
verbosity=1 # Show progress
)
print(result)
asyncio.run(main())
Three-Agent Sequential Workflow
For more control, define the topology explicitly using Orchestra.run():
import asyncio
from marsys.coordination import Orchestra
from marsys.agents import Agent
from marsys.models import ModelConfig
async def main():
model_config = ModelConfig(
type="api",
name="anthropic/claude-haiku-4.5",
provider="openrouter"
)
# Create three specialized agents
data_collector = Agent(
model_config=model_config,
name="DataCollector",
goal="Collects and gathers relevant data",
instruction="You are a data collection specialist. Gather relevant information systematically."
)
analyzer = Agent(
model_config=model_config,
name="Analyzer",
goal="Analyzes collected data and finds patterns",
instruction="You are a data analyst. Analyze data thoroughly and identify key patterns."
)
reporter = Agent(
model_config=model_config,
name="Reporter",
goal="Creates comprehensive reports from analysis",
instruction="You are a report writer. Create clear, comprehensive reports from analysis results."
)
# Define sequential workflow
topology = {
"agents": ["DataCollector", "Analyzer", "Reporter"],
"flows": [
"DataCollector -> Analyzer",
"Analyzer -> Reporter"
]
}
# Run the workflow
result = await Orchestra.run(
task="Analyze market trends in the technology sector",
topology=topology
)
print(result.final_response)
asyncio.run(main())
๐ Documentation
Comprehensive documentation is available at https://marsys.ai
Quick Links
-
Getting Started
-
Core Concepts
-
API Reference
๐๏ธ System Architecture
MARSYS uses a sophisticated branching execution model that enables true parallel processing and dynamic workflow adaptation:
graph TD
A[Task Input] --> B[Topology Analysis]
B --> C[Branch Creation]
C --> D[Agent Execution]
D --> E{Decision Point}
E -->|Sequential| F[Next Agent]
E -->|Parallel| G[Spawn Branches]
E -->|Complete| H[Result]
G --> I[Convergence Point]
I --> J[Aggregate Results]
J --> F
F --> D
Key Components
- Orchestra: High-level coordination and workflow management
- Topology System: Defines agent relationships and allowed interactions
- Branch Executor: Manages parallel execution paths
- Validation Processor: Centralizes response parsing and validation
- Rules Engine: Enforces constraints and business logic
- State Manager: Handles persistence and recovery
- Communication Manager: Manages user interactions
Architecture documentation โ
๐ฃ๏ธ Roadmap
Q1 2025 - Performance & Scale
- Distributed Execution: Multi-machine agent coordination with message passing
- Advanced Caching: Intelligent result caching and memoization
- Stream Processing: Real-time streaming responses for long-running tasks
Q2 2025 - Intelligence & Learning
- Self-Optimizing Topologies: Automatic topology adjustment based on task patterns
- Agent Fine-tuning: In-workflow agent specialization and improvement
- Execution History Learning: Pattern recognition from historical executions
Q3 2025 - Advanced Features
- Workflow Designer UI: Visual topology builder and execution monitor
- Production Readiness: Performance optimizations and scalability improvements
- Advanced Observability: OpenTelemetry integration, detailed tracing, and analytics
๐ Use Cases
MARSYS excels in complex, multi-step workflows requiring coordination between specialized agents:
Research & Analysis
- Multi-source information gathering
- Comparative analysis across domains
- Report generation with fact-checking
Software Development
- Code generation with review cycles
- Bug analysis and fixing
- Architecture design and validation
Business Automation
- Document processing pipelines
- Customer support workflows
- Data extraction and transformation
Creative Applications
- Content generation with editing loops
- Multi-perspective storytelling
- Design iteration with feedback
๐ค Contributing
We welcome contributions from the community! MARSYS is an open-source project that thrives on collaboration.
๐ Contributor License Agreement (CLA)
Before your first contribution can be merged, you must sign our CLA. This is a one-time, automated process:
- Open a pull request
- CLA Assistant bot will comment with a link
- Click the link and sign (takes 1 minute)
- Your PR will be automatically unblocked
Why a CLA? The CLA ensures we can maintain flexible licensing while keeping MARSYS open-source:
- Enables potential dual-licensing in the future
- Protects the project's sustainability and long-term development
- Maintains licensing flexibility for the project
You retain ownership of your code and can use it elsewhere. Read the full CLA details and copyright information.
How to Contribute
- Sign the CLA (automatic on first PR - see above)
- Fork the repository and create your branch from
main - Make your changes and ensure tests pass
- Write/update tests for your changes
- Update documentation as needed
- Submit a pull request with clear description
Development Setup
# Clone the repository
git clone https://github.com/rezaho/MARSYS.git
cd MARSYS
# Install in development mode
pip install -e ".[dev]"
# Run tests
pytest tests/
# Run linting
flake8 src/
black src/ --check
Areas for Contribution
- ๐ Bug fixes and improvements
- ๐ Documentation enhancements
- ๐งช Test coverage expansion
- ๐จ New agent implementations
- ๐ Integration with external services
- ๐ Internationalization support
๐ Citation
If you use MARSYS in your research or projects, please cite:
@software{marsys2025,
author = {Hosseini, Reza},
title = {MARSYS: Multi-Agent Reasoning Systems Framework},
year = {2025},
publisher = {GitHub},
url = {https://github.com/rezaho/MARSYS}
}
Academic Paper
@article{hosseini2025marsys,
title={MARSYS: A Framework for Orchestrating Multi-Agent Reasoning Systems with Dynamic Branching and Convergence},
author={Hosseini, Reza},
journal={arXiv preprint arXiv:2025.xxxxx},
year={2025}
}
๐ก๏ธ License
MARSYS is released under the Apache License 2.0. See LICENSE for full terms.
Copyright & Ownership
Copyright ยฉ 2025 Marsys Project Original Author: rezaho (reza@marsys.ai)
Important: The copyright is held solely by the original author. Contributors grant a license to their contributions but do not transfer copyright ownership. See COPYRIGHT for details.
Contributing
By contributing to MARSYS, you agree that your contributions will be licensed under the Apache License 2.0, subject to our Contributor License Agreement. See CONTRIBUTING.md for full contribution guidelines.
๐ Acknowledgments
Special thanks to:
- The open-source community for invaluable feedback and contributions
- Model providers (OpenAI, Anthropic, Google) for their powerful APIs
- Early adopters and testers who helped shape MARSYS
๐ฎ Contact & Support
- Documentation: https://marsys.ai
- GitHub Issues: Bug reports and feature requests
- Discussions: Community forum
- Email: reza@marsys.ai
- Twitter: @marsys_ai
Built with โค๏ธ by Reza Hosseini and contributors
โญ Star us on GitHub โ it helps!
Website โข Documentation โข Examples โข Blog
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
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 marsys-0.1.2.tar.gz.
File metadata
- Download URL: marsys-0.1.2.tar.gz
- Upload date:
- Size: 1.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e7772269d88154d433b565df206040167bcf40f37d708a1afeb1c4d180567d8
|
|
| MD5 |
19c57ced21b23cb488f6891c56489b0b
|
|
| BLAKE2b-256 |
fb41590f55d3a532eff0d44e7f6f1d2564e07cac068d60e7ec87beb4f7ee8436
|
File details
Details for the file marsys-0.1.2-py3-none-any.whl.
File metadata
- Download URL: marsys-0.1.2-py3-none-any.whl
- Upload date:
- Size: 568.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15311ca56e2c762da136ff2baa0fdfbc2bb04d5f5a3271c252e399bd2ca95461
|
|
| MD5 |
e31a9c3106ef130e847f0a4868e42ed7
|
|
| BLAKE2b-256 |
4cb1c8002c066b018712af072f6183b3b94ebf5d98df711193caf4f6d25aee83
|