CoolFace
Apppublic

rohanjain1648/META-PYTORCH-HACKATHON

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

๐Ÿšจ Incident Triage Environment

An OpenEnv-compliant environment simulating real-world IT/DevOps incident response triage โ€” where an AI agent acts as an on-call engineer handling production incidents.

![OpenEnv](https://github.com/meta-pytorch/OpenEnv) ![HF Space](https://huggingface.co/spaces/rohanjain1648/incident-triage-env) ![Python 3.10+](https://www.python.org)


Table of Contents

  1. 1.Problem Statement
  2. 2.What The Platform Does
  3. 3.Environment Description
  4. 4.Tasks & Difficulty Levels
  5. 5.System Overview
  6. 6.System Architecture
  7. 7.Code Structure & Reproducibility
  8. 8.Core Logic Deep Dive
  9. 9.Reward Function
  10. 10.Architecture Decisions
  11. 11.Performance Optimizations
  12. 12.Setup Instructions
  13. 13.Baseline Scores
  14. 14.API Reference
  15. 15.Known Limitations
  16. 16.What I'd Improve With More Time

โ“ Problem Statement

Current LLMs struggle with multi-step debugging in distributed systems. When an active incident occurs in an enterprise setup, finding the root cause requires correlating metrics, logs, events, and traces across dozens of inter-dependent services. The lack of standard benchmarks and environments for this specific domain heavily hinders the development of autonomous SRE/DevOps agents.


๐Ÿ’ก What The Platform Does

This platform presents an AI agent with a continuous stream of realistic production alerts, system metrics, application logs, and configuration data. The agent must successfully navigate through investigation โ†’ diagnosis โ†’ prioritization โ†’ remediation โ†’ verification to resolve incidents. It supports multiple valid investigation paths, assesses partial-credit situations (like correct diagnosis but slow remediation), and handles dynamically cascading failures with red herrings.


๐Ÿ“‹ Environment Description

Incident Response Triage simulates the work that on-call engineers at every tech company do daily: monitoring production alerts, diagnosing root causes, prioritizing incidents by severity, and applying fixes before outages escalate.

The environment presents the agent with realistic production alerts, system metrics, application logs, and configuration data. The agent must navigate through investigation โ†’ diagnosis โ†’ prioritization โ†’ remediation โ†’ verification to resolve incidents.

Why This Domain?

  • โ€”Genuine real-world task: Millions of engineers perform incident response daily
  • โ€”Rich decision-making: Multiple valid investigation paths, priority trade-offs, cascading failures
  • โ€”Partial-credit scenarios: Correct diagnosis but wrong fix, correct priority but slow
  • โ€”Meaningful difficulty progression: From single alert to cascading multi-service failures

๐Ÿ“Š Tasks & Difficulty Levels

Task 1: single_incident (๐ŸŸข Easy)

Resolve a single production incident.

The agent receives ONE alert and must: investigate โ†’ diagnose โ†’ prioritize โ†’ remediate โ†’ verify.

ComponentWeight
Correct diagnosis30%
Correct priority15%
Correct remediation35%
Successful verification10%
Efficiency (fewer steps)10%

Max steps: 10 | Expected: 5โ€“6 steps

Scenarios: Database connection pool exhaustion, disk space critical, SSL certificate expired


Task 2: multi_incident (๐ŸŸก Medium)

Triage 2โ€“3 simultaneous incidents with correlations.

The agent must identify which alerts are independent vs. symptoms of a shared root cause, prioritize correctly, and fix efficiently.

ComponentWeight
Correct triage order20%
Correct diagnoses25%
Correct remediations30%
Correlation identification15%
Time efficiency10%

Max steps: 20 | Expected: 12โ€“14 steps

Scenarios: Memory leak causing cascading timeouts, DNS misconfiguration breaking deployments


Task 3: cascading_failure (๐Ÿ”ด Hard)

Resolve a cascading failure with 4+ alerts and red herrings.

A database migration has locked a critical table, causing a full-stack cascade. The agent must identify the ROOT CAUSE (not just symptoms), ignore red herring alerts, and fix in the correct order.

ComponentWeight
Root cause identification30%
Red herrings ignored10%
Correct fix order20%
All incidents resolved25%
Efficiency15%

Max steps: 30 | Expected: 18โ€“22 steps

Scenarios: Full stack cascade from database migration (load balancer โ†’ app servers โ†’ database โ†’ cache โ†’ message queue, with cache eviction as red herring)


โš™๏ธ System Overview

The system exposes an OpenAI-compatible API mapping to a deterministic finite-state machine environment that serves interactive challenges to the agent.

๐ŸŽฏ Action Space

The agent has 6 action types to interact with the environment:

Action TypeTargetParametersDescription
investigateService name`{"aspect": "logs\metrics\connections\config"}`Examine a system for detailed information
diagnoseIncident ID{"root_cause": "<diagnosis>"}Declare the root cause of an incident
prioritizeIncident ID`{"priority": "P1\P2\P3\P4"}`Assign severity level
remediateService name{"action": "<fix description>"}Apply a fix to a service
escalateIncident ID{"team": "<team>", "reason": "<why>"}Escalate to specialist team
verifyService name{}Verify that a fix was successful

Action JSON Format

json
{
  "action_type": "investigate",
  "target": "database_primary",
  "parameters": {"aspect": "logs"}
}

๐Ÿ‘๏ธ Observation Space

After each action, the agent receives:

FieldTypeDescription
alertslist[dict]Active alerts with severity, service, title, message
system_statusdictService health metrics (CPU, memory, error rate, latency)
investigation_resultsstrDetailed output from the last action
time_elapsedfloatSimulated minutes since incident start
incidents_resolvedintNumber of incidents fixed
incidents_remainingintNumber still active
last_action_error`str\null`Error feedback for invalid actions
current_stepintCurrent step number
max_stepsintMaximum steps for this task

๐Ÿ—๏ธ System Architecture

mermaid
graph TD
    A[Agent / LLM] -->|HTTP POST /step, /reset| B
    B[FastAPI Server] -->|Action JSON| C[IncidentTriageEnv]
    
    subgraph Environment Core
    C --> D[Scenario Generator]
    C --> E[State Manager]
    C --> F[Reward Engine]
    C --> G[Task Graders]
    end
    
    F -.->|Dense Rewards| C
    E -.->|Observations| B
    B -.->|Response| A
    
    style A fill:#f9f,stroke:#333,stroke-width:2px
    style B fill:#bbf,stroke:#333,stroke-width:2px
    style C fill:#bfb,stroke:#333,stroke-width:2px
text
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚     Agent / LLM          โ”‚
โ”‚  (OpenAI API Client)     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
           โ”‚ HTTP (POST /step, /reset)
           โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   FastAPI Server         โ”‚
โ”‚   (app.py)               โ”‚
โ”‚   โ”œโ”€โ”€ /reset             โ”‚
โ”‚   โ”œโ”€โ”€ /step              โ”‚
โ”‚   โ”œโ”€โ”€ /state             โ”‚
โ”‚   โ””โ”€โ”€ /health            โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
           โ”‚
           โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  IncidentTriageEnv       โ”‚
โ”‚  (incident_environment)  โ”‚
โ”‚  โ”œโ”€โ”€ Scenarios           โ”‚
โ”‚  โ”œโ”€โ”€ Reward Engine       โ”‚
โ”‚  โ””โ”€โ”€ Task Graders        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

The architecture strictly follows the OpenEnv specification, utilizing a thin HTTP API layer (FastAPI) wrapped around a highly decoupled Domain Logic core.


๐Ÿ“ Code Structure & Reproducibility

Reproducibility: The repository is containerized from day one. Both the environment server and the base inference evaluations can be perfectly replicated using the provided standard Dockerfile.

Project Structure

text
META-PYTORCH-HACKATHON/
โ”œโ”€โ”€ inference.py                          # Baseline inference script (root)
โ”œโ”€โ”€ Dockerfile                            # Container definition (root)
โ””โ”€โ”€ incident_triage_env/
    โ”œโ”€โ”€ __init__.py                       # Package exports
    โ”œโ”€โ”€ models.py                         # Action, Observation, State models
    โ”œโ”€โ”€ client.py                         # HTTP client
    โ”œโ”€โ”€ scenarios.py                      # Incident scenario data
    โ”œโ”€โ”€ reward.py                         # Reward computation engine
    โ”œโ”€โ”€ tasks.py                          # Task definitions + graders
    โ”œโ”€โ”€ openenv.yaml                      # OpenEnv manifest
    โ”œโ”€โ”€ pyproject.toml                    # Dependencies
    โ””โ”€โ”€ server/
        โ”œโ”€โ”€ __init__.py
        โ”œโ”€โ”€ incident_environment.py       # Core environment logic
        โ”œโ”€โ”€ app.py                        # FastAPI application
        โ””โ”€โ”€ Dockerfile                    # Standalone container

๐Ÿง  Core Logic Deep Dive

The environment operates as a responsive State Machine. Each step transitions the incident state through logic defined natively in incident_environment.py.

  • โ€”Grading Engine: Instead of relying purely on sparse boolean rewards, the final score grade uses a weighted matrix integrating time efficiency, resolution accuracy, dynamic prioritization correctness, and the proper identification of connected system components (handling correlations and ignoring red herrings).

๐Ÿ† Reward Function

The environment provides dense, per-step reward signals (not just sparse end-of-episode) to optimize trajectory evaluation.

Positive Rewards

ActionReward
Useful investigation+0.05
Correct diagnosis+0.15
Root cause identified+0.20
Correct priority+0.08
Correct remediation+0.20
Successful verification+0.10
Red herring correctly ignored+0.05
Efficiency bonus (per step saved)+0.02

Penalties

BehaviorPenalty
Wrong diagnosis-0.10
Wrong remediation (destructive)-0.15
Redundant investigation-0.03
Wrong triage order (P2 before P1)-0.08
Each step over expected-0.01
Invalid action-0.05

โš–๏ธ Architecture Decisions

  1. 1.Pydantic Validation: Used heavily in models.py to ensure that standard OpenAPI specifications map flawlessly to internal Python primitives.
  2. 2.Deterministic Scenarios: Scenarios use fixed seeds to ensure standard baseline comparisons. Agents face the same issues every time to guarantee reproducibility.
  3. 3.Stateless HTTP API with Internal State: Following the standard reinforcement learning architecture, the FastAPI instance tracks global episode history in-memory allowing lightweight local iterations.

โšก Performance Optimizations

  • โ€”In-Memory Tracking: Eliminated arbitrary database overhead by keeping episode histories completely in-memory, leading to incredibly low-latency trajectory feedback loops (~2ms response times).
  • โ€”Targeted Matching Strategies: Leveraging highly optimized regular expressions combined with structured dictionary mapping to check fix correctness, avoiding the latency and compute cost of an integrated LLM-as-a-judge system on every single action.

๐Ÿš€ Setup Instructions

Prerequisites

  • โ€”Python 3.10+
  • โ€”Docker (for containerized deployment)

Local Development

bash
# 1. Clone the repo
git clone https://github.com/rohanjain1648/META-PYTORCH-HACKATHON.git
cd META-PYTORCH-HACKATHON

# 2. Install dependencies
pip install -e ./incident_triage_env

# 3. Start the environment server
cd incident_triage_env
uvicorn server.app:app --host 0.0.0.0 --port 8000

# 4. In another terminal, test it
curl -X POST http://localhost:8000/reset -H "Content-Type: application/json" -d '{"task_name": "single_incident"}'
curl -X POST http://localhost:8000/step -H "Content-Type: application/json" -d '{"action_type": "investigate", "target": "database_primary", "parameters": {"aspect": "logs"}}'

Docker

bash
# Build
docker build -t incident-triage-env .

# Run
docker run -p 8000:8000 incident-triage-env

# Test
curl http://localhost:8000/health

Run Inference

bash
# Set environment variables
export HF_TOKEN="your-hf-token"
export API_BASE_URL="https://router.huggingface.co/v1"
export MODEL_NAME="Qwen/Qwen2.5-72B-Instruct"
export ENV_BASE_URL="http://localhost:8000"

# Run baseline inference on all 3 tasks
python inference.py

๐Ÿ“ˆ Baseline Scores

Baseline performance using Qwen/Qwen2.5-72B-Instruct:

TaskDifficultyScoreSteps
single_incident๐ŸŸข Easy~0.756
multi_incident๐ŸŸก Medium~0.5015
cascading_failure๐Ÿ”ด Hard~0.3025

Scores may vary based on model temperature and API latency.


๐Ÿ”ง API Reference

POST /reset

Reset the environment for a new episode.

json
{"task_name": "single_incident", "seed": 42}

POST /step

Execute one action.

json
{"action_type": "investigate", "target": "database_primary", "parameters": {"aspect": "logs"}}

GET /state

Get current episode state.

GET /health

Health check endpoint.

GET /tasks

List available tasks.

GET /grade

Get the final grade for the current episode.


๐Ÿ›‘ Known Limitations

  • โ€”Concurrency limits: Support for massive parallel concurrent episodic executions natively across multi-threaded operations requires a local distributed state enhancement.
  • โ€”Generative telemetry: Logs and metrics responses use comprehensive parameterized templates rather than relying strictly on an LLM to dynamically generate endless unique logs on-the-fly, due to local latency requirements.

๐Ÿ”ฎ What I'd Improve With More Time

  1. 1.LLM-as-a-Judge Evaluation: Implement smaller-scale LLMs for the semantic validation of unstructured remediation descriptions to account for variations in developer code fixing patterns.
  2. 2.Multi-Agent Simulation Options: Introduce the ability for the active responder agent to dynamically delegate sub-tasks to autonomous secondary sub-agents (e.g. escalating to a DBA agent).
  3. 3.State Persistence: Plug in natively configured Redis or SQLite adapters to support crash-resumes and infinite horizontal trajectory scaling capabilities for intense scale evaluations.

๐Ÿ“„ License

MIT License