DevilNReality/Incident-Triage-Reinforcement-Learning
๐จ Incident Triage & Alert Routing โ OpenEnv
Meta ร Hugging Face AI Hackathon | Round 1 An OpenEnv environment for training AI agents to triage production incidents like a senior SRE.
Environment Description
This environment simulates the real-world job of a Site Reliability Engineer (SRE) who receives a flood of production alerts and must:
- Identify the root cause from a set of correlated alerts
- Assign the correct severity level (P1โP4)
- Route the incident to the correct on-call team (SRE, Database, Network, or App)
- (Hard task only) Suppress noise alerts โ flapping/self-resolving false positives
Every tech company faces alert fatigue. Reducing Mean Time To Detection (MTTD) by even 5 minutes has enormous operational value. This environment benchmarks how well an AI agent handles that pressure.
Observation Space
At each step the agent receives an AlertObservation:
class AlertObservation(BaseModel):
alerts: List[Alert] # incoming monitoring alerts
services_map: Dict[str, str] # service โ responsible team
step: int # current step in the episode
max_steps: int # maximum steps allowed
task_id: str # "task_easy" | "task_medium" | "task_hard"Each Alert contains:
class Alert(BaseModel):
alert_id: str # e.g. "alert-001"
service: str # e.g. "postgres-primary"
metric: str # e.g. "db_query_time_ms"
value: float # current metric value
threshold: float # value that triggered the alert
duration_s: int # how long it has been firing (seconds)Services Map
Action Space
class TriageAction(BaseModel):
severity: Literal['P1', 'P2', 'P3', 'P4']
team: Literal['sre', 'database', 'network', 'app']
root_cause: str # one-sentence explanation, graded by keyword match
suppressed: List[str] # alert_ids believed to be noise (task_hard only)Reward Function
task_easy
task_medium
task_hard
Task Descriptions
๐ข task_easy โ Single Alert, Obvious Root Cause
- 1 alert randomly chosen from 4 scenario variants
- Variants: CPU spike โ SRE ยท DB timeout โ Database ยท Network latency โ Network ยท 5xx errors โ App
- Max steps: 3
- Expected score (frontier model): 0.9โ1.0
๐ task_medium โ 3 Correlated Alerts, Identify Root Cause
- 3 correlated alerts from 4 scenario sets (Database overload, Network partition, App memory leak, CPU saturation)
- Agent must identify the single upstream root cause from downstream effects
- Max steps: 3
- Expected score (frontier model): 0.5โ0.75
๐ฅ task_hard โ 10โ15 Alerts, Suppress Noise & Escalate
- 6 real alerts (database outage root cause) + 5 noise alerts (short-duration, barely over threshold)
- Noise rule:
duration_s < 60ANDvalue < threshold ร 1.10 - Agent must suppress noise alerts and correctly identify the P1 database root cause
- Max steps: 5
- Expected score (frontier model): 0.2โ0.45
API Reference
All endpoints are available on port 7860 (via nginx reverse proxy).
Example: Full Episode
import requests
BASE = "https://<your-username>-incident-triage-env.hf.space"
# 1. Reset
obs = requests.post(f"{BASE}/reset", json={"task_id": "task_medium"}).json()
# 2. Step
action = {
"severity": "P1",
"team": "database",
"root_cause": "Database overload causing query timeouts and downstream 5xx errors",
"suppressed": []
}
result = requests.post(f"{BASE}/step", json=action).json()
print(result["reward"], result["done"], result["info"])๐ Setup & Deployment
Option A โ Hugging Face Spaces (recommended)
Prerequisites
- Git installed
- A Hugging Face account with a token from https://huggingface.co/settings/tokens
Step 1 โ Install the HF CLI & login
pip install huggingface_hub
huggingface-cli loginStep 2 โ Create a new Space
Go to https://huggingface.co/new-space and set:
- Space name:
incident-triage-env - SDK: Docker
- Visibility: Public
Step 3 โ Clone and push
git clone https://huggingface.co/spaces/<your-username>/incident-triage-env
cd incident-triage-env
# Copy all project files here, then:
git add .
git commit -m "deploy: Incident Triage OpenEnv"
git pushHF Spaces detects the Dockerfile and builds automatically (~3โ5 min). Monitor progress in the Logs tab.
Step 4 โ Add secrets (for LLM agent mode)
In your Space โ Settings โ Repository secrets:
The Streamlit UI and rule-based agent work without secrets. Secrets are only needed for LLM Agent mode.
Option B โ Local Development
# 1. Install dependencies
pip install -r requirements.txt
# 2. Start FastAPI backend (terminal 1)
cd backend
uvicorn server:app --reload --port 8000
# 3. Start Streamlit UI (terminal 2, from project root)
BACKEND_URL=http://localhost:8000 streamlit run frontend/app.py
# Opens at http://localhost:8501
# 4. (Optional) Run the LLM baseline agent
cp .env.example .env # fill in your API keys
source .env
python inference.pyOption C โ Docker locally
docker build -t incident-triage-env .
docker run -p 7860:7860 \
-e HF_TOKEN=hf_... \
-e API_BASE_URL=https://router.huggingface.co/v1 \
-e MODEL_NAME=meta-llama/Llama-3.3-70B-Instruct \
incident-triage-env
# UI + API both at http://localhost:7860Architecture
Browser / OpenEnv Checker
โ
โผ port 7860 (public)
nginx
โฑ โฒ
โผ โผ
FastAPI Streamlit
:8000 :8501
(API calls) (Web UI)nginx routes:
POST /reset,GET /health,/tasks,/step,/stateโ FastAPI (OpenEnv checker)/and all other traffic โ Streamlit UI (browser)
Project Structure
incident-triage-env/
โโโ Dockerfile โ Builds & runs nginx + FastAPI + Streamlit
โโโ nginx.conf โ Reverse proxy: port 7860 โ FastAPI:8000 / Streamlit:8501
โโโ start.sh โ Startup script launching all three processes
โโโ requirements.txt โ Python dependencies (latest versions)
โโโ openenv.yaml โ OpenEnv spec: tasks, action/observation spaces, reward
โโโ pyproject.toml โ Package config; server entry point: server.app:main
โโโ .env.example โ Template for local env vars
โโโ .dockerignore โ Excludes __pycache__, *.pyc, .git, uv.lock etc.
โโโ inference.py โ LLM baseline agent (uses OpenAI client + HF router)
โโโ backend/
โ โโโ models.py โ Pydantic v2: Alert, AlertObservation, TriageAction, TriageReward
โ โโโ tasks.py โ All task definitions + graders (easy / medium / hard)
โ โโโ environment.py โ OpenEnv contract: reset() step() state()
โ โโโ server.py โ FastAPI app with /reset /step /state /health /tasks
โโโ server/
โ โโโ app.py โ Entry point wrapper for multi-mode deployment (server.app:main)
โโโ frontend/
โโโ app.py โ Streamlit UI: alert cards, routing table, score chartBaseline Scores
Scores from meta-llama/Llama-3.3-70B-Instruct via HF inference router.
Built for the Meta ร Hugging Face AI Hackathon, Round 1.
