Spaces:
Sleeping
Sleeping
Update README (from agent)
Browse files
README.md
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
title: Cloud Incident Response OpenEnv
|
| 3 |
emoji: π¨
|
|
@@ -14,48 +19,118 @@ tags:
|
|
| 14 |
- devops
|
| 15 |
- real-world
|
| 16 |
- agentic
|
| 17 |
-
---
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
|
| 20 |
|
| 21 |
-
|
| 22 |
|
| 23 |
-
|
| 24 |
|
| 25 |
-
##
|
| 26 |
|
| 27 |
-
|
| 28 |
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
-
|
| 36 |
|
| 37 |
-
## Tasks
|
| 38 |
|
| 39 |
-
| Task ID | Difficulty | Max Steps | What the Agent Does |
|
| 40 |
-
|---|---|---|---|
|
| 41 |
-
| `alert_classification` | Easy | 3 | Classify alert severity
|
| 42 |
-
| `root_cause_analysis` | Medium | 10 | Trace
|
| 43 |
-
| `remediation_planning` | Hard | 15 | Diagnose
|
| 44 |
|
| 45 |
-
###
|
| 46 |
|
| 47 |
-
| ID | Incident
|
| 48 |
|---|---|---|---|
|
| 49 |
-
| AC-001 | DB connection pool exhaustion |
|
| 50 |
-
| AC-002 | CDN cache invalidation storm |
|
| 51 |
-
|
|
| 52 |
-
| RCA-
|
| 53 |
-
|
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
## Action Space
|
| 57 |
|
| 58 |
-
|
|
|
|
| 59 |
```json
|
| 60 |
{"action_type": "query_logs", "parameters": {"service": "postgres-db"}}
|
| 61 |
{"action_type": "check_metrics", "parameters": {"service": "auth-service"}}
|
|
@@ -64,142 +139,246 @@ Agents trained here learn the same skills a human SRE uses: service dependency t
|
|
| 64 |
{"action_type": "check_service_status", "parameters": {"service": "payment-service"}}
|
| 65 |
```
|
| 66 |
|
| 67 |
-
|
|
|
|
| 68 |
```json
|
| 69 |
{"action_type": "restart_service", "parameters": {"service": "postgres-db"}}
|
| 70 |
-
{"action_type": "rollback_deploy", "parameters": {"service": "
|
| 71 |
-
{"action_type": "scale_service", "parameters": {"service": "image-service", "replicas": 10}}
|
| 72 |
{"action_type": "disable_feature_flag", "parameters": {"flag": "full_history_export"}}
|
| 73 |
{"action_type": "execute_runbook_step", "parameters": {"runbook_action": "restore_bgp_routes"}}
|
|
|
|
|
|
|
| 74 |
```
|
| 75 |
|
| 76 |
-
|
|
|
|
| 77 |
```json
|
| 78 |
-
{"action_type": "submit_severity", "parameters": {"severity": "P1", "service": "
|
| 79 |
{"action_type": "submit_root_cause", "parameters": {"service": "analytics-service", "failure_mode": "unbounded query OOM killing postgres-db"}}
|
| 80 |
-
{"action_type": "submit_resolution", "parameters": {"summary": "
|
| 81 |
```
|
| 82 |
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
| Field | Type | Description |
|
| 86 |
-
|---|---|---|
|
| 87 |
-
| `episode_id` | string | Unique episode UUID |
|
| 88 |
-
| `task_id` | string | Active task |
|
| 89 |
-
| `scenario_id` | string | Scenario (e.g. `AC-001`) |
|
| 90 |
-
| `step_count` / `max_steps` | int | Current step and budget |
|
| 91 |
-
| `incident_summary` | string | Plain-text incident description |
|
| 92 |
-
| `alert` | dict | Alert payload with severity, symptoms, affected services |
|
| 93 |
-
| `available_actions` | list[str] | Valid action types for this task |
|
| 94 |
-
| `queried_data` | dict | All tool responses gathered so far |
|
| 95 |
-
| `known_services` | list[str] | Exact service names to use in actions |
|
| 96 |
-
| `cumulative_reward` | float | Running reward total |
|
| 97 |
-
| `done` | bool | Episode terminal flag |
|
| 98 |
-
| `feedback` | string | Per-step feedback string |
|
| 99 |
|
| 100 |
## Reward Function
|
| 101 |
|
| 102 |
-
Dense reward shaping
|
| 103 |
|
| 104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
|---|---|
|
| 106 |
-
|
|
| 107 |
-
|
|
| 108 |
-
|
|
| 109 |
-
| Correct remediation action | +0.10 |
|
| 110 |
-
| Wrong remediation action | β0.10 |
|
| 111 |
-
| Step past halfway (non-submit) | β0.02 |
|
| 112 |
-
| Timeout without submission | β0.10 |
|
| 113 |
-
| Grader score (terminal step) | 0.0β1.0 |
|
| 114 |
|
| 115 |
-
|
| 116 |
|
| 117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
|---|---|
|
| 119 |
-
| `
|
| 120 |
-
| `
|
| 121 |
-
| `
|
|
|
|
|
|
|
| 122 |
|
| 123 |
-
##
|
| 124 |
|
| 125 |
-
|
|
| 126 |
|---|---|---|
|
| 127 |
-
|
|
| 128 |
-
|
|
| 129 |
-
|
|
| 130 |
-
|
|
| 131 |
-
|
|
| 132 |
-
|
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
##
|
| 137 |
-
|
| 138 |
-
###
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
```bash
|
| 140 |
pip install -r requirements.txt
|
| 141 |
uvicorn server.app:app --host 0.0.0.0 --port 7860
|
| 142 |
```
|
| 143 |
|
| 144 |
### Docker
|
|
|
|
| 145 |
```bash
|
| 146 |
docker build -t cloud-incident-env .
|
| 147 |
-
docker run -p 7860:7860
|
| 148 |
-
-e API_BASE_URL="https://api-inference.huggingface.co/v1" \
|
| 149 |
-
-e MODEL_NAME="meta-llama/Llama-3.1-8B-Instruct" \
|
| 150 |
-
-e HF_TOKEN="hf_your_token" \
|
| 151 |
-
cloud-incident-env
|
| 152 |
```
|
| 153 |
|
| 154 |
-
### Run
|
|
|
|
| 155 |
```bash
|
| 156 |
-
export API_BASE_URL="https://api
|
| 157 |
-
export MODEL_NAME="
|
| 158 |
-
export HF_TOKEN="
|
| 159 |
python inference.py
|
| 160 |
```
|
| 161 |
|
| 162 |
-
|
| 163 |
-
```bash
|
| 164 |
-
# Start new episode
|
| 165 |
-
curl -X POST "http://localhost:7860/reset?task_id=alert_classification&scenario_index=0"
|
| 166 |
|
| 167 |
-
#
|
| 168 |
-
curl -X POST http://localhost:7860/step \
|
| 169 |
-
-H "Content-Type: application/json" \
|
| 170 |
-
-d '{"action_type":"query_logs","parameters":{"service":"api-gateway"}}'
|
| 171 |
|
| 172 |
-
|
| 173 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
```
|
| 175 |
|
| 176 |
-
|
| 177 |
|
| 178 |
-
|
| 179 |
|
| 180 |
-
|
| 181 |
-
|---|---|---|---|
|
| 182 |
-
| `alert_classification` | ~1.00 | ~0.50 | ~0.75 |
|
| 183 |
-
| `root_cause_analysis` | ~0.45 | ~0.35 | ~0.40 |
|
| 184 |
-
| `remediation_planning` | ~0.25 | ~0.20 | ~0.23 |
|
| 185 |
-
| **overall** | | | **~0.46** |
|
| 186 |
|
| 187 |
-
|
| 188 |
|
| 189 |
-
##
|
| 190 |
|
| 191 |
-
|
| 192 |
-
.
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
βββ graders.py # Deterministic graders for all tasks
|
| 199 |
-
βββ inference.py # Baseline agent + smart fallback logic
|
| 200 |
-
βββ server/
|
| 201 |
-
βββ __init__.py
|
| 202 |
-
βββ app.py # FastAPI endpoints
|
| 203 |
-
βββ environment.py # Core OpenEnv step/reset/state logic
|
| 204 |
-
βββ models.py # Typed Pydantic models (Action, Observation, Reward)
|
| 205 |
```
|
|
|
|
| 1 |
+
|
| 2 |
+
|
| 3 |
+
## `README.md`
|
| 4 |
+
|
| 5 |
+
```markdown
|
| 6 |
---
|
| 7 |
title: Cloud Incident Response OpenEnv
|
| 8 |
emoji: π¨
|
|
|
|
| 19 |
- devops
|
| 20 |
- real-world
|
| 21 |
- agentic
|
| 22 |
+
---
|
| 23 |
+
|
| 24 |
+
# βοΈ Cloud Incident Response β OpenEnv Environment
|
| 25 |
|
| 26 |
+
An OpenEnv environment for training and evaluating AI agents on **cloud SRE incident response** β the real-world on-call workflow that engineers perform daily at every cloud company.
|
| 27 |
|
| 28 |
+
Distinct from Kubernetes operations environments: this focuses on **cross-service cascading failures** in distributed microservice architectures β OOM kills from runaway analytics queries, BGP network partitions isolating availability zones, and credential rotation bugs pushing stale secrets to production services.
|
| 29 |
|
| 30 |
+
---
|
| 31 |
|
| 32 |
+
## OpenEnv Interface
|
| 33 |
|
| 34 |
+
This environment implements the **full OpenEnv specification** with typed Pydantic models:
|
| 35 |
|
| 36 |
+
| Method | Endpoint | Input | Returns |
|
| 37 |
+
|---|---|---|---|
|
| 38 |
+
| `POST` | `/reset` | `{"task_id": "...", "scenario_index": 0}` or `{}` | `Observation` |
|
| 39 |
+
| `POST` | `/step` | `Action` JSON body | `{observation, reward, done, info}` |
|
| 40 |
+
| `GET` | `/state` | β | `EpisodeState` |
|
| 41 |
+
| `GET` | `/health` | β | `{"status": "ok"}` |
|
| 42 |
+
| `GET` | `/tasks` | β | Task list + action schemas |
|
| 43 |
+
| `GET` | `/grader` | β | Score 0.0β1.0 with breakdown |
|
| 44 |
+
| `POST` | `/baseline` | β | Run inference.py, return scores |
|
| 45 |
+
|
| 46 |
+
### Typed Models
|
| 47 |
+
|
| 48 |
+
```python
|
| 49 |
+
# Action β submitted by the agent
|
| 50 |
+
Action {
|
| 51 |
+
action_type: str, # e.g. "query_logs", "restart_service", "submit_severity"
|
| 52 |
+
parameters: {
|
| 53 |
+
service?: str, # Target service name
|
| 54 |
+
severity?: str, # P1|P2|P3|P4 (for submit_severity)
|
| 55 |
+
failure_mode?: str, # Root cause description (for submit_root_cause)
|
| 56 |
+
summary?: str, # Resolution summary (for submit_resolution)
|
| 57 |
+
flag?: str, # Feature flag name (for disable_feature_flag)
|
| 58 |
+
runbook_action?: str, # Runbook step (for execute_runbook_step)
|
| 59 |
+
target_version?: str, # Deploy version (for rollback_deploy)
|
| 60 |
+
}
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
# Observation β returned to the agent
|
| 64 |
+
Observation {
|
| 65 |
+
episode_id: str, # Unique episode UUID
|
| 66 |
+
task_id: str, # Active task
|
| 67 |
+
scenario_id: str, # Current scenario (e.g. "AC-001")
|
| 68 |
+
step_count: int, # Steps taken so far
|
| 69 |
+
max_steps: int, # Budget (3, 10, or 15)
|
| 70 |
+
incident_summary: str, # Plain-text incident description
|
| 71 |
+
alert: dict, # Alert payload: title, symptoms, error_rate, revenue_impact
|
| 72 |
+
available_actions: [str], # Valid action types for this task
|
| 73 |
+
queried_data: dict, # All evidence gathered so far
|
| 74 |
+
known_services: [str], # Valid service names for actions
|
| 75 |
+
cumulative_reward: float, # Running reward total
|
| 76 |
+
done: bool, # Episode complete flag
|
| 77 |
+
feedback: str, # Per-step reward explanation
|
| 78 |
+
last_action_error: str?, # Error from last action (null if OK)
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
# Reward β returned after each step
|
| 82 |
+
Reward {
|
| 83 |
+
score: float, # Step reward value
|
| 84 |
+
value: float, # Alias for score (backward compatibility)
|
| 85 |
+
reason: str, # Human-readable explanation
|
| 86 |
+
cumulative: float, # Running total
|
| 87 |
+
}
|
| 88 |
+
```
|
| 89 |
|
| 90 |
+
---
|
| 91 |
|
| 92 |
+
## Tasks (3 Difficulty Levels, 9 Scenarios)
|
| 93 |
|
| 94 |
+
| Task ID | Difficulty | Max Steps | Scenarios | What the Agent Does |
|
| 95 |
+
|---|---|---|---|---|
|
| 96 |
+
| `alert_classification` | π’ Easy | 3 | 3 | Classify alert severity P1βP4 from metrics and symptoms |
|
| 97 |
+
| `root_cause_analysis` | π‘ Medium | 10 | 3 | Trace failure chain across 8 services to find root cause |
|
| 98 |
+
| `remediation_planning` | π΄ Hard | 15 | 3 | Diagnose + execute multi-step remediation + document resolution |
|
| 99 |
|
| 100 |
+
### Scenario Details
|
| 101 |
|
| 102 |
+
| ID | Incident | Root Cause | Challenge |
|
| 103 |
|---|---|---|---|
|
| 104 |
+
| AC-001 | DB connection pool exhaustion | β | Clear P1: 78% errors, $12k/min |
|
| 105 |
+
| AC-002 | CDN cache invalidation storm | β | Ambiguous P2: degraded but checkout works |
|
| 106 |
+
| AC-003 | Recommendation engine errors | β | Trap P3: 45% errors but zero revenue impact |
|
| 107 |
+
| RCA-001 | Postgres OOM crash loop | analytics-service (unbounded query) | Root cause NOT in alert, 8 services to investigate |
|
| 108 |
+
| RCA-002 | Cross-AZ checkout failures | network-infra (BGP route withdrawal) | Network issue disguised as application failure |
|
| 109 |
+
| RCA-003 | DB authentication failures | config-service (stale credential rotation) | Multiple red herring deploys on other services |
|
| 110 |
+
| RP-001 | Full OOM incident | analytics-service | 6-step remediation sequence, wrong actions penalized |
|
| 111 |
+
| RP-002 | Full BGP incident | network-infra | 4-step runbook + config rollback, 8 services |
|
| 112 |
+
| RP-003 | Full credential incident | config-service | 7-step sequence, credential rotation + service restarts |
|
| 113 |
+
|
| 114 |
+
### Why This Is Genuinely Difficult
|
| 115 |
+
|
| 116 |
+
- **Medium**: Root cause service is NEVER in the alert's `affected_services`. Agent must query logs on victim services, follow breadcrumbs that name the culprit, then investigate that service. 8 known services with red herring deploys.
|
| 117 |
+
- **Hard**: Same diagnostic challenge PLUS must execute 4β7 remediation actions in logical order. Wrong actions (e.g. restarting a healthy service) carry β0.15 penalties. Resolution summary must reference specific services and actions.
|
| 118 |
+
|
| 119 |
+
### Baseline Scores
|
| 120 |
+
|
| 121 |
+
| Model | Easy | Medium | Hard | Overall |
|
| 122 |
+
|---|---|---|---|---|
|
| 123 |
+
| `llama-3.1-8b-instant` | 1.0 | 0.65 | 0.70 | 0.78 |
|
| 124 |
+
| `llama-3.3-70b-versatile` | 1.0 | 0.99 | 0.80 | 0.93 |
|
| 125 |
+
|
| 126 |
+
70B consistently outperforms 8B on medium/hard tasks, proving the environment differentiates model quality.
|
| 127 |
+
|
| 128 |
+
---
|
| 129 |
|
| 130 |
## Action Space
|
| 131 |
|
| 132 |
+
### π Diagnostic Actions (gather evidence)
|
| 133 |
+
|
| 134 |
```json
|
| 135 |
{"action_type": "query_logs", "parameters": {"service": "postgres-db"}}
|
| 136 |
{"action_type": "check_metrics", "parameters": {"service": "auth-service"}}
|
|
|
|
| 139 |
{"action_type": "check_service_status", "parameters": {"service": "payment-service"}}
|
| 140 |
```
|
| 141 |
|
| 142 |
+
### π§ Remediation Actions (fix the incident)
|
| 143 |
+
|
| 144 |
```json
|
| 145 |
{"action_type": "restart_service", "parameters": {"service": "postgres-db"}}
|
| 146 |
+
{"action_type": "rollback_deploy", "parameters": {"service": "config-service", "target_version": "previous"}}
|
|
|
|
| 147 |
{"action_type": "disable_feature_flag", "parameters": {"flag": "full_history_export"}}
|
| 148 |
{"action_type": "execute_runbook_step", "parameters": {"runbook_action": "restore_bgp_routes"}}
|
| 149 |
+
{"action_type": "scale_service", "parameters": {"service": "image-service", "replicas": 10}}
|
| 150 |
+
{"action_type": "clear_cache", "parameters": {"service": "redis-session"}}
|
| 151 |
```
|
| 152 |
|
| 153 |
+
### π Submission Actions (end episode)
|
| 154 |
+
|
| 155 |
```json
|
| 156 |
+
{"action_type": "submit_severity", "parameters": {"severity": "P1", "service": "api-gateway"}}
|
| 157 |
{"action_type": "submit_root_cause", "parameters": {"service": "analytics-service", "failure_mode": "unbounded query OOM killing postgres-db"}}
|
| 158 |
+
{"action_type": "submit_resolution", "parameters": {"summary": "3+ sentence description of what failed, what you did, and current status"}}
|
| 159 |
```
|
| 160 |
|
| 161 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
|
| 163 |
## Reward Function
|
| 164 |
|
| 165 |
+
Dense reward shaping provides signal over the **full trajectory** (not just binary end-of-episode):
|
| 166 |
|
| 167 |
+
| Signal | Reward | Description |
|
| 168 |
+
|---|---|---|
|
| 169 |
+
| Query new service | +0.03 to +0.04 | First diagnostic action on a service |
|
| 170 |
+
| Query new action type | +0.01 to +0.02 | Different diagnostic on already-queried service |
|
| 171 |
+
| Repeat same query | β0.03 to β0.04 | Same (action, service) pair again |
|
| 172 |
+
| Unknown service | β0.05 to β0.06 | Service not in known_services |
|
| 173 |
+
| Correct remediation | +0.06 | Action matches correct remediation sequence |
|
| 174 |
+
| Wrong remediation | β0.12 to β0.15 | Action in wrong_actions list (e.g. restarting healthy service) |
|
| 175 |
+
| Correct submission type | +0.02 | Using the right submit action for the task |
|
| 176 |
+
| Wrong submission type | β0.08 to β0.12 | e.g. submit_severity during remediation_planning |
|
| 177 |
+
| Past halfway (non-submit) | β0.015 to β0.04 | Per-step efficiency penalty |
|
| 178 |
+
| Timeout | β0.15 to β0.20 | No submission before max_steps |
|
| 179 |
+
| Exact repeat action | β0.04 to β0.05 | Identical action+params as a previous step |
|
| 180 |
+
| **Grader score** | **0.0β1.0** | **Added at terminal step** |
|
| 181 |
+
|
| 182 |
+
### Grading (deterministic, reproducible, 0.0β1.0)
|
| 183 |
+
|
| 184 |
+
| Task | Scoring Logic |
|
| 185 |
|---|---|
|
| 186 |
+
| `alert_classification` | 1.0 exact match Β· 0.5 adjacent (P1βP2) Β· 0.25 two-off Β· 0.0 wrong |
|
| 187 |
+
| `root_cause_analysis` | 0.6 base (correct service + failure mode) + up to 0.4 efficiency bonus |
|
| 188 |
+
| `remediation_planning` | 0.6 base + 0.3 efficiency (correct steps matched) β 0.15 penalty (wrong actions) + 0.1 summary quality |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
|
| 190 |
+
---
|
| 191 |
|
| 192 |
+
## π₯οΈ Interactive UI Walkthrough
|
| 193 |
+
|
| 194 |
+
The Gradio UI at `/` provides a visual interface for human evaluation. Here's how to use it:
|
| 195 |
+
|
| 196 |
+
### π’ Easy Task: Alert Classification
|
| 197 |
+
|
| 198 |
+
1. **Select Task**: Choose `π’ Easy β Alert Classification` from the Task dropdown
|
| 199 |
+
2. **Select Scenario**: Choose `Scenario 2` (the tricky P3 trap)
|
| 200 |
+
3. **Click** `π Reset Environment`
|
| 201 |
+
4. **Read** the observation panel β recommendation-service errors at 45%
|
| 202 |
+
5. **Investigate**: Set Action Type to `π check_metrics`, Service to `recommendation-service`, click `βΆοΈ Execute Action`
|
| 203 |
+
6. **Read evidence** β "User impact: NONE", "Revenue: unchanged", "Checkout: 100%"
|
| 204 |
+
7. **Submit**: Set Action Type to `π submit_severity`, expand `π Parameters`, set Severity to `P3 Medium`, click `βΆοΈ Execute Action`
|
| 205 |
+
8. **Grade**: Click `π Grade` β should show **1.0** for exact P3 match
|
| 206 |
+
|
| 207 |
+
### π‘ Medium Task: Root Cause Analysis
|
| 208 |
+
|
| 209 |
+
1. **Select Task**: `π‘ Medium β Root Cause Analysis`, **Scenario**: `Scenario 0`
|
| 210 |
+
2. **Click** `π Reset Environment`
|
| 211 |
+
3. **Read** the observation β postgres-db crash loop, multiple services down
|
| 212 |
+
4. **Query victim**: Action Type `π query_logs`, Service `postgres-db`, click `βΆοΈ Execute Action`
|
| 213 |
+
5. **Read evidence** β logs say *"query from analytics-service consuming all memory"*
|
| 214 |
+
6. **Follow breadcrumb**: Action Type `π query_logs`, Service `analytics-service`, click `βΆοΈ Execute Action`
|
| 215 |
+
7. **Read evidence** β "full_history_export job", "847M row scan", "no LIMIT"
|
| 216 |
+
8. **Confirm**: Action Type `π check_recent_deploys`, Service `analytics-service`, click `βΆοΈ Execute Action`
|
| 217 |
+
9. **Read evidence** β "Deploy 6h ago: cross-table JOIN without LIMIT clause"
|
| 218 |
+
10. **Submit**: Action Type `π submit_root_cause`, Service `analytics-service`, Failure Mode: `unbounded query OOM killing postgres-db`, click `βΆοΈ Execute Action`
|
| 219 |
+
11. **Grade**: Click `π Grade` β should show **0.85β1.0**
|
| 220 |
+
|
| 221 |
+
### π΄ Hard Task: Remediation Planning
|
| 222 |
+
|
| 223 |
+
1. **Select Task**: `π΄ Hard β Remediation Planning`, **Scenario**: `Scenario 0`
|
| 224 |
+
2. **Click** `π Reset Environment`
|
| 225 |
+
3. **Diagnose**: `π query_logs` on `postgres-db` β see "analytics-service" breadcrumb
|
| 226 |
+
4. **Confirm**: `π query_logs` on `analytics-service` β see "full_history_export, no LIMIT"
|
| 227 |
+
5. **Fix Step 1**: `π§ disable_feature_flag`, Flag: `full_history_export` β "job DISABLED"
|
| 228 |
+
6. **Fix Step 2**: `π§ restart_service` on `analytics-service` β "restarted β idle"
|
| 229 |
+
7. **Fix Step 3**: `π§ restart_service` on `postgres-db` β "accepting connections (12/500)"
|
| 230 |
+
8. **Fix Step 4**: `π§ restart_service` on `auth-service` β "reconnected OK"
|
| 231 |
+
9. **Fix Step 5**: `π§ restart_service` on `order-service` β "writes resuming"
|
| 232 |
+
10. **Verify**: `π§ execute_runbook_step`, Runbook Action: `verify_db_health` β "healthy"
|
| 233 |
+
11. **Submit**: `π submit_resolution`, Summary: *"The analytics-service deployed a full_history_export job with an unbounded query that OOM-killed postgres-db. We disabled the full_history_export flag, restarted analytics-service, then restarted postgres-db, auth-service, and order-service. All services recovered and postgres-db is healthy."*
|
| 234 |
+
12. **Grade**: Click `π Grade` β should show **0.85β1.0**
|
| 235 |
+
|
| 236 |
+
### UI Controls Reference
|
| 237 |
+
|
| 238 |
+
| Button | Purpose |
|
| 239 |
|---|---|
|
| 240 |
+
| `π Reset Environment` | Start a new episode |
|
| 241 |
+
| `βΆοΈ Execute Action` | Run the selected action |
|
| 242 |
+
| `π Parameters` | Expand to fill severity / failure_mode / summary / flag / runbook fields |
|
| 243 |
+
| `π Grade` | See final grader score (0.0β1.0) after episode ends |
|
| 244 |
+
| `π State` | Refresh the state panel |
|
| 245 |
|
| 246 |
+
### Common Mistakes & Penalties
|
| 247 |
|
| 248 |
+
| Mistake | Penalty | Why |
|
| 249 |
|---|---|---|
|
| 250 |
+
| Wrong submission type (e.g. `submit_severity` in hard task) | β0.12 | Each task has ONE correct submission action |
|
| 251 |
+
| Restarting a healthy service (e.g. `restart redis-session`) | β0.15 | Wrong remediation action |
|
| 252 |
+
| Querying a service not in `known_services` | β0.06 | Invalid target |
|
| 253 |
+
| Repeating the exact same action | β0.04 | Infinite loop detection |
|
| 254 |
+
| Not submitting before max steps | β0.20 | Timeout penalty |
|
| 255 |
+
| Using remediation actions in easy task | β0.08 | Not available for alert classification |
|
| 256 |
+
|
| 257 |
+
---
|
| 258 |
+
|
| 259 |
+
## API Usage
|
| 260 |
+
|
| 261 |
+
### Quick Test
|
| 262 |
+
|
| 263 |
+
```bash
|
| 264 |
+
# Reset with defaults (alert_classification, scenario 0)
|
| 265 |
+
curl -X POST http://localhost:7860/reset \
|
| 266 |
+
-H "Content-Type: application/json" -d '{}'
|
| 267 |
+
|
| 268 |
+
# Reset with specific task
|
| 269 |
+
curl -X POST http://localhost:7860/reset \
|
| 270 |
+
-H "Content-Type: application/json" \
|
| 271 |
+
-d '{"task_id": "root_cause_analysis", "scenario_index": 1}'
|
| 272 |
+
|
| 273 |
+
# Take a step
|
| 274 |
+
curl -X POST http://localhost:7860/step \
|
| 275 |
+
-H "Content-Type: application/json" \
|
| 276 |
+
-d '{"action_type": "query_logs", "parameters": {"service": "postgres-db"}}'
|
| 277 |
+
|
| 278 |
+
# Check state
|
| 279 |
+
curl http://localhost:7860/state
|
| 280 |
+
|
| 281 |
+
# Grade current episode
|
| 282 |
+
curl http://localhost:7860/grader
|
| 283 |
+
```
|
| 284 |
+
|
| 285 |
+
### Full Episode Example (Python)
|
| 286 |
+
|
| 287 |
+
```python
|
| 288 |
+
import requests
|
| 289 |
+
|
| 290 |
+
BASE = "http://localhost:7860"
|
| 291 |
+
|
| 292 |
+
# Start episode
|
| 293 |
+
obs = requests.post(f"{BASE}/reset", json={
|
| 294 |
+
"task_id": "alert_classification", "scenario_index": 0
|
| 295 |
+
}).json()
|
| 296 |
+
|
| 297 |
+
print(f"Incident: {obs['incident_summary']}")
|
| 298 |
+
print(f"Services: {obs['known_services']}")
|
| 299 |
+
|
| 300 |
+
# Investigate
|
| 301 |
+
result = requests.post(f"{BASE}/step", json={
|
| 302 |
+
"action_type": "check_metrics",
|
| 303 |
+
"parameters": {"service": obs["known_services"][0]}
|
| 304 |
+
}).json()
|
| 305 |
+
|
| 306 |
+
print(f"Reward: {result['reward']['score']:+.3f}")
|
| 307 |
+
print(f"Done: {result['done']}")
|
| 308 |
+
|
| 309 |
+
# Submit
|
| 310 |
+
result = requests.post(f"{BASE}/step", json={
|
| 311 |
+
"action_type": "submit_severity",
|
| 312 |
+
"parameters": {"severity": "P1", "service": obs["known_services"][0]}
|
| 313 |
+
}).json()
|
| 314 |
+
|
| 315 |
+
# Grade
|
| 316 |
+
grade = requests.get(f"{BASE}/grader").json()
|
| 317 |
+
print(f"Score: {grade['total']}")
|
| 318 |
+
```
|
| 319 |
+
|
| 320 |
+
---
|
| 321 |
+
|
| 322 |
+
## Setup
|
| 323 |
+
|
| 324 |
+
### Local Development
|
| 325 |
+
|
| 326 |
```bash
|
| 327 |
pip install -r requirements.txt
|
| 328 |
uvicorn server.app:app --host 0.0.0.0 --port 7860
|
| 329 |
```
|
| 330 |
|
| 331 |
### Docker
|
| 332 |
+
|
| 333 |
```bash
|
| 334 |
docker build -t cloud-incident-env .
|
| 335 |
+
docker run -p 7860:7860 cloud-incident-env
|
|
|
|
|
|
|
|
|
|
|
|
|
| 336 |
```
|
| 337 |
|
| 338 |
+
### Run Baseline Agent
|
| 339 |
+
|
| 340 |
```bash
|
| 341 |
+
export API_BASE_URL="https://api.groq.com/openai/v1"
|
| 342 |
+
export MODEL_NAME="llama-3.1-8b-instant"
|
| 343 |
+
export HF_TOKEN="gsk_your_groq_key"
|
| 344 |
python inference.py
|
| 345 |
```
|
| 346 |
|
| 347 |
+
---
|
|
|
|
|
|
|
|
|
|
| 348 |
|
| 349 |
+
## Project Structure
|
|
|
|
|
|
|
|
|
|
| 350 |
|
| 351 |
+
```
|
| 352 |
+
βββ Dockerfile # Docker build for HF Spaces
|
| 353 |
+
βββ README.md # This file
|
| 354 |
+
βββ requirements.txt # Python dependencies
|
| 355 |
+
βββ openenv.yaml # OpenEnv manifest (tasks, endpoints)
|
| 356 |
+
βββ pyproject.toml # Project metadata
|
| 357 |
+
βββ tasks.py # 9 scenarios across 3 difficulty levels
|
| 358 |
+
βββ graders.py # Deterministic graders (0.0β1.0)
|
| 359 |
+
βββ inference.py # Baseline LLM agent with fallback logic
|
| 360 |
+
βββ server/
|
| 361 |
+
βββ __init__.py
|
| 362 |
+
βββ app.py # FastAPI + Gradio endpoints
|
| 363 |
+
βββ environment.py # Core step/reset/state logic + reward shaping
|
| 364 |
+
βββ models.py # Typed Pydantic models (Action, Observation, Reward)
|
| 365 |
```
|
| 366 |
|
| 367 |
+
---
|
| 368 |
|
| 369 |
+
## Design Decisions
|
| 370 |
|
| 371 |
+
### Why Cloud Incident Response?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 372 |
|
| 373 |
+
Every cloud company employs SREs who respond to production incidents under time pressure with incomplete information. This is a universal, high-value skill that AI agents should learn. The environment simulates the exact decision loop: triage β investigate β diagnose β remediate β document.
|
| 374 |
|
| 375 |
+
### Why These Specific Incidents?
|
| 376 |
|
| 377 |
+
- **OOM kills** (RCA-001, RP-001): The most common database failure mode β a runaway query consumes all memory and crashes the DB, taking down every dependent service.
|
| 378 |
+
- **BGP partitions** (RCA-002, RP-002): Network-layer failures that look like application failures β services appear "down" but are actually healthy, just unreachable.
|
| 379 |
+
- **Credential rotation bugs** (RCA-003, RP-003): Configuration management failures that cause cascading auth failures β the DB is fine but clients have wrong passwords.
|
| 380 |
+
|
| 381 |
+
### Why Dense Rewards?
|
| 382 |
+
|
| 383 |
+
Sparse rewards (only at episode end) provide no learning signal for RL agents. Our reward function gives feedback on **every step**: positive for useful investigation, negative for wasted actions, with the terminal grader score layered on top. This enables both RL training and LLM agent evaluation.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 384 |
```
|