A production-grade, AI-powered FastAPI application with sophisticated GitHub integration that automatically processes GitHub issues using intelligent parsing, advanced state management, and rich user communication.
Phase 2 Complete - This system implements an enterprise-ready Issue-Ops workflow that:
- Intelligent Issue Processing: Advanced template parsing with validation scoring and complexity estimation
- AI-Powered Analysis: Claude Code CLI integration with context-aware prompt building and result processing
- 11-State Workflow Management: Sophisticated state machine from queued → completed with automatic transitions
- Sandboxed Execution: Isolated git worktrees with comprehensive resource management
- Rich User Communication: Personalized responses, conversation memory, and real-time progress updates
- Robust Error Recovery: 12-category error classification with intelligent retry strategies
- 🧠 Intelligent GitHub Integration - Bidirectional communication via comments, labels, and state management
- 🔄 Advanced State Machine - 11-state agent workflow with automatic transitions and error recovery
- 💬 Rich User Experience - Personalized responses, conversation memory, progress bars with emojis
- 🛡️ Production-Ready Reliability - Comprehensive error handling, health monitoring, and graceful degradation
- 🔍 Smart Issue Analysis - Template parsing, task validation, and complexity estimation
- ⚡ High Performance - Configurable concurrency, resource cleanup, and optimized processing pipeline
- 🚀 FastAPI Server - High-performance async server with structured logging
- 🤖 Claude Code CLI - AI-powered code analysis with intelligent prompting
- 🔒 Git Worktree Isolation - Sandboxed processing with automatic cleanup
- 📊 Job Management - Async processing with status tracking and cancellation
- 🔐 Security - Webhook validation, input sanitization, sensitive data detection
agent/
├── .github/
│ ├── ISSUE_TEMPLATE/agent-task.yml # Structured GitHub issue forms
│ └── workflows/agent-dispatcher.yml # GitHub Actions webhook dispatch
├── src/
│ ├── api/ # FastAPI routes (health, webhooks, jobs)
│ ├── core/ # Core business logic
│ ├── models/ # Pydantic data models (github, jobs)
│ └── services/ # 20+ specialized services
│ ├── agent_state_machine.py # 11-state workflow engine
│ ├── github_client.py # 25+ GitHub API methods
│ ├── processing_orchestrator.py # Master workflow coordinator
│ ├── issue_parser.py # Intelligent template parsing
│ ├── task_validator.py # Multi-dimensional validation
│ ├── error_classifier.py # 12-category error handling
│ ├── recovery_manager.py # Automatic error recovery
│ ├── conversation_manager.py # Context-aware conversations
│ ├── progress_reporter.py # Rich progress communication
│ ├── health_monitor.py # System health monitoring
│ └── [10+ other services] # WorktreeManager, CommentAnalyzer, etc.
├── tests/ # Comprehensive test suite
├── docs/ # Phase 1&2 implementation summaries
├── scripts/ # Setup and utility scripts (GitHub labels, etc.)
├── config/ # Application configuration
├── tasks/ # Task management and communication
└── worktrees/ # Git worktree isolation (runtime)
- Python 3.9+ with pip
- Git version control
- Claude Code CLI tool installed and authenticated
- GitHub Personal Access Token with repo permissions
- GitHub CLI (optional, for label setup)
# 1. Clone and navigate
git clone <repository-url>
cd agent
# 2. Create virtual environment
python3 -m venv venv
source venv/bin/activate # Linux/Mac
# venv\Scripts\activate # Windows
# 3. Install dependencies
pip install -r requirements.txt
# 4. Environment configuration
cp .env.example .env
# Edit .env with your GitHub tokens and settings
# 5. Setup GitHub labels (optional but recommended)
./scripts/setup-github-labels.sh
# 6. Start the server
python main.py
Server runs on: http://localhost:8080
API Documentation: http://localhost:8080/docs
Essential Configuration:
# GitHub Integration
GITHUB_WEBHOOK_SECRET=your_webhook_secret_here
GITHUB_TOKEN=ghp_your_personal_access_token_here
REPO_OWNER=your-username
REPO_NAME=your-repository
# Server Configuration
PORT=8080
HOST=0.0.0.0
DEBUG=true
LOG_LEVEL=INFO
# Claude CLI Integration
CLAUDE_CODE_PATH=claude
CLAUDE_TIMEOUT=3600
# Performance Tuning
MAX_CONCURRENT_JOBS=3
JOB_TIMEOUT=7200
WORKTREE_BASE_PATH=./worktrees
1. Webhook Configuration
- Repository Settings → Webhooks → Add webhook
- Payload URL:
http://your-server:8080/webhook/github
- Content type:
application/json
- Events: Issues, Issue comments, Pull requests
- Secret: Use your
GITHUB_WEBHOOK_SECRET
2. GitHub Actions Integration
- Uses
.github/workflows/agent-dispatcher.yml
for auto-dispatch - Configure
AGENT_WEBHOOK_URL
andAGENT_WEBHOOK_SECRET
in repository secrets
3. Issue Template Integration
- Uses
.github/ISSUE_TEMPLATE/agent-task.yml
for structured issue creation - Automatically adds
agent:queued
label to new agent tasks
Endpoint | Method | Description | Response |
---|---|---|---|
/ |
GET | Welcome message and system info | JSON status |
/health |
GET | System health check | Health metrics |
/webhook/github |
POST | GitHub webhook receiver | Job creation response |
/jobs/{job_id} |
GET | Job status monitoring | Job details & progress |
/docs |
GET | Interactive API documentation | Swagger UI |
/redoc |
GET | Alternative API documentation | ReDoc UI |
graph TD
A[GitHub Issue Created] --> B[GitHub Actions Dispatch]
B --> C[Webhook Received]
C --> D[Event Router & Validation]
D --> E[Issue Parser & Task Validator]
E --> F[Agent State Machine: QUEUED]
F --> G[Job Manager: Create Background Job]
G --> H[Worktree Manager: Isolated Environment]
H --> I[Processing Orchestrator: 8-Stage Pipeline]
I --> J[Claude Code CLI Execution]
J --> K[Result Processor: Parse & Format]
K --> L[GitHub Client: Post Results]
L --> M[Progress Reporter: Update Status]
M --> N[Agent State Machine: COMPLETED]
O[Error Occurred] --> P[Error Classifier: Categorize]
P --> Q[Recovery Manager: Retry Strategy]
Q --> R[Escalation or Recovery]
State Transitions:
queued
→ validating
→ analyzing
→ in-progress
→ implementing
→ testing
→ completed
Error States:
failed
, cancelled
, escalated
, recovering
20+ Specialized Services organized in layers:
-
Orchestration Layer
ProcessingOrchestrator
- Master workflow coordinatorEventRouter
- GitHub event dispatcherAgentStateMachine
- 11-state workflow engine
-
Intelligence Layer
IssueParser
- Template parsing & validationTaskValidator
- Multi-dimensional validationCommentAnalyzer
- User intent detectionErrorClassifier
- 12-category error handling
-
Communication Layer
ConversationManager
- Context-aware conversationsResponseGenerator
- Personalized response generationProgressReporter
- Rich progress communicationGitHubClient
- 25+ specialized API methods
-
Processing Layer
WorktreeManager
- Git isolation & cleanupClaudeCodeService
- CLI execution wrapperResultProcessor
- Output parsing & formattingPromptBuilder
- Context-aware prompt construction
-
Infrastructure Layer
JobManager
- Background job lifecycleRecoveryManager
- Error recovery strategiesHealthMonitor
- System health monitoring
# Run all tests
pytest tests/
# Run specific test categories
pytest tests/unit/ # Unit tests
pytest tests/integration/ # Integration tests
# Run with coverage
pytest --cov=src tests/
# Start development server (auto-reload)
python main.py
# Start with specific configuration
DEBUG=true LOG_LEVEL=DEBUG python main.py
# Setup GitHub labels
./scripts/setup-github-labels.sh
# Verify setup
./scripts/verify-setup.sh
- Concurrent Processing: Configurable job limits with queue management
- Resource Management: Automatic cleanup and memory optimization
- Error Recovery: Exponential backoff with intelligent retry strategies
- Health Monitoring: Real-time system health with alerting thresholds
- Input Validation: Comprehensive sanitization and validation
- Git Isolation: Sandboxed worktree execution prevents cross-contamination
- Webhook Security: Cryptographic signature validation
- Sensitive Data Detection: Automatic detection and protection of secrets
- Structured Logging: JSON-formatted logs with correlation IDs
- Health Endpoints: System health monitoring with detailed metrics
- Job Tracking: Complete job lifecycle with progress visibility
- Error Classification: Intelligent error categorization and trending
Via GitHub Issue Template:
- Navigate to your repository
- Click "New Issue" → "🤖 New Agent Task"
- Fill out the structured form with task details
- Submit - automatically labeled
agent:queued
Example Issue Content:
Task Type: Code Analysis
Priority: Medium
Detailed Prompt: |
Please analyze the performance of the user authentication system
and suggest optimizations. Focus on database queries and caching strategies.
Relevant Files: src/auth/, src/models/user.py
Additional Context: We're experiencing slow login times during peak hours
GitHub Integration:
- Labels: Visual state tracking (
agent:in-progress
,agent:completed
) - Comments: Real-time progress updates with emojis and progress bars
- Notifications: Automatic GitHub notifications for state changes
API Monitoring:
# Check job status
curl http://localhost:8080/jobs/{job_id}
# System health
curl http://localhost:8080/health
- Phase 1 Summary:
docs/phase1-implementation-summary.md
- Phase 2 Summary:
docs/phase2-implementation-summary.md
- Testing Guide:
docs/testing-mode-guide.md
- GitHub Labels:
docs/github-labels.md
- Claude Code CLI Documentation
- FastAPI Documentation
- GitHub Webhooks Guide
- GitHub Actions Documentation
This project is licensed under the MIT License - see the LICENSE file for details.
- Issues: Create a GitHub issue for bugs or feature requests
- Discussions: Use GitHub Discussions for questions and community support
- Documentation: Check the
docs/
directory for detailed guides