Meta-HF-hackathon/sre-incident-simulator
๐จ SRE Incident Response Simulator
An OpenEnv environment where AI agents must diagnose and remediate production incidents across a simulated microservices architecture.
Why This Environment Matters
This is a POMDP (Partially Observable Markov Decision Process). The agent never sees the root cause โ it sees symptoms: climbing memory metrics, cascading error logs, firing alerts. It must gather evidence, form hypotheses, and act โ exactly like a real SRE at 3 AM.
Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ SIMULATED INFRASTRUCTURE โ
โ โ
โ โโโโโโโโโโโ โโโโโโโโโโโ โโโโโโโโโโโ โโโโโโโโโโโ โ
โ โ API GW โโโโโโบโ Auth โโโโโโบโ Orders โโโโโโบโ Payment โ โ
โ โโโโโโฌโโโโโ โโโโโโโโโโโ โโโโโโฌโโโโโ โโโโโโฌโโโโโ โ
โ โ โ โ โ
โ โผ โผ โผ โ
โ โโโโโโโโโโโ โโโโโโโโโโโ โโโโโโโโโโโ โ
โ โ Cache โ โ DB โ โ Queue โ โ
โ โโโโโโโโโโโ โโโโโโโโโโโ โโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ7 services with reactive metrics, logs, alerts, and dependency-aware cascade propagation.
Action Space (Hierarchical)
Level 1: Action Type
Level 2: Target Service + Parameters
Targeted actions require target_service from: api_gateway, auth, orders, payment, cache, database, queue.
Action Masking
The observation includes valid_actions[] โ illegal actions (e.g., rollback on a service with no deploy history) are rejected with a penalty.
Observation Space (POMDP)
The agent never sees: fault_type, is_bad deploy flag, or internal simulation state.
It does see:
- Incident summary and severity
- Service statuses (healthy/degraded/down)
- Active alert count
- Action result (data from the last action: logs, metrics, alerts, etc.)
- Valid actions (action mask)
- Time elapsed / budget (SLA pressure)
- Cumulative reward and step count
Tasks
Reward Design (Two-Layer)
Layer 1: Per-Step Training Rewards (Oracle-Shaped)
These rewards peek at hidden state to guide RL training:
Layer 2: Evaluation Grader (Oracle-Independent)
The grader scores only the trajectory โ no hidden state access:
Quick Start
Local Development
# Install dependencies
cd incident_env
pip install -e .
# Start server
uvicorn incident_env.server.app:app --host 0.0.0.0 --port 8000
# Test endpoints
curl http://localhost:8000/health
curl -X POST http://localhost:8000/reset -H "Content-Type: application/json" -d '{"task_name": "memory_leak"}'
curl -X POST http://localhost:8000/step -H "Content-Type: application/json" -d '{"action_type": "view_alerts"}'Run Inference
export OPENAI_API_KEY=sk-...
export MODEL_NAME=gpt-4o-mini
export ENV_BASE_URL=http://localhost:8000
python inference.pyDocker
docker build -t incident-env -f server/Dockerfile .
docker run -p 8000:8000 incident-envExample Agent Interaction
Agent: POST /reset {"task_name": "memory_leak"}
โ Incident triggered: "Orders service experiencing failures..."
โ Services: orders=degraded, rest=healthy
Agent: POST /step {"action_type": "view_alerts"}
โ 3 alerts: orders HighMemoryUsage (critical), orders HighErrorRate, orders HighLatencyP99
โ reward = +0.13
Agent: POST /step {"action_type": "check_metrics", "target_service": "orders"}
โ 30 data points: memory climbing from 35% โ 78% over 20 minutes
โ reward = +0.13
Agent: POST /step {"action_type": "check_deploy_history", "target_service": "orders"}
โ 2 deploys: v2.3.1 (20 min ago, "batch order processing") and v1.2.0
โ reward = +0.13
Agent: POST /step {"action_type": "rollback_deploy", "target_service": "orders"}
โ "Rolled back orders from v2.3.1 to v1.2.0 โ service recovering"
โ reward = +0.28
Agent: POST /step {"action_type": "declare_root_cause", "parameters": {"root_cause": "memory leak in orders caused by bad deploy v2.3.1"}}
โ Episode done. Final grade: 0.97