File size: 8,643 Bytes
cda147c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3d87f50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cda147c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
title: ConfigDebugEnv
colorFrom: red
colorTo: yellow
sdk: docker
app_port: 7860
tags:
  - openenv
  - devops
  - configuration
  - debugging
  - reinforcement-learning
  - multi-task-rl
pinned: false
---

# ConfigDebugEnv: Multi-Task RL Environment for Configuration Debugging

> **Challenge**: Train AI agents to autonomously debug broken configuration files across 7 real-world DevOps formats. This is a **multi-step sequential decision-making problem** requiring iterative reasoning and progressive understanding.

## Why This Matters

**The Problem**: Configuration errors cause ~40% of production incidents and are among the hardest to debug manually because they require domain expertise across multiple technologies (JSON, YAML, Docker, Kubernetes, nginx, etc.).

**Why RL?**: Static rule-based fixes fail because:
- Bugs interact (fixing one reveals another)
- Context matters (nginx syntax differs from Kubernetes)
- Validation is semantic (type checker would pass some errors)

**ConfigDebugEnv's Solution**: Train agents with **partial rewards** to discover multi-step fixes:
- Agent attempts fix → gets 0.4 reward + error guidance
- Agent iterates → gets 0.7 reward + next error guidance
- Agent completes → gets 1.0 reward + advances to next task

This mirrors real-world debugging where solutions emerge through iteration, not revelation.

---

## Environment Design

### Action Space
```
ConfigDebugAction.fixed_config: str  # Corrected configuration
```

### Observation Space
```
{
  "broken_config": str,           # Current broken config
  "file_type": str,               # Format: json, yaml, dockerfile, etc
  "error_message": str,           # Specific guidance (e.g., "replicas must be int")
  "task_id": str,                 # Current task ID
  "task_description": str,        # Human-readable task
  "difficulty": str,              # easy, medium, hard, very_hard
  "num_bugs": int,                # Total bugs in this config
  "bugs_found_so_far": int,       # Bugs fixed in this attempt
  "previous_reward": float,       # Last reward: [0.0, 1.0]
}
```

### Reward Structure (Sequential Decision Making)

Each task has **3 progressive levels**:

| Level | Example (Kubernetes) | Reward | Guides Next Attempt |
|-------|----------------------|--------|---------------------|
| L1    | Fix replicas type    | 0.4    | "containerPort must be int" |
| L2    | Fix port type too    | 0.7    | "cpu must include unit (m)" |
| L3    | Fix all bugs         | 1.0    | ✅ Task complete, advance |

**Why this works**: Agents learn to read error messages, make targeted fixes, and build on partial success—exactly like human debugging.

**⚠️ Important**: Hard tasks (Kubernetes, Nginx) **require sequential reasoning and cannot be solved in a single step**. Perfect first-attempt solutions will not occur; agents must iterate based on error guidance.

---

## The 7 Tasks (Progressive Complexity)

### Benchmark Quality Design
Each task is carefully crafted with **realistic, interdependent bugs** that require progressive debugging:

| Task | Format | Difficulty | Bugs | Description | Requires Multi-Step Fix? |
|------|--------|------------|------|-------------|------------------------|
| **task1_json** | JSON | Medium | 3 | Microservice config: missing comma, env structure bug, volumes structure bug | ✓ Yes |
| **task2_yaml** | YAML | Medium | 3 | CI/CD pipeline: indentation error, env array→object, missing job timeouts | ✓ Yes |
| **task3_dockerfile** | Dockerfile | Medium | 3 | Multi-stage build: base image, build args, runtime setup | ✓ Progressive |
| **task4_compose** | Docker-Compose | Medium | 4 | Service mesh: compose syntax, volumes, service networking | ✓ Progressive |
| **task5_k8s** | Kubernetes | Hard | 3 | Deployment manifest: type errors, missing fields, configuration validation | ✓ Yes |
| **task6_github_actions** | GitHub Actions | Hard | 5 | Workflow automation: YAML syntax, job dependencies, environment configuration | ✓ Yes |
| **task7_nginx** | Nginx config | Very Hard | 3 | Reverse proxy: syntax (semicolons), protocol prefix, routing headers | ✓ Yes |

### Grading Philosophy
Graders use **progressive, dependency-aware validation**:
- **Level 1**: Syntax pass/fail (foundational)
- **Level 2**: Structure validation (builds on syntax pass)
- **Level 3**: Semantic correctness (builds on structure pass)

Rewards are **emergent from fixes**, not hand-tuned. Example for task1_json:
- Syntax error only: 0.05 (penalty state)
- Syntax fixed: +0.3 → 0.35
- Structure fixed: +0.25 → 0.60
- All semantics fixed: +0.35 → 0.95 ✅

---

## The 7 Tasks (Original Overview)

| Task | Format | Difficulty | Bugs | Key Challenge |

---

## Multi-Task Learning

The environment progresses through all 7 tasks sequentially:
1. Agent learns from task1 → task2 → ... → task7
2. Each task builds on previous knowledge
3. Harder tasks should show better reasoning (agents see more diverse error types)

---

## API Endpoints

### Core OpenEnv Endpoints
- `POST /reset` - Reset environment to task1
- `POST /step` - Submit action (fixed config) → get reward + next observation
- `GET /observation` - Get current observation
- `GET /state` - Get full environment state

### Utility Endpoints
- `GET /metadata` - Environment specification (auto-generated by OpenEnv)
- `GET /info` - Service info
- `GET /health` - Health check
- `GET /tasks` - List all tasks with metadata

---

## Example Session

```python
from server.config_debug_environment import ConfigDebugEnvironment
from server.models import ConfigDebugAction

env = ConfigDebugEnvironment()
obs = env.reset()  # Start at task1_json

# Attempt 1: Agent tries initial fix
action = ConfigDebugAction(fixed_config='{"key": "value"}')
obs = env.step(action)
print(f"Reward: {obs.reward}")        # → 0.4 (partial credit)
print(f"Error: {obs.error_message}")  # → Guides next attempt

# Attempt 2: Agent learns and improves
action = ConfigDebugAction(fixed_config='{"key": "value", "number": 42}')
obs = env.step(action)
print(f"Reward: {obs.reward}")        # → 0.7
print(f"Error: {obs.error_message}")  # → Final hint

# Attempt 3: Agent completes
action = ConfigDebugAction(fixed_config='{"key": "value", "number": 42, "enabled": true}')
obs = env.step(action)
print(f"Reward: {obs.reward}")        # → 1.0 ✅
print(f"Done: {obs.done}")            # → False (more tasks remain)
obs = obs.task_id                     # → task2_yaml
```

---

## Key Strengths

**True RL Problem**: Partial rewards with sequential decision-making  
**Multi-Step Reasoning**: Errors cascade; fixes must be iterative  
**Domain-Diverse**: 7 config formats = varied error types  
**Scalable Difficulty**: Easy tasks build foundation for hard tasks  
**Real-World Relevance**: Configuration bugs are a major DevOps pain point  

---

## Technical Stack

- **Framework**: OpenEnv (FastAPI-based)
- **Language**: Python 3.12+
- **Graders**: Domain-specific validators (YAML, JSON, Docker, K8s, nginx)
- **Deployment**: Docker + Hugging Face Spaces

---

## Getting Started

```bash
# Install dependencies
pip install -r requirements.txt

# Run tests
python test_env.py

# Start server
uvicorn server.app:app --reload

# Access at http://localhost:8000
```

---

## Evaluation Criteria

- ✅ **Correct Task Progression** - All 7 tasks with proper graders
- ✅ **Multi-Step Learning** - Agents show iterative improvement  
- ✅ **Error Guidance** - Clear feedback directs next fix
- ✅ **Reward Semantics** - Partial credit enables intermediate learning

---

## For Judges

This project demonstrates **advanced RL environment design**:

1. **Problem Formulation**: Configuration debugging is inherently sequential and iterative
2. **Reward Engineering**: Partial rewards guide exploration; not just binary pass/fail
3. **Task Curriculum**: 7 tasks from easy→hard with consistent structure
4. **Error Pedagogy**: Error messages teach agents what to fix next
5. **Scalability**: Framework generalizes to any text-based debugging task

ConfigDebugEnv isn't just a benchmark—it's a **learning tool** that teaches agents to think like human debuggers.

---

**Built for**: Meta PyTorch OpenEnv Hackathon x SST  
**Version**: 1.0.0
- GET /docs - Swagger API docs

## Setup

Run locally:

    pip install fastapi uvicorn pydantic pyyaml httpx openai gradio
    uvicorn server.env:app --host 0.0.0.0 --port 7860

Run with Docker:

    docker build -t config-debug-env .
    docker run -p 7860:7860 config-debug-env

## Baseline Results

Qwen/Qwen2.5-72B-Instruct: 7/7 tasks, score = 1.000