Download README.md from JacellJamble/devops-incident-response: direct link, hf CLI and curl.
- Browser
- Download file 12.4 kB
-
https://huggingface.co/spaces/JacellJamble/devops-incident-response/resolve/main/README.md
- Command line
-
hf download hf://spaces/JacellJamble/devops-incident-response/README.md
-
curl -L -o README.md https://huggingface.co/spaces/JacellJamble/devops-incident-response/resolve/main/README.md
title: DevOps Incident Response Environment
emoji: π¨
colorFrom: red
colorTo: yellow
sdk: docker
pinned: false
license: mit
DevOps Incident Response Environment
An OpenEnv-compliant reinforcement learning environment for training AI agents in production incident response. This environment simulates a realistic microservices infrastructure where agents must diagnose and resolve production incidents.
Overview
What is this?
This environment simulates the work of a Site Reliability Engineer (SRE) responding to production incidents. Agents interact with a simulated microservices architecture, analyzing logs, metrics, and alerts to identify root causes and take remediation actions.
Why is this useful?
- Real-world applicability: Incident response is a critical skill at every tech company
- Training data scarcity: Real incident data is sensitive and rare
- Evaluation benchmark: Standardized tasks to measure AI agent capabilities
- Safe experimentation: Learn from failures without impacting production
Key Features
- Full OpenEnv spec compliance with typed Pydantic models
- 3 difficulty levels from simple OOM fixes to complex multi-factor incidents
- Realistic simulation of microservices, logs, metrics, and alerts
- Programmatic graders with deterministic 0.0-1.0 scoring
- Shaped rewards with partial progress signals
Quick Start
Installation
# Clone the repository
git clone https://huggingface.co/spaces/openenv/devops-incident-response
cd devops-incident-response
# Install dependencies
pip install -e .
Run the Server
# Start the FastAPI server
uvicorn server.app:app --host 0.0.0.0 --port 7860
Run Inference
# Set your API credentials (REQUIRED)
export API_BASE_URL="https://api-inference.huggingface.co/v1"
export MODEL_NAME="meta-llama/Meta-Llama-3-8B-Instruct"
export HF_TOKEN="your-huggingface-token"
export ENV_URL="http://localhost:7860" # or your HF Space URL
# Run the baseline agent
python inference.py
Docker
# Build from project root
docker build -f server/Dockerfile -t devops-incident-response .
# Run the container
docker run -p 7860:7860 devops-incident-response
Project Structure
devops-incident-response/
βββ __init__.py # Root exports (Action, Observation, Env)
βββ models.py # Pydantic models
βββ client.py # EnvClient for remote access
βββ inference.py # Baseline inference script
βββ openenv.yaml # OpenEnv configuration
βββ pyproject.toml # Package configuration
βββ README.md # This file
βββ outputs/ # Runtime outputs
β βββ logs/
β βββ evals/
βββ server/
βββ __init__.py
βββ app.py # FastAPI server
βββ environment.py # Main environment
βββ simulator.py # Infrastructure simulator
βββ graders.py # Task graders
βββ tasks.py # Task definitions
βββ requirements.txt # Server dependencies
βββ Dockerfile # Container definition
Environment Details
The Simulated Infrastructure
The environment simulates a typical e-commerce microservices architecture:
βββββββββββββββββββ
β API Gateway β
ββββββββββ¬βββββββββ
β
ββββββββββββββββββββββΌβββββββββββββββββββββ
β β β
βββββββ΄ββββββ ββββββββ΄βββββββ βββββββ΄ββββββ
β User β β Order β β Product β
β Service β β Service β β Service β
βββββββ¬ββββββ ββββββββ¬βββββββ βββββββ¬ββββββ
β β β
β ββββββββ΄βββββββ β
β β Payment β β
β β Service β β
β βββββββββββββββ β
β β
βββββββ΄ββββββ βββββββ΄ββββββ
β Redis β βElasticsearchβ
β Cache β βββββββββββββ
βββββββββββββ
β
βββββββ΄ββββββ βββββββββββββββ
β PostgreSQLβ β Kafka β
β DB β β β
βββββββββββββ βββββββββββββββ
Action Space
| Action | Description | Example |
|---|---|---|
query_service |
Get service status and info | query_service:order-service |
read_logs |
Read recent log entries | read_logs:user-service |
get_metrics |
Get CPU, memory, latency metrics | get_metrics:postgres-db |
get_alerts |
Get active monitoring alerts | get_alerts |
run_diagnostic |
Run diagnostic checks | run_diagnostic:redis-cache |
restart_service |
Restart a service | restart_service:order-service |
scale_service |
Scale service replicas | scale_service:api-gateway:5 |
rollback_service |
Rollback to previous version | rollback_service:payment-service |
update_config |
Update configuration | update_config:order-service:JAVA_OPTS:-Xmx1024m |
resolve_incident |
Mark incident resolved | resolve_incident |
get_runbook |
Consult a runbook | get_runbook:oom-response |
get_slo_status |
Check SLO violations | get_slo_status:order-service |
get_timeline |
View incident timeline | get_timeline |
escalate |
Escalate to next level | escalate |
Observation Space
Each observation includes:
- Incident Context: Title, severity, description, affected services, customer impact
- Visible Data: Services queried, logs read, metrics fetched, alerts active
- Last Action Result: Success/failure, error messages, returned data
- Available Services: List of all services in the infrastructure
- SLO Violations: Services currently violating SLOs
- Incident Duration: Time elapsed since incident started
- Escalation Level: Current escalation level (1-3)
Reward Structure
Rewards are shaped to guide learning:
| Component | Value | Description |
|---|---|---|
| Diagnostic actions | +0.02 | Investigating affected services |
| Correct remediation | +0.10 | Taking required fix actions |
| Successful resolution | +0.30 | Fully resolving the incident |
| Efficiency bonus | up to +0.10 | Resolving quickly |
| Runbook consultation | +0.01 | Using runbooks for guidance |
| Unnecessary actions | -0.01 | Actions not needed |
| Time pressure | -0.01/step | Penalty after 80% of max steps |
Tasks
Task 1: Memory Crisis (Easy)
Scenario: The order-service has been OOM killed during a traffic spike.
Root Cause: Java heap size too small for traffic volume.
Solution: Increase JAVA_OPTS heap size and restart the service.
Max Steps: 15
Task 2: Database Overload (Medium)
Scenario: Multiple services experiencing database connection timeouts with cascading failures.
Root Cause: PostgreSQL max connections too low, causing connection pool exhaustion across services.
Solution: Increase database connections and connection pool sizes for affected services.
Max Steps: 25
Task 3: Perfect Storm (Hard)
Scenario: Multiple alerts firing across infrastructure with several services affected.
Root Cause: Multiple concurrent issues - Redis cluster network partition causing cache failures, leading to database overload, PLUS an unrelated memory leak in product-service.
Solution: Fix Redis cluster, restart services with memory leaks, scale as needed.
Max Steps: 40
Task 4: Security Breach (Expert)
Scenario: Active credential stuffing attack detected. Suspicious login attempts, account lockouts, and traffic anomalies from specific IP ranges.
Root Cause: Credential stuffing attack from malicious IP range targeting authentication service.
Solution: Block malicious IPs at WAF, adjust lockout policies, scale auth service to handle cleanup.
Max Steps: 50
Enhanced Features
π Runbooks
Agents can consult runbooks for guidance on handling specific incident types:
# Get a specific runbook
action = "get_runbook:oom-response"
# Search runbooks by keyword
action = "get_runbook" # Lists all available runbooks
Available runbooks:
oom-response- Out of Memory incidentsdatabase-connection-pool- Connection pool issuescascading-failure- Cascading failure responsesecurity-incident- Credential attack responsecache-failure- Redis/cache issuesbad-deployment- Deployment rollback procedures
π SLO Tracking
Monitor Service Level Objectives during incidents:
- Availability SLO: Target 99.9% uptime
- Latency P99 SLO: Target < 200ms
- Error Rate SLO: Target < 1%
# Check SLO status
action = "get_slo_status:order-service"
π Incident Timeline
Track all events during incident response for post-incident review:
# Get timeline
action = "get_timeline"
π¨ Escalation
Escalate incidents to higher severity levels when needed:
# Escalate incident
action = "escalate"
API Reference
Endpoints
| Method | Endpoint | Description |
|---|---|---|
| POST | /reset |
Reset environment, get initial observation |
| POST | /step |
Take an action, get result |
| GET | /state/{session_id} |
Get full environment state |
| POST | /grade |
Grade completed episode |
| GET | /tasks |
List available tasks |
| GET | /health |
Health check |
Using the Python Client
from client import EnvClient
# Connect to server
client = EnvClient("http://localhost:7860")
# Start episode
session_id, observation = client.reset("task_easy_oom")
# Run episode
while True:
action = "get_alerts" # Your agent logic here
observation, reward, done, info = client.step(session_id, action)
if done:
break
# Get final score
result = client.grade(session_id)
print(f"Score: {result['score']}")
Grading
Each task is graded on three components:
- Diagnosis Score (30-40%): Did the agent investigate the affected services?
- Remediation Score (45-60%): Did the agent take the correct fix actions?
- Efficiency Score (10-15%): How quickly was the incident resolved?
Final scores range from 0.0 to 1.0.
Development
Running Tests
pytest tests/ -v
OpenEnv CLI
# Validate environment
openenv validate .
# Deploy to Hugging Face
openenv push --repo-id your-username/devops-incident-response
Configuration
Environment Variables
| Variable | Description | Required |
|---|---|---|
API_BASE_URL |
LLM API endpoint | Yes |
MODEL_NAME |
Model to use for inference | Yes |
HF_TOKEN |
Hugging Face / API key for LLM | Yes |
ENV_URL |
Environment server URL | No (default: http://localhost:7860) |
TASK_NAME |
Task to run | No (default: task_easy_oom) |
PORT |
Server port | No (default: 7860) |
Example .env file
API_BASE_URL=https://api-inference.huggingface.co/v1
MODEL_NAME=meta-llama/Meta-Llama-3-8B-Instruct
HF_TOKEN=hf_xxxxxxxxxxxxxxxxxxxx
ENV_URL=https://your-space.hf.space
License
MIT License - see LICENSE file.
Contributing
Contributions welcome! Please open an issue or PR.
Acknowledgments
Built for the OpenEnv Hackathon. Special thanks to Hugging Face and Meta for organizing.