Spaces:
Sleeping
Sleeping
File size: 7,182 Bytes
38c2d5c 125deae | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 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 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | ---
title: Dev Environment Debugger
emoji: π
colorFrom: blue
colorTo: green
sdk: docker
app_port: 7860
pinned: false
---
# Dev Environment Debugger
An [OpenEnv](https://huggingface.co/openenv) environment where an AI agent debugs a broken multi-service development stack. The agent must read logs, inspect configurations, fix environment variables, and restart services to restore a healthy system β exactly as a senior engineer would during onboarding or an incident.
---
## Motivation
Setting up and debugging a local development environment is one of the most time-consuming tasks in software engineering. Developers routinely lose days diagnosing misconfigured ports, missing env vars, and cascading service failures. No existing agent benchmark targets this problem.
This environment fills that gap: it tests whether an agent can **reason across multiple failure signals, take stateful corrective actions, and know when the system is healthy**.
---
## Environment Description
Simulates a realistic 4-service application stack:
```
ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ
β Reverse ββββββΆβ Backend ββββββΆβ Database β
β Proxy β β API β β (Postgres) β
ββββββββββββββββ ββββββββ¬ββββββββ ββββββββββββββββ
β
ββββββββΌββββββββ
β Worker β
β Process β
ββββββββββββββββ
```
All services run **in memory** β no real Docker, no real ports. The environment is fully deterministic and self-contained.
At the start of each episode, one or more faults are injected (wrong env vars, missing config). The agent must fix them all.
---
## Observation Space
```json
{
"step": 3,
"services": {
"proxy": { "status": "healthy", "port": 80 },
"api": { "status": "error", "port": 8000 },
"database": { "status": "healthy", "port": 5432 },
"worker": { "status": "error", "port": null }
},
"last_action_result": {
"success": false,
"message": "API failed to start: cannot connect to database on port 5433"
},
"available_actions": ["read_logs", "inspect_env", "edit_env", "restart_service", "run_healthcheck", "submit"],
"done": false
}
```
---
## Action Space
| Action | Required Params | Description |
|---|---|---|
| `read_logs` | `service` | Read error logs for a service |
| `inspect_env` | `service` | View environment variables for a service |
| `edit_env` | `service`, `key`, `value` | Change an environment variable |
| `restart_service` | `service` | Restart a service after config fix |
| `run_healthcheck` | `service` | Get current health status |
| `submit` | β | Declare environment fixed, end episode |
Valid services: `api`, `worker`, `database`, `proxy`
---
## Reward Function
| Event | Reward |
|---|---|
| Read logs before fixing (correct diagnosis) | +0.05 |
| Inspect env vars | +0.02 |
| Correct env var edit (fixes a known fault) | +0.10 |
| Service transitions unhealthy β healthy | +0.30 |
| Submit with all services healthy | +0.50 |
| Restart service without fixing root cause | -0.10 |
| Redundant/invalid action | -0.05 |
| Submit while services still unhealthy | -0.30 |
| Exceed max steps (25) | -0.20 |
---
## Tasks
### Task 1 β Single Service Fault (Easy)
One service is down because `DB_PORT` is set to `5433` instead of `5432`.
**Agent must:** read API logs β inspect API env β fix `DB_PORT` β restart API β submit.
**Expected score:** ~0.85 (GPT-4o-mini)
---
### Task 2 β Multi-Fault Diagnosis (Medium)
Two independent faults:
- `DB_PORT` wrong on API service
- `WORKER_QUEUE_URL` missing on worker service
**Agent must:** identify and fix both faults independently. Partial score for fixing one.
**Expected score:** ~0.60 (GPT-4o-mini)
---
### Task 3 β Cascading Failure Debug (Hard)
`DB_PASSWORD` is wrong on the database. This causes:
- Database β auth failure (`FATAL: password authentication failed`)
- API β misleading `connection timeout` error
- Worker and Proxy β downstream failures
**Agent must:** trace root cause (database credentials) rather than patching symptoms. Misleading logs make this hard.
**Expected score:** ~0.35 (GPT-4o-mini)
---
## API Endpoints
| Method | Endpoint | Description |
|---|---|---|
| POST | `/reset?task_id=task1` | Start new episode |
| POST | `/step` | Submit action, get observation + reward |
| GET | `/state` | Current environment state |
| GET | `/tasks` | Task list and action schema |
| GET | `/grader?task_id=task1` | Score current episode |
| POST | `/baseline` | Run baseline agent on all tasks |
| GET | `/health` | Health check |
---
## Setup & Running
### Local (Python)
```bash
git clone https://github.com/your-username/dev-env-debugger
cd dev-env-debugger
pip install -r requirements.txt
python api.py
# Server starts at http://localhost:7860
```
### Docker
```bash
docker build -t dev-env-debugger .
docker run -p 7860:7860 dev-env-debugger
```
### Validate OpenEnv spec
```bash
openenv validate
```
---
## Running the Baseline
```bash
export OPENAI_API_KEY=your_key_here
# Run all tasks
python baseline.py
# Run single task
python baseline.py --task task1
# JSON output (used by /baseline endpoint)
python baseline.py --output-json
```
### Baseline Scores (GPT-4o-mini)
| Task | Difficulty | Expected Score |
|---|---|---|
| task1 | Easy | ~0.85 |
| task2 | Medium | ~0.60 |
| task3 | Hard | ~0.35 |
| **Average** | | **~0.60** |
---
## Quick API Example
```bash
# Start episode
curl -X POST "http://localhost:7860/reset?task_id=task1"
# Read logs
curl -X POST http://localhost:7860/step \
-H "Content-Type: application/json" \
-d '{"type": "read_logs", "service": "api"}'
# Fix env var
curl -X POST http://localhost:7860/step \
-H "Content-Type: application/json" \
-d '{"type": "edit_env", "service": "api", "key": "DB_PORT", "value": "5432"}'
# Restart service
curl -X POST http://localhost:7860/step \
-H "Content-Type: application/json" \
-d '{"type": "restart_service", "service": "api"}'
# Submit
curl -X POST http://localhost:7860/step \
-H "Content-Type: application/json" \
-d '{"type": "submit"}'
# Get score
curl "http://localhost:7860/grader?task_id=task1"
```
---
## Project Structure
```
dev-env-debugger/
βββ environment.py # Core simulation β state machine, fault injection, action handlers
βββ tasks.py # Task definitions and programmatic graders
βββ models.py # Pydantic models (Observation, Action, Reward, ServiceStatus)
βββ api.py # FastAPI server exposing all endpoints
βββ baseline.py # LLM baseline inference script
βββ openenv.yaml # OpenEnv metadata
βββ requirements.txt
βββ Dockerfile
βββ README.md
```
---
## License
MIT
|