Spaces:
Sleeping
Sleeping
File size: 6,642 Bytes
3d77779 | 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 | # TRACE β Teaching AI to Fix Production Incidents
> **Triage Β· Response Β· Action Β· Cause Β· Evaluation**
---
## π₯ The Problem
**Production incidents cost companies millions per hour.**
When systems break at 3 AM, engineers scramble through dashboards, comb through logs, and guess at root causes. The average MTTR (Mean Time to Resolution) for critical incidents is **4+ hours** β and it's getting worse as systems grow more complex.
Current AI coding agents can write code, but **none of them can operate production infrastructure under pressure.**
Why? Because there's no training ground for it.
---
## π‘ The Solution: TRACE
TRACE is the **first RL environment designed to teach AI agents how to respond to production incidents.**
Think of it as a **flight simulator for Site Reliability Engineers** β but for AI.
```
Agent observes metrics β inspects systems β diagnoses root cause β executes fix β validates recovery
```
One environment. Three difficulty levels. Infinite training runs.
---
## π― How It Works
### The Agent Loop
```
βββββββββββββββββββββββββββββββββββββββββββββββ
β LLM Agent β
β "CPU is at 85%... let me check β
β the logs for api_workers" β
ββββββββββββββββββββ¬βββββββββββββββββββββββββββ
β action: inspect_logs("api_workers")
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββ
β TRACE Environment β
β β
β π Metrics π₯οΈ Services π¨ Alerts β
β CPU: 85% api: degraded cpu_high β
β Latency: 500ms β
β β
β π "Traffic spike detected. Scale workers" β
ββββββββββββββββββββ¬βββββββββββββββββββββββββββ
β reward: +1.0 (useful inspection)
βΌ
Agent learns to diagnose β fix β validate
```
### Partial Observability β Like Real Life
The agent sees **symptoms**, not causes:
- β
CPU usage, memory, latency, error rates
- β
Service statuses (healthy / degraded / down)
- β
Alert names
But **root cause is hidden** behind inspection actions β just like a real engineer who has to `grep` the logs.
### Three Scenarios, Increasing Complexity
| Scenario | What Breaks | Root Cause | How to Fix |
|----------|-------------|------------|------------|
| π’ **Easy** | Traffic spike | Worker overload | Scale horizontally |
| π‘ **Medium** | Cascading failures | Queue memory leak | Restart service |
| π΄ **Hard** | Multi-service outage | DB pool + bad release | Restart DB + rollback |
### Smart Grading
```python
score = 0.6 Γ did_you_fix_it + 0.4 Γ how_fast_were_you
```
No hand-wavy metrics. Binary success + speed. That's it.
---
## ποΈ Technical Design
### OpenEnv Compliant
TRACE is built to the **OpenEnv specification** β the emerging standard for RL environment benchmarks:
- `pyproject.toml` + `openenv.yaml` β auto-validated
- 4 REST endpoints: `/reset`, `/step`, `/state`, `/health`
- Docker-ready, deploys to HF Spaces in one push
### Deterministic & Reproducible
Same seed β same metrics β same trajectory. Every time.
This isn't a toy random environment. The scenarios are **hand-crafted to test real incident response patterns** β triage, diagnosis, remediation, validation.
### Action Space
10 structured actions using `(type, target, value)` triples:
```
inspect_logs("database") β reveals root cause
scale_workers("api_workers", 5) β horizontal scaling
restart_database() β resets connection pool
declare_healthy() β "I fixed it" (terminal)
```
---
## π Results
Running our benchmark with heuristic agents:
| Scenario | Steps | Grade | Status |
|----------|-------|-------|--------|
| Easy CPU Spike | 3/5 | 0.76 | β
Solved |
| Medium Cascade | 3/7 | 0.83 | β
Solved |
| Hard Mixed | 4/8 | 0.80 | β
Solved |
**Average: 0.80** β and that's with hand-coded heuristics. The ceiling for LLM agents is much higher.
---
## π¦Ύ Why This Matters
### For AI Research
- First standardized benchmark for **operational AI** (not just coding)
- Partial observability forces genuine **reasoning under uncertainty**
- Structured action space enables **reward shaping** without reward hacking
### For the Industry
- Train agents to reduce MTTR from hours to minutes
- Build **autonomous incident response** systems
- Bridge the gap between "AI writes code" and "AI runs production"
### For the Hackathon
- β
OpenEnv validator passes
- β
28 tests, all green
- β
Full inference pipeline with LLM agent
- β
Interactive Gradio demo
- β
Docker builds and serves
- β
Push-to-deploy HF Spaces ready
---
## π Demo
### Live Interactive UI
```
python ui.py
β Opens Gradio dashboard at localhost:7861
β Select scenario, take actions, watch metrics change in real-time
```
### LLM Agent Run
```
export HF_TOKEN=your-token
python inference.py
[START] task=easy_cpu_spike env=trace model=openai/gpt-oss-20b
[STEP] step=1 action=inspect_logs(api_workers,) reward=1.00 done=false error=null
[STEP] step=2 action=scale_workers(api_workers,5) reward=5.00 done=false error=null
[STEP] step=3 action=declare_healthy(,) reward=10.00 done=true error=null
[END] success=true steps=3 score=0.840 rewards=1.00,5.00,10.00
```
---
## π€ Team
**Rajarshi Datta** β Builder, designer, engineer.
---
## π¦ Stack
| Component | Technology |
|-----------|-----------|
| Environment | Python, Pydantic |
| Server | FastAPI, Uvicorn |
| Inference | OpenAI Client, HF Router |
| Model | openai/gpt-oss-20b |
| Deployment | Docker, HF Spaces |
| Demo | Gradio |
| Spec | OpenEnv |
---
## One Line
**TRACE teaches AI agents to fix production incidents β the missing benchmark between "AI writes code" and "AI runs production."**
---
*Built for the Meta Γ PyTorch Γ Hugging Face OpenEnv Hackathon.*
|