A distributed system for coordinating AI agents using AgentLite, designed to run on Heroku with CPU-optimized ML processing.
- Features
- System Architecture
- Local Development
- Deployment
- Configuration
- Usage
- Monitoring
- Troubleshooting
- Distributed Task Processing: Coordinate multiple agents across worker processes
- CPU-Optimized: Designed for CPU-only environments like Heroku
- Flexible Agent Integration: Easy integration with existing AgentLite agents
- State Management: Redis-based state synchronization
- Health Monitoring: Comprehensive system health tracking
- Metrics Collection: Prometheus integration for metrics
graph TD
C[Coordinator] --> Redis[(Redis)]
C --> W1[Worker 1]
C --> W2[Worker 2]
W1 --> A1[Agent 1]
W1 --> A2[Agent 2]
W2 --> A3[Agent 3]
Redis --> W1
Redis --> W2
- Python 3.8+
- Redis server
- virtualenv or conda
- Clone the repository:
git clone https://github.com/yourusername/agent-coordinator.git
cd agent-coordinator
- Create and activate virtual environment:
python -m venv venv
source venv/bin/activate # Linux/Mac
# or
.\venv\Scripts\activate # Windows
- Install dependencies:
pip install -e ".[dev]"
- Set up environment variables:
cp .env.example .env
# Edit .env with your configuration
- Start Redis:
docker run --name redis -p 6379:6379 -d redis:alpine
# or use your local Redis installation
- Run development server:
python -m coordinator.core.coordinator
# Run all tests
pytest
# Run with coverage
pytest --cov=coordinator tests/
# Run specific test file
pytest tests/test_worker.py
- Install Heroku CLI:
# macOS
brew tap heroku/brew && brew install heroku
# Linux
curl https://cli-assets.heroku.com/install.sh | sh
# Windows
# Download installer from Heroku website
- Login to Heroku:
heroku login
- Create Heroku apps:
# Create coordinator app
heroku create your-coordinator-app
# Create worker app
heroku create your-worker-app
# Add Redis
heroku addons:create heroku-redis:premium-0 --app your-coordinator-app
- Configure apps:
# Set environment variables
heroku config:set ENVIRONMENT=production --app your-coordinator-app
heroku config:set REDIS_URL=$(heroku config:get REDIS_URL --app your-coordinator-app) --app your-worker-app
# Additional configuration
heroku config:set MAX_WORKERS=2 --app your-worker-app
heroku config:set WORKER_CONCURRENCY=2 --app your-worker-app
- Deploy:
# Deploy coordinator
git push heroku main:main --app your-coordinator-app
# Deploy worker
git push heroku main:main --app your-worker-app
- Scale workers:
heroku ps:scale worker=2 --app your-worker-app
coordinator: python -m coordinator.core.coordinator
worker: python -m coordinator.workers.worker
-
Coordinator: Standard-2x dyno recommended
heroku ps:type standard-2x --app your-coordinator-app
-
Worker: Standard-2x dyno recommended for ML tasks
heroku ps:type standard-2x --app your-worker-app
Monitor memory usage and adjust dyno sizes accordingly:
heroku metrics:web --app your-coordinator-app
heroku metrics:worker --app your-worker-app
# Core Settings
ENVIRONMENT=development
MAX_WORKERS=2
WORKER_CONCURRENCY=2
# Redis Configuration
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=
REDIS_SSL=False
# Worker Configuration
MAX_CONCURRENT_TASKS=3
TASK_TIMEOUT=300
RETRY_ATTEMPTS=3
RETRY_DELAY=5
# Agent Configuration
DEFAULT_LLM=gpt-4
MAX_TOKENS=2000
TEMPERATURE=0.7
The system is configured for CPU-only operation on Heroku:
# TensorFlow CPU Configuration
import tensorflow as tf
tf.config.set_visible_devices([], 'GPU')
# PyTorch CPU Configuration
import torch
torch.set_num_threads(4)
Access health endpoints:
# Coordinator health
curl https://your-coordinator-app.herokuapp.com/health
# Worker health
curl https://your-worker-app.herokuapp.com/health
Prometheus metrics are available at:
# Coordinator metrics
curl https://your-coordinator-app.herokuapp.com/metrics
# Worker metrics
curl https://your-worker-app.herokuapp.com/metrics
View logs:
# Coordinator logs
heroku logs --tail --app your-coordinator-app
# Worker logs
heroku logs --tail --app your-worker-app
-
Worker Connection Issues
# Check Redis connection heroku redis:info --app your-coordinator-app # Restart workers heroku ps:restart worker --app your-worker-app
-
Memory Issues
# Check memory usage heroku ps:metrics --app your-worker-app # Restart if needed heroku ps:restart --app your-worker-app
-
Task Processing Issues
- Check worker logs
- Verify Redis connection
- Check agent configurations
For issues and support:
- Check the Issues page
- Create a new issue with:
- System configuration
- Error logs
- Steps to reproduce
MIT License - see LICENSE for details