An intelligent DevOps agent that automatically diagnoses CI failures, proposes fixes, and validates solutions using AI-powered reasoning and tool execution.
The CodeOps Agent follows a sophisticated multi-step pipeline to diagnose and fix CI failures:
graph TD
A[CI Failure Detected] --> B[Context Retrieval]
B --> C[AI Planning & Analysis]
C --> D[Tool Execution]
D --> E[Code Patching]
E --> F[Test Execution]
F --> G{Success?}
G -->|Yes| H[Verification & Documentation]
G -->|No| I[Critic Agent Review]
I --> J[Refined Planning]
J --> D
H --> K[Slack Notification]
subgraph "Data Layer"
L[FAISS Vector Store]
M[SQLite Database]
N[GitHub Repository]
end
subgraph "AI Components"
O[OpenAI GPT-4]
P[Sentence Transformers]
Q[LangGraph Reasoning]
end
B --> L
C --> O
C --> Q
D --> N
H --> M
- Docker and Docker Compose
- Git
- OpenAI API Key
- GitHub Token (optional, for repository access)
-
Clone the repository:
git clone <repository-url> cd codeops-agent
-
Configure environment:
cp .env.example .env # Edit .env with your API keys -
Start the application:
docker compose up --build
-
Access the services:
- Dashboard: http://localhost:5173
- API: http://localhost:8000
- Health Check: http://localhost:8000/healthz
-
Backend Setup:
# Create virtual environment python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate # Install dependencies pip install -r requirements.txt pip install sentence-transformers # Run backend uvicorn backend.app.main:app --reload --port 8000
-
Frontend Setup:
cd frontend pnpm install pnpm run dev
| Variable | Description | Required | Default |
|---|---|---|---|
OPENAI_API_KEY |
OpenAI API key for AI functionality | Yes | - |
GITHUB_TOKEN |
GitHub token for repository access | No | - |
SLACK_WEBHOOK_URL |
Slack webhook for notifications | No | - |
AGENT_DRY_RUN |
Run in dry-run mode (no actual changes) | No | true |
DB_URL |
Database connection string | No | sqlite+aiosqlite:///./data/codeops.db |
The Docker setup includes:
- Backend (FastAPI): Port 8000, Python 3.11-slim
- Frontend (React): Port 5173, Node 22 with Vite
- FAISS Store: Vector database for semantic search
- Demo Repository: Mounted for testing purposes
The agent monitors CI pipelines and detects failures through webhooks or manual triggers.
- Analyzes failure logs and error messages
- Retrieves relevant code context using FAISS vector search
- Gathers repository metadata and recent changes
- Uses OpenAI GPT-4 to analyze the failure
- Generates a step-by-step fix plan
- Identifies required tools and resources
- Executes git operations (checkout, branch, commit)
- Runs tests to validate fixes
- Applies code patches and modifications
- Re-runs tests to confirm fixes
- Validates solution completeness
- Documents changes and rationale
- Sends results to Slack (if configured)
- Updates run logs and metrics
- Provides detailed trace information
| Endpoint | Method | Description |
|---|---|---|
/healthz |
GET | Health check |
/metrics |
GET | System metrics |
/agent/run/{run_id} |
POST | Trigger agent pipeline |
/runs |
GET | List all runs |
/runs/{run_id} |
GET | Get specific run details |
# Trigger agent for run ID 1
curl -X POST http://localhost:8000/agent/run/1
# Get system metrics
curl http://localhost:8000/metrics
# List all runs
curl http://localhost:8000/runsThe dashboard provides real-time insights into:
- Success Rate: Percentage of successful fixes
- Average Latency: Time to complete fixes
- Confidence Trends: AI confidence scores over time
- Run Traces: Detailed execution logs
{
"total_runs": 45,
"successful_runs": 38,
"success_rate": 0.844,
"average_latency": 2.3,
"confidence_trend": [0.85, 0.87, 0.89, 0.91]
}# Backend tests
python -m pytest test_*.py
# Integration tests
python test_endpoints.py
python test_github_integration.py
python test_slack_integration.pyThe included demo-repo contains a simple calculator with intentional bugs for testing:
# Run demo tests
cd demo-repo
python test_calculator.py-
Docker Build Fails:
- Ensure Docker is running
- Check available disk space
- Verify network connectivity
-
API Connection Issues:
- Check if backend is running on port 8000
- Verify CORS settings in
backend/app/main.py - Check firewall settings
-
FAISS Index Issues:
- Ensure
faiss_index.binandfaiss_index_texts.pklexist - Check file permissions
- Rebuild index if corrupted
- Ensure
-
Environment Variables:
- Verify
.envfile exists and is properly formatted - Check API key validity
- Ensure no trailing spaces in values
- Verify
# View Docker logs
docker compose logs -f backend
docker compose logs -f frontend
# View specific service logs
docker compose logs backend# Build and tag images
docker build -f Dockerfile.backend -t codeops-agent/backend:latest .
docker build -f Dockerfile.frontend -t codeops-agent/frontend:latest .
# Push to registry
docker push codeops-agent/backend:latest
docker push codeops-agent/frontend:latest- Use production-grade database (PostgreSQL)
- Configure proper secrets management
- Set up monitoring and alerting
- Enable HTTPS with proper certificates
- Configure backup strategies for FAISS index
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
Ready to automate your DevOps workflow? Start with docker compose up and watch the magic happen! π