CoolFace
Apppublic

pavan1910/ticket-triage-openenv

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

๐ŸŽซ Ticket Triage โ€” OpenEnv Environment

A production-grade OpenEnv environment that simulates IT helpdesk ticket triage โ€” a task humans do millions of times daily. An AI agent must read customer support tickets, categorize them, assess priority, craft responses, decide on escalations, and properly close each case.


๐ŸŒ Why Ticket Triage?

DimensionValue
Real-world utilityCustomer support is a $400B+ industry. Every company needs ticket triage.
Multi-step reasoningAgents must categorize โ†’ prioritize โ†’ investigate โ†’ respond โ†’ escalate โ†’ close
Judgment requiredSecurity incidents need escalation, not responses. Angry customers need empathy.
Natural difficultySimple FAQ โ†’ billing disputes โ†’ security breaches with legal implications
Evaluation clarityEach ticket has objective ground truth for grading

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚              Agent (inference.py)               โ”‚
โ”‚   OpenAI Client โ†’ JSON actions โ†’ HTTP POST     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ”‚  POST /reset, /step, /state
                   โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚          FastAPI Server (server/app.py)         โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚  โ”‚  reset()  โ”‚  โ”‚  step()  โ”‚  โ”‚   state()    โ”‚ โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”           โ”‚
โ”‚         โ”‚   Environment State      โ”‚           โ”‚
โ”‚         โ”‚   - Tickets (GT + Agent) โ”‚           โ”‚
โ”‚         โ”‚   - Scores & Rewards     โ”‚           โ”‚
โ”‚         โ”‚   - Step Counter         โ”‚           โ”‚
โ”‚         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜           โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐ŸŽฎ Action Space

The agent can perform 7 action types. Each action is a JSON object:

Action`action_type``payload`Description
Categorizecategorize`technical\billing\shipping\security\general`Set ticket category
Set Priorityset_priority`low\medium\high\critical`Set ticket urgency
RespondrespondResponse text (โ‰ฅ10 chars)Send customer-facing response
Escalateescalate(empty)Send to senior team
Add Noteadd_noteNote text (โ‰ฅ5 chars)Add internal investigation note
Closeclose(empty)Mark ticket as resolved
No-opnoop(empty)Skip turn (penalized)

Example Action

json
{
  "action_type": "categorize",
  "ticket_id": "T1",
  "payload": "technical"
}

๐Ÿ‘๏ธ Observation Space

Each observation contains:

FieldTypeDescription
ticketsList[Ticket]All tickets with current state
last_feedbackstrFeedback from the last action
current_scorefloatCurrent grader score [0.0, 1.0]
pending_countintTickets still open
resolved_countintTickets closed
escalated_countintTickets escalated
step_numberintCurrent step in the episode
max_stepsintMaximum steps allowed

Ticket Fields

FieldTypeDescription
idstrTicket ID (e.g., "T1")
subjectstrTicket subject line
bodystrFull ticket description
senderstrCustomer email
sentimentstr`positive\neutral\negative\angry`
statusstr`open\in_progress\escalated\closed`
categorystr?Agent-assigned category
prioritystr?Agent-assigned priority
has_responseboolWhether agent has responded
escalatedboolWhether ticket was escalated
notesList[str]Internal notes added by agent

๐Ÿ“‹ Tasks

Task Easy (2 tickets)

TicketSubjectExpected Actions
T1Login issuecategorize=technical, priority=medium, respond, close
T2Refund requestcategorize=billing, priority=medium, respond, close

Difficulty: Straightforward categorization and response. Both tickets have clear categories and need basic responses.

Task Medium (3 tickets)

TicketSubjectExpected Actions
T3Password resetcategorize=technical, priority=low, respond, close
T4Missing ordercategorize=shipping, priority=high, respond, close
T5Double chargedcategorize=billing, priority=high, respond, escalate, close

Difficulty: One ticket requires escalation. Agent must recognize that a double-charge (angry customer) needs senior team involvement.

Task Hard (4 tickets)

TicketSubjectExpected Actions
T6Account hackedcategorize=security, priority=critical, escalate only (no response!), close
T7API 500 errorcategorize=technical, priority=critical, respond, escalate, close
T8Want to upgrade plancategorize=billing, priority=low, respond, close
T9Legal threat - data breachcategorize=security, priority=critical, escalate only (no response!), close

Difficulty:

  • โ€”T6 & T9 require restraint โ€” security incidents should be escalated, NOT responded to (leaking information risk)
  • โ€”T7 is a production outage requiring both response and escalation
  • โ€”Four tickets with different priorities and handling strategies forces genuine triage

๐Ÿ“Š Reward Function

Step Rewards

ActionCorrectIncorrect
Categorize+0.15-0.05
Set Priority+0.10-0.05
Respond (needed)+0.08 to +0.15โ€”
Respond (not needed)-0.03โ€”
Escalate (needed)+0.20โ€”
Escalate (not needed)-0.10โ€”
Add Note+0.03-0.02
Close (all correct)+0.15โ€”
Close (mostly correct)+0.02 to +0.08โ€”
Close (premature)-0.10โ€”
Noop-0.02โ€”

Final Grader Score (0.0 โ†’ 1.0)

Per ticket, evaluated on 5 criteria:

  • โ€”Category (25%): Correct categorization
  • โ€”Priority (20%): Correct priority (partial credit for ยฑ1 level)
  • โ€”Response (25%): Appropriate response with relevant keywords
  • โ€”Escalation (20%): Correct escalation decision
  • โ€”Closure (10%): Proper closure after handling

Score = average across all tickets, capped at 1.0.


๐Ÿš€ Setup & Usage

Local Development

bash
# Install dependencies
pip install -r requirements.txt

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

# In another terminal, run the baseline
export API_BASE_URL="https://api.openai.com/v1"
export MODEL_NAME="gpt-4o-mini"
export HF_TOKEN="your-api-key"
python inference.py

Docker

bash
# Build
docker build -t ticket-triage .

# Run
docker run -p 8000:8000 ticket-triage

# Test health
curl http://localhost:8000/health
# {"status":"ok"}

# Test reset
curl -X POST http://localhost:8000/reset \
  -H "Content-Type: application/json" \
  -d '{"task_id": "task_easy"}'

Hugging Face Spaces

This environment is deployed as a Hugging Face Space with Docker:

bash
# The Dockerfile handles everything โ€” just deploy
# Tag your space with "openenv"

๐Ÿ“ˆ Baseline Scores

TaskExpected Score RangeModel
task_easy0.75 โ€“ 0.95gpt-4o-mini
task_medium0.55 โ€“ 0.80gpt-4o-mini
task_hard0.35 โ€“ 0.65gpt-4o-mini

Scores vary by model capability. Frontier models (GPT-4o, Claude) should score higher.


๐Ÿ”ง API Reference

POST /reset

Reset the environment to start a new episode.

Request:

json
{"task_id": "task_easy"}

Response:

json
{
  "observation": {
    "tickets": [...],
    "last_feedback": "Environment reset. Task: task_easy...",
    "current_score": 0.0,
    "pending_count": 2,
    "resolved_count": 0,
    "escalated_count": 0,
    "step_number": 0,
    "max_steps": 20
  },
  "info": {"task_id": "task_easy"}
}

POST /step

Take an action in the environment.

Request:

json
{
  "action": {
    "action_type": "categorize",
    "ticket_id": "T1",
    "payload": "technical"
  }
}

Response:

json
{
  "observation": {...},
  "reward": 0.15,
  "done": false,
  "info": {"step": 1, "episode_reward": 0.15}
}

GET /state

Get the current environment state.

Response:

json
{
  "task_id": "task_easy",
  "step_count": 3,
  "max_steps": 20,
  "score": 0.45,
  "done": false,
  "episode_reward": 0.35
}

GET /health

Health check endpoint.


๐Ÿ“ Project Structure

openenv-support-triage/
โ”œโ”€โ”€ server/
โ”‚   โ”œโ”€โ”€ __init__.py         # Package init
โ”‚   โ”œโ”€โ”€ models.py           # Pydantic models (Action, Observation, State, Ticket)
โ”‚   โ””โ”€โ”€ app.py              # FastAPI server with environment logic
โ”œโ”€โ”€ inference.py             # Baseline inference script
โ”œโ”€โ”€ openenv.yaml             # OpenEnv manifest
โ”œโ”€โ”€ Dockerfile               # Container definition
โ”œโ”€โ”€ requirements.txt         # Python dependencies
โ”œโ”€โ”€ pyproject.toml           # Package configuration
โ””โ”€โ”€ README.md                # This file

๐Ÿ“„ License

MIT