CoolFace
Apppublic

Meta-HF-hackathon/sre-incident-simulator

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
App README

๐Ÿšจ 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.

DimensionDetail
ObservationAlerts, metric timeseries, structured logs, dependency graphs, deploy history
Action space10 hierarchical action types ร— 7 target services = rich combinatorics
DifficultyEasy (single-service leak) โ†’ Medium (cascading failure) โ†’ Hard (distributed deadlock)
RewardOracle-shaped per-step signal for training + oracle-independent grader for evaluation
RealismReactive simulation โ€” memory climbs over time, cascades propagate, restarts don't fix root causes

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

ActionCategoryDescription
view_alertsDiagnosticSee all firing alerts
query_logsDiagnosticQuery service logs (with level/keyword filters)
check_metricsDiagnosticGet 30-minute metric timeseries
check_dependenciesDiagnosticView upstream/downstream dependency map
check_deploy_historyDiagnosticRecent deploys for a service
run_health_checkDiagnosticPing a service for status
restart_serviceRemediationRestart (fixes symptoms temporarily, not root cause)
rollback_deployRemediationRollback to previous deploy version
scale_serviceRemediationScale replicas up/down
declare_root_causeTerminalSubmit diagnosis โ€” ends episode

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

TaskDescriptionDifficultyRoot Cause
memory_leakOrders service OOM from bad deployEasyRollback orders deploy v2.3.1
cascading_failureAuth config change cascading to API GW + ordersMediumRollback auth deploy, restart dependents
distributed_deadlockPayment retry change creates circular waitHardRollback payment, scale queue, restart orders

Reward Design (Two-Layer)

Layer 1: Per-Step Training Rewards (Oracle-Shaped)

These rewards peek at hidden state to guide RL training:

Action CategoryConditionReward
DiagnosticInvestigating involved service+0.15
DiagnosticInvestigating uninvolved service+0.05
AnyRepeating a previous action-0.05
RemediationCorrect target (root cause service)+0.30
RemediationHelpful (affected, not root cause)+0.10
RemediationHarmful (healthy service)-0.15
DeclarationCorrect root cause+0.40
DeclarationWrong root cause-0.20
AnyPer-step efficiency penalty-0.02
CompletionAll services healthy+0.20
CompletionTime budget exceeded-0.10

Layer 2: Evaluation Grader (Oracle-Independent)

The grader scores only the trajectory โ€” no hidden state access:

CriterionWeightWhat it measures
Root cause accuracy40%Did the agent declare the correct root cause?
Remediation quality30%Did the agent take the right fix actions?
Diagnostic efficiency20%Fewer steps to diagnosis = better
Service restoration10%Are all services healthy at episode end?

Quick Start

Local Development

bash
# 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

bash
export OPENAI_API_KEY=sk-...
export MODEL_NAME=gpt-4o-mini
export ENV_BASE_URL=http://localhost:8000

python inference.py

Docker

bash
docker build -t incident-env -f server/Dockerfile .
docker run -p 8000:8000 incident-env

Example 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