Skip to content

koate-kpai/ai-agent-engineer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Multi-Agent Schedule Optimizer

CI Python 3.11+ License: MIT

A production-grade multi-agent system where specialised AI agents collaborate to analyse, risk-assess, and optimise complex project schedules. Built with LangGraph-inspired architecture, Claude API integration, enterprise resilience patterns, and zero-dependency deterministic fallbacks.


The Problem

Project schedules are complex dependency networks. Finding the critical path, detecting circular logic, identifying risk bottlenecks, and recommending optimisations requires deep domain expertise and meticulous analysis. Most scheduling tools provide raw data reports β€” they don't reason about the schedule the way an expert planner would.

The Solution

This system deploys three specialised AI agents that collaborate like a team of expert planners:

Agent Role Responsibility
🧠 Scheduler Agent Structural Analyst Computes critical path, detects circular dependencies, validates logic ties
⚠️ Risk Agent Risk Assessor Identifies bottlenecks, near-critical activities, and anomaly patterns
πŸ“ˆ Optimiser Agent Improvement Advisor Generates actionable recommendations to compress schedule and reduce risk

Each agent runs as an independent node with its own state, memory, and tool access β€” orchestrated by a supervisor that manages routing, error recovery, and result aggregation.


Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    ORCHESTRATOR (Supervisor)                  β”‚
β”‚  Routes messages Β· Manages state Β· Handles errors Β· Aggregates β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚                      β”‚                      β”‚
       β–Ό                      β–Ό                      β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  SCHEDULER   β”‚    β”‚     RISK     β”‚    β”‚  OPTIMISER   β”‚
β”‚    AGENT     β”‚    β”‚    AGENT     β”‚    β”‚    AGENT     β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€    β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€    β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ β€’ CPM calc   β”‚    β”‚ β€’ Bottleneck β”‚    β”‚ β€’ Schedule   β”‚
β”‚ β€’ Topo sort  β”‚    β”‚   detection  β”‚    β”‚   compressionβ”‚
β”‚ β€’ Cycle detectβ”‚   β”‚ β€’ Float      β”‚    β”‚ β€’ Resource   β”‚
β”‚ β€’ Float calc β”‚    β”‚   analysis   β”‚    β”‚   levelling  β”‚
β”‚ β€’ Forward/   β”‚    β”‚ β€’ Anomaly    β”‚    β”‚ β€’ Risk       β”‚
β”‚   backward   β”‚    β”‚   scanning   β”‚    β”‚   mitigation β”‚
β”‚   pass       β”‚    β”‚              β”‚    β”‚              β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚                   β”‚                   β”‚
       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚   Structured Report  β”‚
              β”‚   (JSON + Human)     β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key Design Decisions

Decision Rationale
Deterministic-first architecture Core CPM analysis runs without LLM dependency β€” schedule logic is always correct
LLM augmentation on top Claude API enriches analysis with natural language reasoning when available
Graceful degradation Every agent has a fallback β€” the system works even without API keys
Pydantic validation All data passes through strict schemas β€” no silent failures
Circuit breaker pattern Protects against cascading API failures with auto-recovery

Tech Stack

Layer Technology
Language Python 3.11+ (typed, async-capable)
Data Models Pydantic v2 β€” strict validation, JSON serialisation
LLM Integration Anthropic Claude (optional, with tool-use support)
Resilience Custom retry, circuit breaker, fallback handler
Testing pytest β€” unit + integration tests
Containerisation Docker + docker-compose
CI/CD GitHub Actions β€” lint, test, verify on every push

Quick Start

Prerequisites

  • Python 3.11+
  • (Optional) Anthropic API key for LLM-enriched analysis

Installation

# Clone the repository
git clone https://github.com/koate-kpai/ai-agent-engineer.git
cd ai-agent-engineer

# Install dependencies
pip install -r requirements.txt

# Install package in development mode
pip install -e .

Usage

# Generate a sample schedule and run analysis
python -m src.main --generate-sample
python -m src.main data/sample_schedule.csv

# Run with Claude LLM enrichment (requires ANTHROPIC_API_KEY)
export ANTHROPIC_API_KEY="sk-ant-..."
python -m src.main data/sample_schedule.csv --log-level INFO

# JSON output for programmatic consumption
python -m src.main data/sample_schedule.csv --json

# Docker
docker compose up

Sample Output

============================================================
  SCHEDULE ANALYSIS REPORT: sample_schedule
============================================================

  Total Activities: 10
  Critical Path Duration: 62 days
  Critical Path: A1000 -> A1010 -> A1020 -> A1040 -> A1050 -> A1060 -> A1070

  [SCHEDULER AGENT]
      Critical path validated β€” no circular dependencies detected.

  [RISK AGENT]
      Bottleneck identified: A1020 (System Design) β€” float = 0, on critical path.

  [OPTIMISER AGENT]
      1. Fast-track A1030 (Data Migration) to run parallel with A1020
      2. Add resource buffer to A1040 (Dev Sprint 1) β€” highest cost activity

Project Structure

ai-agent-engineer/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ main.py              # CLI entry point
β”‚   β”œβ”€β”€ schedule.py          # Pydantic data models
β”‚   β”œβ”€β”€ analyzer.py          # Deterministic CPM schedule analysis
β”‚   β”œβ”€β”€ agent.py             # Multi-agent orchestration system
β”‚   β”œβ”€β”€ llm_client.py        # Claude API integration
β”‚   β”œβ”€β”€ resilience.py        # Retry, circuit breaker, fallback
β”‚   └── logging_config.py    # Structured logging setup
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ test_schedule.py     # Model validation tests
β”‚   β”œβ”€β”€ test_analyzer.py     # CPM logic tests
β”‚   β”œβ”€β”€ test_agent.py        # Agent orchestration tests
β”‚   └── test_resilience.py   # Resilience pattern tests
β”œβ”€β”€ data/
β”‚   └── sample_schedule.csv  # Sample project schedule
β”œβ”€β”€ config/
β”‚   └── config.yaml          # Application configuration
β”œβ”€β”€ .github/workflows/ci.yml # CI pipeline
β”œβ”€β”€ Dockerfile               # Container definition
β”œβ”€β”€ docker-compose.yml       # Container orchestration
β”œβ”€β”€ requirements.txt         # Python dependencies
β”œβ”€β”€ pyproject.toml           # Project metadata
└── README.md                # You are here

Resilience Patterns

This system implements production-grade resilience patterns:

Pattern Implementation What It Prevents
Retry with backoff @retry(max_attempts=3, backoff_factor=2.0) Transient API failures
Circuit breaker CircuitBreaker(failure_threshold=5) Cascading failures β€” opens after 5 errors, auto-recovers after 30s
Fallback handler @FallbackHandler(fallback_func=...) Every agent node has a degradation path
Graceful degradation LLM enrichment is optional β€” core analysis always works Zero API dependency for basic functionality

Testing

# Run all tests
python -m pytest tests/ -v

# Run with coverage
pip install pytest-cov
python -m pytest tests/ --cov=src --cov-report=term-missing

Current test coverage:

  • Schedule models β€” creation, validation, topological ordering
  • CPM analysis β€” forward pass, backward pass, critical path, cycle detection
  • Agent orchestration β€” multi-agent run, output aggregation, error recovery
  • Resilience patterns β€” retry logic, circuit breaker states, fallback execution

Why This Project Matters for AI Agent Engineer Roles

This project demonstrates exactly what the role demands:

  1. Agentic workflow design β€” Multi-agent system with delegation, state management, and result aggregation
  2. LLM integration β€” Claude API with tool-use for structured data analysis
  3. System resilience β€” Production-grade error handling, retries, circuit breakers
  4. Domain expertise applied β€” 20 years of scheduling logic built into deterministic CPM engine
  5. Production engineering β€” Type hints, Pydantic validation, Docker, CI/CD, comprehensive tests

About the Author

George Kpai, PMP, PRINCE2

20 years building complex dependency networks and quantitative logic systems for Β£1.2B+ infrastructure programmes. Now pivoting into AI engineering β€” combining deep domain expertise with production-grade Python and modern AI agent frameworks.


License

MIT

About

A production-grade multi-agent system where specialised AI agents collaborate to analyse, risk-assess, and optimise complex project schedules. Built with LangGraph-inspired architecture, Claude API integration, enterprise resilience patterns, and zero-dependency deterministic fallbacks.

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors