CoolFace
Apppublic

hyperlinken/ALT_DESIGN

sourceHugging Faceapache-2.0updated 6mo agoView on Hugging Face
0likes
App README

๐ŸŽซ IT Helpdesk Triage & Incident Management โ€” OpenEnv

![OpenEnv](https://huggingface.co/openenv) ![Python 3.11](https://python.org) ![FastAPI](https://fastapi.tiangolo.com) ![License](LICENSE)

A production-grade OpenEnv RL training environment that simulates a real enterprise IT Service Desk. An AI agent receives incoming IT support tickets and must make triage decisions โ€” classifying, prioritising, routing, escalating, and ultimately managing a cascading PostgreSQL database outage spanning seven simultaneous tickets.

Built for the Meta ร— Hugging Face OpenEnv AI Hackathon โ€” Round 1.

๐ŸŒ Environment Description & Motivation

Every enterprise runs an IT service desk. Triage quality โ€” getting the right ticket to the right team at the right priority โ€” directly impacts SLA compliance, business continuity, and employee productivity. Poor triage means P1 outages sitting in a P3 queue, payroll batches missing bank cut-offs, or security breaches going uninvestigated.

This environment trains AI agents on realistic, high-stakes triage scenarios drawn from actual enterprise incident patterns. The skills learned here transfer directly to production helpdesk automation, on-call decision support, and agentic ITSM systems.

Why this domain is non-trivial for LLMs:

  • โ€”Tickets are ambiguous โ€” the same symptom (slow application) can be P1 or P3 depending on business context
  • โ€”Incident detection requires correlating multiple tickets across time (root-cause reasoning)
  • โ€”Remediation steps must be operationally correct, ordered, and specific โ€” not generic advice
  • โ€”Noise filtering is required in the hard task (2 of 7 tickets are irrelevant to the incident)

๐Ÿ—‚๏ธ Tasks

Three tasks of increasing difficulty, each with its own grader weights and success criteria.

Task IDDifficultyTicketsMax StepsKey Challenge
basic_triage๐ŸŸข Easy510Category + Priority + Team routing
priority_routing๐ŸŸก Medium510Incident detection + Escalation decisions
incident_escalation๐Ÿ”ด Hard715Cascading DB outage + Noise filtering + Remediation steps

๐ŸŸข Task 1 โ€” Basic Triage (Easy)

Five standalone IT tickets covering the most common helpdesk categories: a jammed HR printer (hardware/P3), a locked Salesforce account with a 3 PM client proposal deadline (access/P2), a 45-user Wi-Fi degradation (network/P2), a live CEO-fraud phishing attempt (security/P1), and an Excel macro broken by an overnight Office update (software/P3).

Agent must correctly assign: category, priority (P1โ€“P4), and resolver team for each ticket.

Expected difficulty: A frontier model should score ~0.85โ€“1.0. A weaker model will struggle with the security/P1 escalation and the access vs. software distinction.

๐ŸŸก Task 2 โ€” Priority Routing (Medium)

Five high-stakes enterprise tickets arriving simultaneously: SAP ERP degrading with 1,200 employees' payroll at risk of missing a bank ACH cut-off (performance/P1), a new-hire onboarding request (access/P4), e-commerce 503 errors at $800/min revenue loss (software/P1), VPN drops affecting 15 remote engineers (network/P2), and a SIEM alert showing possible lateral movement in the customer database (security/P1).

Agent must additionally: detect which tickets constitute major incidents, assign correct incident IDs, and decide whether to escalate to senior management.

Expected difficulty: Incident detection and escalation require reasoning across multiple tickets. The new-hire ticket is a deliberate P4 noise trap โ€” escalating it to management incurs a penalty.

๐Ÿ”ด Task 3 โ€” Incident Escalation (Hard)

A PostgreSQL WAL-corruption event takes down db-prod-primary at 14:32. Seven tickets flood in over 23 minutes:

  • โ€”TKT-H001 โ€” Primary DB completely unresponsive (WAL corruption)
  • โ€”TKT-H002 โ€” Auth service returning 500s (depends on primary DB)
  • โ€”TKT-H003 โ€” E-commerce checkout failing ($2,400/min revenue loss)
  • โ€”TKT-H004 โ€” โš ๏ธ Noise: Team lunch reminder
  • โ€”TKT-H005 โ€” Metabase dashboards frozen (exec presentation in 80 min)
  • โ€”TKT-H006 โ€” โš ๏ธ Noise: TLS cert expiring in 7 days (planned, non-urgent)
  • โ€”TKT-H007 โ€” Nightly exec reporting batch job failed

Agent must: identify the 5 incident-linked tickets, declare INC-MAJOR-01, filter out the 2 noise tickets, and provide specific ordered remediation steps for each P1 ticket (DB failover, auth service restart, checkout recovery).

Expected difficulty: Genuinely challenges frontier models. Resolution steps are NLP-scored against ground-truth runbooks โ€” generic advice does not score well.


๐Ÿ“ Action Space

python
class TriageAction(BaseModel):
    ticket_id:              str             # Exact ID of the ticket being triaged
    category:               TicketCategory  # hardware | software | network | security
                                            # access | database | performance | other
    priority:               TicketPriority  # P1 (Critical) | P2 (High)
                                            # P3 (Medium)   | P4 (Low)
    assigned_team:          AssignedTeam    # infrastructure | application_support
                                            # network_ops | security_ops
                                            # database_admin | helpdesk
    is_part_of_incident:    bool            # True when ticket is a major-incident symptom
    incident_id:            str | None      # e.g. "INC-MAJOR-01" (medium + hard tasks)
    resolution_steps:       list[str]|None  # Ordered remediation steps (hard task P1s)
    escalate_to_management: bool            # Page senior management / C-suite

Priority definitions (ITIL standard):

  • โ€”P1 โ€” Critical: complete outage or business-stopping event, SLA 1 hour
  • โ€”P2 โ€” High: significant degradation or multiple users impacted, SLA 4 hours
  • โ€”P3 โ€” Medium: partial degradation, workaround available, SLA 8 hours
  • โ€”P4 โ€” Low: cosmetic, informational, or planned work, SLA 48 hours

๐Ÿ‘๏ธ Observation Space

python
class Observation(BaseModel):
    task_id:          str            # Active task identifier
    current_ticket:   Ticket | None  # Next ticket to triage (None = queue exhausted)
    queue_remaining:  int            # Tickets still waiting in queue
    processed_count:  int            # Tickets triaged so far this episode
    step_number:      int            # Current step (0-based)
    action_feedback:  str | None     # Correctness feedback on the previous action
    cumulative_score: float          # Running mean reward 0.0โ€“1.0
    episode_done:     bool           # True when episode has ended
    active_incidents: list[str]      # Incident IDs declared so far
    hints:            list[str]      # Task-level guidance for the agent

class Ticket(BaseModel):
    id:                  str       # Unique identifier e.g. "TKT-H001"
    subject:             str       # One-line summary
    description:         str       # Full free-text from reporter
    reporter:            str       # Reporter name
    reporter_department: str       # Business department
    timestamp:           str       # ISO-8601 creation time
    affected_systems:    list[str] # Hostnames / service identifiers
    affected_users_count: int      # Number of end-users impacted
    sla_hours:           int       # SLA resolution target in hours

๐Ÿ’ฐ Reward Function

Rewards are dense โ€” computed per step across 6 independent dimensions, not just at episode end. All values are strictly bounded to [0.0, 1.0]. This provides a continuous learning signal suitable for policy gradient and GRPO training.

Grader weight profiles by difficulty

DimensionEasyMediumHardNotes
Category classification0.400.280.20Exact match required
Priority assignment0.350.220.18Partial credit for ยฑ1 level
Team routing0.250.180.14Exact match from 6 teams
Incident detectionโ€”0.180.20Medium + Hard only
Escalation decisionโ€”0.140.12Penalty for over-escalating P4
Resolution qualityโ€”โ€”0.16Hard only โ€” NLP scored

Partial credit rules

Priority: Assigning P2 when P1 is expected scores 0.5 instead of 0.0. This creates a learning gradient rather than a hard cliff, allowing models to learn from near-misses.

Incident detection: Correctly identifying is_part_of_incident=True/False scores 0.7. Providing the correct incident_id (e.g. INC-MAJOR-01) on top of that scores 1.0.

Resolution steps (Hard only): NLP-scored against ground-truth runbooks using a weighted combination of keyword recall (35%) and ordered step recall (65%). Agents that cover the right concepts in their own words are rewarded โ€” exact string matching is not required.

Escalation penalty: Escalating a P4 low-priority ticket to senior management incurs a -0.15 penalty, preventing reward hacking via an always-escalate strategy.


๐Ÿš€ Setup & Usage Instructions

Prerequisites

  • โ€”Python 3.11+
  • โ€”Docker (for containerised deployment)
  • โ€”An OpenAI-compatible API key (set as HF_TOKEN)

Local development

bash
# 1. Clone the repo
git clone https://huggingface.co/spaces/hyperlinken/triage
cd triage

# 2. Install dependencies
pip install -r requirements.txt

# 3. Start the server
uvicorn app:app --host 0.0.0.0 --port 7860 --reload

# 4. Run the baseline inference script (separate terminal)
export API_BASE_URL="https://api.openai.com/v1"
export MODEL_NAME="gpt-4o-mini"
export HF_TOKEN="your_api_key_here"
python inference.py

Docker

bash
# Build and run locally
docker build -t it-triage-env .
docker run -p 7860:7860 \
  -e API_BASE_URL="https://api.openai.com/v1" \
  -e MODEL_NAME="gpt-4o-mini" \
  -e HF_TOKEN="your_api_key" \
  it-triage-env

# Verify it's running
curl http://localhost:7860/health

Manual curl interaction

bash
# Reset to the hard task
curl -X POST http://localhost:7860/reset \
  -H "Content-Type: application/json" \
  -d '{"task_id": "incident_escalation"}'

# Submit a triage action for the DB ticket
curl -X POST http://localhost:7860/step \
  -H "Content-Type: application/json" \
  -d '{
    "ticket_id": "TKT-H001",
    "category": "database",
    "priority": "P1",
    "assigned_team": "database_admin",
    "is_part_of_incident": true,
    "incident_id": "INC-MAJOR-01",
    "escalate_to_management": true,
    "resolution_steps": [
      "Promote db-prod-replica-01 to primary using SELECT pg_promote()",
      "Update all application DB_HOST configs to point to replica",
      "Do NOT restart db-prod-primary โ€” preserve WAL for forensics",
      "Open bridge call with DBA team and follow runbook DB-DR-001"
    ]
  }'

# Check full environment state
curl http://localhost:7860/state

๐Ÿ“Š Baseline Scores

Produced by running inference.py with gpt-4o-mini at temperature=0. Scores are deterministic and reproducible across runs.

TaskModelScore
basic_triagegpt-4o-mini0.92
priority_routinggpt-4o-mini0.76
incident_escalationgpt-4o-mini0.58
Overall Averagegpt-4o-mini0.75

Full reproducible results saved to baseline_scores.json after running inference.py.


๐Ÿ”Œ API Reference

MethodPathDescription
GET/Interactive HTML dashboard
GET/healthJSON health check โ€” {"status": "ok", "tasks": [...]}
POST/resetStart new episode โ€” body: {"task_id": "basic_triage"}
POST/stepSubmit TriageAction โ†’ returns StepResult(obs, reward, done, info)
GET/stateFull EnvironmentState snapshot with action history
GET/tasksAll tasks with difficulty, ticket count, grader weights
GET/docsInteractive Swagger UI
GET/redocReDoc UI

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                   OpenEnv Interface                      โ”‚
โ”‚  POST /reset  โ”€โ”€โ–บ  Observation (first ticket in queue)  โ”‚
โ”‚  POST /step   โ”€โ”€โ–บ  StepResult (obs + reward + done)     โ”‚
โ”‚  GET  /state  โ”€โ”€โ–บ  EnvironmentState (full snapshot)     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                         โ”‚
         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
         โ”‚   ITTriageEnvironment (core)   โ”‚
         โ”‚                                โ”‚
         โ”‚  Task Registry                 โ”‚
         โ”‚  โ”œโ”€ basic_triage    (easy)     โ”‚
         โ”‚  โ”œโ”€ priority_routing (medium)  โ”‚
         โ”‚  โ””โ”€ incident_escalation (hard) โ”‚
         โ”‚                                โ”‚
         โ”‚  Dense Reward Engine           โ”‚
         โ”‚  โ”œโ”€ Category score (exact)     โ”‚
         โ”‚  โ”œโ”€ Priority score (partial)   โ”‚
         โ”‚  โ”œโ”€ Routing score  (exact)     โ”‚
         โ”‚  โ”œโ”€ Incident score (partial)   โ”‚
         โ”‚  โ”œโ”€ Escalation score + penalty โ”‚
         โ”‚  โ””โ”€ Resolution score (NLP)     โ”‚
         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“ฆ File Structure

it-triage-env/
โ”œโ”€โ”€ models.py         # Pydantic Action / Observation / State / Reward models
โ”œโ”€โ”€ environment.py    # Core environment logic, ticket datasets, reward engine
โ”œโ”€โ”€ app.py            # FastAPI server โ€” OpenEnv REST endpoints
โ”œโ”€โ”€ client.py         # Typed HTTP client for use in agents and inference
โ”œโ”€โ”€ inference.py      # Baseline LLM inference script (uses HF_TOKEN)
โ”œโ”€โ”€ openenv.yaml      # OpenEnv specification metadata
โ”œโ”€โ”€ requirements.txt  # Python dependencies
โ”œโ”€โ”€ Dockerfile        # Container definition for HF Spaces deployment
โ””โ”€โ”€ README.md         # This file

โš™๏ธ Environment Variables

VariableRequiredDefaultDescription
HF_TOKENinferenceโ€”API key for the LLM (OpenAI-compatible)
API_BASE_URLinferencehttps://api.openai.com/v1LLM API base URL
MODEL_NAMEinferencegpt-4o-miniLLM model identifier
ENV_BASE_URLinferencehttp://localhost:7860OpenEnv server URL
PORToptional7860Server port override