SOP-001: Environment Setup
Document Control
| Property | Value |
|---|---|
| SOP ID | 001 |
| Title | Environment Setup |
| Version | 1.0 |
| Status | Active |
| Complexity | Easy |
Purpose
Install all required dependencies and configure the development environment for building self-evolving agents.
Prerequisites
- Python 3.10 or higher
- pip package manager
- Terminal/command line access
- OpenAI account with API access
Procedure Flowchart
┌─────────────────────────────────────────────────────────────────────┐
│ ENVIRONMENT SETUP FLOW │
├─────────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────┐ │
│ │ Check Python │ │
│ │ Version │ │
│ └────────┬────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────┐ ┌─────────────────┐ │
│ │ Install Core │────►│ Install Optional│ │
│ │ Dependencies │ │ Dependencies │ │
│ └────────┬────────┘ └────────┬────────┘ │
│ │ │ │
│ └───────────┬───────────┘ │
│ ▼ │
│ ┌─────────────────┐ │
│ │ Create .env │ │
│ │ File │ │
│ └────────┬────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────┐ │
│ │ Verify │ │
│ │ Installation │ │
│ └─────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────┘Step-by-Step Procedure
Step 1: Verify Python Version
bash
python --version
# Expected: Python 3.10.x or higherWARNING
Python 3.9 and below are not supported due to type hint syntax requirements.
Step 2: Create Project Directory
bash
mkdir self-evolving-agents
cd self-evolving-agentsStep 3: Create Virtual Environment (Recommended)
bash
python -m venv venv
# Windows
venv\Scripts\activate
# macOS/Linux
source venv/bin/activateStep 4: Install Core Dependencies
bash
pip install --upgrade openai openai-agents pydantic pandas python-dotenvPackage Descriptions:
| Package | Version | Purpose |
|---|---|---|
openai | Latest | OpenAI API client |
openai-agents | Latest | Agents SDK for building agents |
pydantic | Latest | Data validation for PromptVersionEntry |
pandas | Latest | Dataset handling |
python-dotenv | Latest | Environment variable management |
Step 5: Install Optional Dependencies (GEPA)
bash
pip install gepa litellm| Package | Purpose |
|---|---|
gepa | Genetic-Pareto prompt optimization |
litellm | Multi-model support for GEPA |
Step 6: Configure Environment Variables
Create .env file in project root:
bash
# .env
OPENAI_API_KEY=sk-your-api-key-hereStep 7: Create Configuration File
Create config.py:
python
import os
from dotenv import load_dotenv
load_dotenv()
# API Configuration
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
# Model Configuration
DEFAULT_MODEL = "gpt-5"
EVAL_MODEL = "gpt-4.1"
# Optimization Thresholds
LENIENT_PASS_RATIO = 0.75
LENIENT_AVERAGE_THRESHOLD = 0.85
MAX_OPTIMIZATION_RETRIES = 3Step 8: Verify Installation
Create verify_setup.py:
python
import os
from dotenv import load_dotenv
from openai import OpenAI
load_dotenv()
def verify():
# Check API key
api_key = os.getenv("OPENAI_API_KEY")
if not api_key:
print("❌ OPENAI_API_KEY not found in .env")
return False
# Test API connection
try:
client = OpenAI(api_key=api_key)
models = client.models.list()
print("✅ OpenAI API connection successful")
print(f"✅ Found {len(list(models))} available models")
return True
except Exception as e:
print(f"❌ API connection failed: {e}")
return False
if __name__ == "__main__":
verify()Run verification:
bash
python verify_setup.pyExpected Output:
✅ OpenAI API connection successful
✅ Found X available modelsVerification Checklist
- [ ] Python 3.10+ installed and verified
- [ ] Virtual environment created and activated
- [ ] Core dependencies installed (openai, openai-agents, pydantic, pandas, python-dotenv)
- [ ] Optional dependencies installed (gepa, litellm) if using GEPA
- [ ]
.envfile created with valid API key - [ ] Verification script runs successfully
Troubleshooting
Issue: ModuleNotFoundError: No module named 'openai'
Solution: Ensure virtual environment is activated and reinstall:
bash
pip install --force-reinstall openaiIssue: API key not found
Solution: Verify .env file location and format:
bash
# Check file exists
ls -la .env
# Check content (careful not to expose key)
head -c 20 .envIssue: SSL Certificate errors
Solution: Update certificates:
bash
pip install --upgrade certifi