CoolFace
Apppublic

monish211205/incident-response-env

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

๐Ÿšจ Incident Response OpenEnv

An OpenEnv environment where an AI agent acts as an on-call Site Reliability Engineer, diagnosing and resolving production incidents across a simulated microservices system.

Why This Environment?

Every company running production software faces incidents โ€” services going down, latency spiking, cascading failures rippling through a dependency graph. Incident response is one of the most high-stakes, time-pressured reasoning tasks in software engineering.

This environment captures that task faithfully:

  • โ€”The agent reads real-looking monitoring dashboards (service metrics, PagerDuty-style alerts)
  • โ€”It runs diagnostic commands (inspecting log tails from failing services)
  • โ€”It must identify the root cause โ€” not just the symptom โ€” through a dependency graph
  • โ€”It applies the correct remediation: rollback a bad deployment, scale up an overloaded service, or restart one stuck in a crash loop
  • โ€”All under a ticking SLA clock

This is exactly what SRE teams at Google, Meta, Netflix, and Stripe do every day.


Environment Design

System Topology

Each episode presents a snapshot of a microservices system. Services have:

MetricDescription
statushealthy / degraded / down
error_rateFraction of requests failing (0.0โ€“1.0)
latency_p99_ms99th-percentile response time
cpu_utilisationCPU usage (0.0โ€“1.0)
memory_utilisationMemory usage (0.0โ€“1.0)
recent_deploymentWhether a deploy happened in the last 30 minutes
dependenciesUpstream services this service calls

Action Space

The agent submits one action per step โ€” mirroring real SRE operations:

ActionDescriptionReal-world analogue
investigateRead logs + diagnostics for a servicekubectl logs / APM trace
rollbackRevert last deploymenthelm rollback / git revert
restartRestart a servicekubectl rollout restart
scale_upAdd replicaskubectl scale --replicas=N
escalatePage a human engineerPagerDuty escalation policy
resolveDeclare incident resolvedIncident closure

Every action requires a rationale โ€” the agent's reasoning. This is scored for specificity (mentioning service names, metrics, root-cause keywords).

Observation Space

json
{
  "incident_title": "[P1] Site-wide degradation โ€” multiple services failing",
  "incident_severity": "P1",
  "step_count": 2,
  "max_steps": 10,
  "time_to_resolve_budget": 50,
  "services": [
    {
      "name": "auth-service",
      "status": "degraded",
      "error_rate": 0.30,
      "latency_p99_ms": 3200,
      "cpu_utilisation": 0.97,
      "memory_utilisation": 0.85,
      "recent_deployment": false,
      "dependencies": ["redis-cache"]
    }
  ],
  "active_alerts": [
    {
      "alert_id": "ALT-020",
      "service": "api-gateway",
      "severity": "P1",
      "message": "api-gateway: error rate 45% โ€” multiple upstream failures"
    }
  ],
  "last_diagnostic": {
    "service": "auth-service",
    "log_tail": ["2026-03-27T16:00:05Z [ERROR] Token validation timeout โ€” queue full"],
    "error_summary": "auth-service is CPU-saturated due to a 2x traffic spike...",
    "suggested_action": "SCALE_UP auth-service"
  },
  "action_history": [
    "Step 1: [INVESTIGATE] -> api-gateway | Starting at user-facing entry point..."
  ]
}

Tasks

Easy โ€” Single Service Failure

Scenario: Payment service crashes immediately after a bad deployment. API Gateway begins returning 502s. Alerts fire on both services.

The agent must:

  1. 1.Investigate the API Gateway (upstream errors point to payment-service)
  2. 2.Investigate payment-service (crash logs show failed DB migration)
  3. 3.Rollback payment-service
  4. 4.Resolve

Medium โ€” Cascading Failure (Multi-hop)

Scenario: Checkout latency exceeds 10 seconds. The root cause is inventory-service stuck in a crash loop โ€” three hops from the user-facing alert.

The agent must trace: checkout โ†’ order โ†’ inventory.


Hard โ€” Site-wide Degradation with Red Herrings

Scenario: Four services simultaneously degraded with P1 alerts firing. Root cause is auth-service CPU saturation from a 2x traffic spike โ€” but:

  • โ€”notification-service had a recent deployment (red herring)
  • โ€”user-service has a worse error rate than auth-service
  • โ€”auth-service has a lower severity alert (P2) than the symptoms (P1)
  • โ€”The fix is scale_up โ€” not restart or rollback

Reward Function

Reward is dense โ€” partial progress signals fire every step.

Episode-end reward (90% of final score)

ComponentWeightMeasures
Root cause identification35%Did the agent investigate the root-cause service?
Correct remediation30%Was the right fix applied to the right service?
Resolution speed20%Fewer steps + time budget remaining
Reasoning quality15%Rationale specificity (keywords, service names, metrics)

Per-step reward (10% of final score)

TriggerReward
Investigating root-cause service+0.10
Investigating a dependency of root cause+0.05
Correct fix on root-cause service+0.12
Any investigation (exploration)+0.02

Penalties

TriggerPenalty
Escalate without investigating root cause-0.10
Destructive action on a healthy service-0.05

API Reference

MethodEndpointDescription
GET/healthLiveness check
GET/schemaAction + observation JSON schemas
GET/tasksAll tasks with difficulty + action schema
POST/resetStart a new episode
POST/stepSubmit an action
GET/stateCurrent observation (no advance)
POST/graderRun grader for a task
POST/baselineRun baseline agent on all tasks
WS/wsWebSocket for persistent sessions

Baseline Scores

AgentEasyMediumHardMean
Random (immediate resolve)0.080.070.060.07
Rule-based heuristic0.79990.72470.76060.7617
Optimal action sequence0.82440.81000.82310.8192

Local Setup

bash
git clone https://huggingface.co/spaces/monish211205/incident-response-env
cd incident-response-env
pip install openenv-core fastapi "uvicorn[standard]" pydantic openai
uvicorn server.app:app --host 0.0.0.0 --port 7860 --reload

Open http://localhost:7860/docs for the interactive Swagger UI.

Run tests

bash
pip install pytest pytest-asyncio
pytest tests/ -v
# Expected: 34 passed

Run baseline

bash
python -m baseline.baseline

Project Structure

incident-response-env/
โ”œโ”€โ”€ server/
โ”‚   โ”œโ”€โ”€ app.py           # FastAPI server (openenv-core create_app)
โ”‚   โ”œโ”€โ”€ environment.py   # IncidentResponseEnv โ€” core environment class
โ”‚   โ”œโ”€โ”€ models.py        # Typed Pydantic models: Action, Observation, State
โ”‚   โ”œโ”€โ”€ scenarios.py     # Incident scenario definitions (easy/medium/hard)
โ”‚   โ”œโ”€โ”€ reward.py        # Dense multi-component reward function
โ”‚   โ””โ”€โ”€ graders.py       # Deterministic graders for all 3 tasks
โ”œโ”€โ”€ baseline/
โ”‚   โ””โ”€โ”€ baseline.py      # LLM + rule-based baseline agent
โ”œโ”€โ”€ tests/
โ”‚   โ””โ”€โ”€ test_environment.py  # 34-test suite
โ”œโ”€โ”€ openenv.yaml         # OpenEnv metadata spec
โ”œโ”€โ”€ Dockerfile           # Multi-stage production build
โ”œโ”€โ”€ pyproject.toml       # Package configuration
โ””โ”€โ”€ README.md            # This file

License

Apache 2.0 โ€” see LICENSE.