pavan1910/ticket-triage-openenv
๐ซ 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?
๐๏ธ 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:
Example Action
{
"action_type": "categorize",
"ticket_id": "T1",
"payload": "technical"
}๐๏ธ Observation Space
Each observation contains:
Ticket Fields
๐ Tasks
Task Easy (2 tickets)
Difficulty: Straightforward categorization and response. Both tickets have clear categories and need basic responses.
Task Medium (3 tickets)
Difficulty: One ticket requires escalation. Agent must recognize that a double-charge (angry customer) needs senior team involvement.
Task Hard (4 tickets)
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
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
# 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.pyDocker
# 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:
# The Dockerfile handles everything โ just deploy
# Tag your space with "openenv"๐ Baseline Scores
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:
{"task_id": "task_easy"}Response:
{
"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:
{
"action": {
"action_type": "categorize",
"ticket_id": "T1",
"payload": "technical"
}
}Response:
{
"observation": {...},
"reward": 0.15,
"done": false,
"info": {"step": 1, "episode_reward": 0.15}
}GET /state
Get the current environment state.
Response:
{
"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
