hemang1404/RuntimeTerror
0
IncidentEnv — AI On-Call Incident Response Environment
An AI agent receives a production alert, investigates using diagnostic tools, identifies the root cause, and submits a code fix — validated by actual test execution.
Built on OpenEnv for the Meta × PyTorch × Hugging Face Hackathon.
Why Incident Response?
Incident response is the highest-stakes task in software engineering. When a system goes down at 3 AM, an on-call engineer must:
- Read alerts and logs — triage severity, identify affected services
- Run diagnostics — query metrics, inspect code, correlate signals
- Identify root cause — connect multiple data points into a hypothesis
- Apply a fix — write and validate a code change that resolves the issue
This environment simulates that full loop, testing multi-step reasoning, code comprehension, and debugging — capabilities no existing benchmark covers.
Architecture
reset(task_id)
│
├─ PHASE 1: INVESTIGATION (up to 10 steps)
│ ├─ query_logs(service, keyword) → filtered log entries
│ ├─ query_metrics(metric, time_range) → time-series data
│ ├─ inspect_code(file) → source file with line numbers
│ ├─ run_diagnostic(command) → diagnostic output
│ └─ submit_root_cause(root_cause) → transitions to Phase 2
│
└─ PHASE 2: REMEDIATION (up to 5 steps)
├─ suggest_fix(file, patch_code) → pytest runs → pass/fail
└─ submit_resolution() → episode ends → grader scoreAction Space
Observation Space
Tasks
Scenario Examples
- Easy: DB connection pool leak, null pointer crash, unbounded SQL query
- Medium: Memory leak in batch processor, cascading timeout mismatch, off-by-one rate limiter
- Hard: Race condition in job queue, UTF-8/Latin-1 encoding corruption, JWT clock skew, silent event buffer drops, cache stampede
Reward Function
Investigation Phase
Remediation Phase
Grading
Deterministic formula (0.0 – 1.0):
score = 0.30 × root_cause_accuracy
+ 0.15 × investigation_quality (inspected buggy file?)
+ 0.35 × fix_quality (tests passed?)
+ 0.10 × efficiency (fewer steps = better)
+ 0.10 × decision_quality (submitted root cause?)Setup
Local Development
# Install dependencies
pip install pydantic fastapi uvicorn requests pytest
# Run tests
python -m pytest tests/ -v
# Start server
python -m uvicorn server.app:app --host 0.0.0.0 --port 8000Docker
docker build -t incident-env:latest -f server/Dockerfile .
docker run -p 8000:8000 incident-env:latestHuggingFace Space
openenv push --repo-id yourname/incident-envUsage
# Connect to running server
from client import IncidentEnv
env = IncidentEnv(base_url="http://localhost:8000")
# Start an episode
obs = env.reset(task_id="easy_triage")
print(obs["alert_title"]) # 🚨 HIGH ERROR RATE: user-api
# Investigate
result = env.step({"action_type": "query_logs", "service": "user-api", "keyword": "error"})
print(result["observation"]["output"]) # Log entries...
result = env.step({"action_type": "inspect_code", "file": "db/pool.py"})
print(result["observation"]["output"]) # Source code...
# Submit root cause
result = env.step({
"action_type": "submit_root_cause",
"root_cause": "DB connections leak in get_user() — never released"
})
# Fix the bug
result = env.step({
"action_type": "suggest_fix",
"file": "db/pool.py",
"patch_code": "...fixed code with try/finally..."
})
print(result["observation"]["tests_passed"]) # True ✅
# Finalize
result = env.step({"action_type": "submit_resolution"})
state = env.state()
print(f"Grader score: {state['grader_score']}") # 0.87Inference Script
export API_BASE_URL=https://api-inference.huggingface.co/v1
export MODEL_NAME=mistralai/Mistral-7B-Instruct-v0.3
export HF_TOKEN=hf_xxxxxxxxxxxxxxxx
python inference.py # all tasks
python inference.py --task easy_triage # just easy
python inference.py --episodes 3 # 3 episodes per taskBaseline Scores
Latest measured runs (HF Space deployment):
Reproduce with:
export ENV_URL="https://hemang1404-runtimeterror.hf.space"
export API_BASE_URL="https://router.huggingface.co/v1"
export MODEL_NAME="Qwen/Qwen2.5-7B-Instruct"
export HF_TOKEN="hf_xxxxxxxxxxxxxxxx"
python inference.py --task easy_triage --episodes 3Environment Variables
License
MIT
