Thanks to visit codestin.com
Credit goes to github.com

Skip to content

philipbankier/autonomous-lab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

84 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Autonomous Lab - Multi-Agent System

A production-ready multi-agent system for autonomous software development with comprehensive monitoring, error handling, and configuration management.

Features

Core System

  • Mastra Agent Framework: Modern agent orchestration with built-in LLM call tracking
  • Google Gemini Integration: Advanced AI models via LiteLLM for better performance
  • Browser Automation: Stagehand integration for web-based tasks
  • Fail-Fast Error Handling: Immediate quota protection with comprehensive reporting
  • Budget Management: Real-time budget tracking and quota monitoring
  • Circuit Breaker: Automatic API protection with configurable thresholds
  • Configuration Management: Flexible configuration with validation and fallbacks

Mastra Integration (Phase 1 Complete ✅)

  • Supervisor Agent: Manages Codex CLI worker instances with scalability (1-2 workers)
  • Plan Management: Creates, stores, and executes structured plans with steps
  • Task Coordination: Generates tasks for Codex CLI workers with proper context
  • Memory System: Persistent storage using Mastra's SQLite database
  • Configuration Integration: Unified configuration system with environment variable support

Mastra Web GUI (Phase 3 Complete ✅)

  • Real-time Agent Monitoring: Live agent activity and performance tracking
  • LLM Call Analytics: Detailed tracking of all AI model interactions
  • Memory Management: Persistent agent memory with SQLite database
  • Tool Integration: Visual tool usage and browser automation monitoring

CLI Tools

  • Project Management: Create, manage, and monitor projects
  • Configuration: Validate, generate, and manage configurations
  • Error Reporting: Comprehensive error analysis and recommendations
  • System Health: Real-time system health monitoring
  • Quota Management: Real-time quota and budget status monitoring
  • Fail-Fast Control: Enable/disable fail-fast behavior for quota protection
  • Migration: Automatic project migration and rollback
  • Dashboard Integration: Access to real Mastra Playground for monitoring
  • Memory Management: Memory system status, cleanup, and monitoring
  • Unified Error Handling: Python-Mastra integrated error reporting

Quick Start

Prerequisites

  • Python 3.11+
  • Node.js 18+ (for adapters)
  • Git
  • Google AI API key (for Gemini models)
  • Browserbase account (for browser automation)

Installation

  1. Clone the repository:
git clone <repository-url>
cd autonomous-lab
  1. Set up the environment:
# Install Python dependencies
make install

# Install Node.js dependencies for adapters
cd adapters && npm install && cd ..

# (Optional) Create a .env for non-sensitive overrides
cp .env.example .env
# The credential vault replaces most secrets stored in .env
  1. Configure your API keys:
# Initialise the encrypted credential vault (writes to logs/credentials/)
swarm vault init

# Store required secrets (hidden prompts will confirm values)
swarm vault set google_ai_api_key
swarm vault set browserbase_api_key
swarm vault set browserbase_project_id

# View stored entries (metadata only) and recent audit events
swarm vault list
swarm vault audit

# The system automatically loads vault secrets into the environment at runtime.
# You can still define fallback values in .env, but vault entries take precedence.
  1. Start the system:
# Start the enhanced Python service
swarm run

# Open the Mastra Playground dashboard
swarm dashboard

# Or use the Makefile for convenience
make dashboard

Basic Usage

  1. Create a new project:
swarm create <project-name>
  1. Monitor system health:
swarm system-health
  1. Generate error report:
swarm error-report
  1. Validate configuration:
swarm config-validate
  1. Monitor quota and budget status:
swarm quota-status
swarm budget-status
  1. Enable fail-fast mode for quota protection:
swarm fail-fast --enable
  1. Run golden-path smoke + lint verification:
swarm smoke
# or skip lint to iterate faster
swarm smoke --lint false
# pass --skip-browser-check when Stagehand/Browserbase are not configured yet
swarm smoke --skip-browser-check
  1. Reset queues before reruns:
swarm cleanup
# archives stale artifacts to logs/archives/queue-<timestamp>/
  1. Access the Mastra Playground dashboard:
swarm dashboard
  1. Check memory system status:
swarm memory-status
  1. View unified error reports:
swarm unified-error-report

Mastra Playground Integration

The system now integrates with the real Mastra Playground for comprehensive agent monitoring and management.

Features

  • Real-time Agent Monitoring: Live agent activity and performance tracking
  • Tool Execution: Direct execution of Codex CLI, Browser, and FFmpeg tools
  • Memory Management: Visual memory system monitoring and management
  • Error Handling: Unified error reporting and system health monitoring
  • LLM Analytics: Detailed tracking of all AI model interactions

Accessing the Playground

# Basic dashboard access
swarm dashboard

# Auto-start the Playground
swarm dashboard --auto-start

# Open in browser automatically
swarm dashboard --open-browser

# Full experience (auto-start + open browser)
swarm dashboard --auto-start --open-browser

System Integration

  • Enhanced Python Service: HTTP API bridge at http://localhost:8000
  • Memory System: Persistent SQLite database with agent-specific settings
  • Error Handling: Unified Python-Mastra error reporting system
  • Tool Integration: Seamless execution of Python tools via Mastra agents

Makefile Convenience

# Basic dashboard
make dashboard

# Auto-start Playground
make dashboard-auto

# Open in browser
make dashboard-open

# Full experience
make dashboard-full

Fail-Fast Error Handling

The system includes comprehensive fail-fast error handling to prevent quota exhaustion and provide immediate feedback on API issues.

Key Features

  • Immediate Quota Protection: System stops immediately when quota is exceeded
  • Enhanced Quota Detection: Detects all quota-related error patterns
  • Circuit Breaker: Automatic API protection with configurable thresholds
  • Budget Integration: Real-time budget tracking and quota monitoring
  • Loud Error Reporting: Prominent visual warnings for quota issues
  • Graceful Shutdown: Automatic shutdown when budget thresholds are exceeded

Configuration

Enable fail-fast behavior in swarm.yaml:

codex:
  fail_fast: true  # Enable fail-fast behavior
  quota_aware: true  # Enable quota-aware error handling
  aggressive_quota_detection: true  # Use enhanced quota detection

  # Circuit breaker configuration
  circuit_breaker_failure_threshold: 2
  circuit_breaker_recovery_timeout: 60
  circuit_breaker_quota_failure_threshold: 1
  circuit_breaker_quota_recovery_timeout: 300

CLI Commands

# Check quota and budget status
swarm quota-status
swarm budget-status

# Enable/disable fail-fast mode
swarm fail-fast --enable
swarm fail-fast --disable
swarm fail-fast --show-status

# Monitor system health
swarm status  # Shows budget and circuit breaker status

Troubleshooting Quota Issues

  1. Check quota status:

    swarm quota-status
  2. Review budget spending:

    swarm budget-status
  3. Enable fail-fast mode:

    swarm fail-fast --enable
  4. Monitor system health:

    swarm status

Configuration

The system uses a flexible configuration system with multiple validation levels:

  • Strict: All options must be explicitly defined
  • Moderate: Some options can use defaults
  • Lenient: Minimal configuration required

Example configuration (swarm.yaml):

project:
  name: "my-project"
  description: "Project description"

agents:
  max_workers: 4
  timeout: 300

monitoring:
  enabled: true
  metrics_interval: 60

error_handling:
  fail_fast: true
  log_level: "INFO"

Development

Running Tests

make test

Running Linting

make lint

Building

make build

Architecture

The system is built with a modern modular architecture:

  • Mastra Core: Agent framework with built-in LLM call tracking and memory management
  • Google Gemini: Advanced AI models via LiteLLM for better performance and cost efficiency
  • Stagehand: Browser automation for web-based tasks and interactions
  • SQLite: High-performance database for agent memory and task persistence
  • CLI: Command-line interface for system management
  • Web GUI: Mastra's built-in web interface for monitoring and management (Phase 3)

Implementation Status

✅ Phase 1: Mastra Foundation (Complete)

  • Phase 1.1: Mastra Dependencies Added
  • Phase 1.2: Mastra Core Structure Created
  • Phase 1.3: Mastra Supervisor Agent Created
  • Phase 1.4: Configuration System Integrated

✅ Phase 2: Tool Integration (Complete)

  • Phase 2.1: Creating Mastra Tools
  • Phase 2.2: Migrating Task Queue System
  • Phase 2.3: Integrating Fail-Fast Logic

✅ Phase 3: Dashboard Migration (Complete)

  • Phase 3.1: Remove FastAPI Dashboard
  • Phase 3.2: Configure Mastra Web GUI
  • Phase 3.3: Update CLI Commands

✅ Phase 4: Testing & Documentation (Complete)

  • Phase 4.1: Browser Automation Integration
  • Phase 4.2: End-to-End Testing
  • Phase 4.3: Documentation and Cleanup

Contributing

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

License

[License information]

Support

For support and questions:

  • Create an issue in the repository
  • Check the documentation in the docs/ directory
  • Review the implementation plan in IMPLEMENTATION_PLAN.md

About

Experimental Agent that builds software projects using Codex CLI as worker agents

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published