aadhesh2025/ticket-triage-env
<div align="center">
π« Ticket Triage OpenEnv
A Real-World AI Agent Training Environment
Train AI agents to triage customer support tickets β classify, prioritize, and respond.
    
π Live Demo Β· π API Docs Β· π Tasks
</div>
π Why This Environment Exists
Every company receives hundreds of customer support tickets every day. Human agents must read each ticket, decide what type of problem it is, how urgent it is, and craft a helpful response. This process is:
- β±οΈ Time-consuming β reading and triaging takes hours daily
- π€ Judgment-heavy β requires experience and domain knowledge
- π Scalability bottleneck β hard to scale with growing user bases
This environment trains AI agents to automate that entire workflow.
ποΈ Environment Architecture
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β AI Agent (My Model) β
β β β
β βββββββββββΌβββββββββββ β
β β OpenEnv API β β
β β POST /reset β β Get a ticket β
β β POST /step β β Submit answerβ
β β GET /state β β Check status β
β βββββββββββ¬βββββββββββ β
β β β
β βββββββββββΌβββββββββββ β
β β TicketTriage Env β β
β β environment.py β β
β βββββββββββ¬βββββββββββ β
β β β
β ββββββββββββββββΌβββββββββββββββ β
β βΌ βΌ βΌ β
β Task 1 Grader Task 2 Grader Task 3 Grader β
β (Easy) (Medium) (Hard) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββποΈ Tasks Overview
π’ Task 1 β Ticket Categorization (Easy)
Example:
Input: "I was charged twice for my subscription"
Action: { "category": "billing" }
Reward: 1.0π‘ Task 2 β Category + Priority Assignment (Medium)
Example:
Action: { "category": "technical", "priority": "high" }
Reward: 1.0 (both correct) | 0.5 (one correct) | 0.0 (both wrong)π΄ Task 3 β Full Ticket Triage (Hard)
Example:
Action: {
"category": "billing",
"priority": "high",
"reply": "We sincerely apologize. Our billing team will process your refund within 24 hours."
}
Reward: 1.0π Observation & Action Spaces
Observation Space
{
"observation": {
"ticket_id": "T001",
"subject": "I was charged twice for my subscription",
"body": "Hello, I noticed two charges of $29.99 on my credit card..."
},
"task_id": "task1_categorize",
"task_description": "Classify the support ticket into: billing, technical, or general",
"action_schema": {
"category": "string β one of: billing | technical | general"
}
}Action Space
Task 1: { "category": "billing" }
Task 2: { "category": "billing", "priority": "high" }
Task 3:
{
"category": "billing",
"priority": "high",
"reply": "Thank you for contacting us. We will resolve your issue within 24 hours."
}π Reward Function
Task 1: R = 1.0 if category correct, else 0.0
Task 2: R = (0.5 Γ category_correct) + (0.5 Γ priority_correct)
Task 3: R = (0.34 Γ category_correct)
+ (0.33 Γ priority_correct)
+ (0.33 Γ reply_length >= 10 words)π API Reference
Python Example
import requests
BASE = "https://aadhesh2025-ticket-triage-env.hf.space"
# Start episode
obs = requests.post(f"{BASE}/reset", json={"task_id": "task1_categorize"}).json()
print(obs["observation"]["subject"])
# Submit action
result = requests.post(f"{BASE}/step", json={"action": {"category": "billing"}}).json()
print(f"Reward: {result['reward']}")π Baseline Scores
π Local Setup
# Clone
git clone https://github.com/Crypto-Type/ticket-triage-env
cd ticket-triage-env
# Install
pip install -r requirements.txt
# Run
uvicorn main:app --host 0.0.0.0 --port 7860 --reload
# Open: http://localhost:7860Run Inference Script
export API_BASE_URL="https://api-inference.huggingface.co/v1"
export MODEL_NAME="Qwen/Qwen2.5-72B-Instruct"
export HF_TOKEN="your_hf_token_here"
export ENV_BASE_URL="http://localhost:7860"
python inference.pyπ³ Docker
docker build -t ticket-triage-env .
docker run -p 7860:7860 ticket-triage-envπ Project Structure
ticket-triage-env/
βββ main.py # FastAPI server + UI dashboard
βββ environment.py # Core env: reset(), step(), state()
βββ tasks.py # Tasks, tickets, grader functions
βββ inference.py # LLM inference script (OpenAI client)
βββ baseline.py # Random baseline agent
βββ openenv.yaml # OpenEnv specification
βββ pyproject.toml # Python project config
βββ requirements.txt # Python dependencies
βββ Dockerfile # Container definition
βββ README.md # This fileπ§ͺ Environment Variables
π OpenEnv Compliance
- β Typed Pydantic models for Observation, Action, Reward
- β
POST /resetβ returns clean initial observation - β
POST /stepβ returns observation, reward, done, info - β
GET /stateβ returns current environment state - β
openenv.yamlwith full metadata - β Deployed on Hugging Face Spaces with Docker
- β
inference.pyusing OpenAI-compatible client - β Scores reproducible between runs
π€ Author
Aravind S β Built for OpenEnv Round 1 Β· Hugging Face Γ Meta AI Competition
<div align="center">
Built with β€οΈ using FastAPI Β· Docker Β· Hugging Face Spaces
π Try it Live Β· π API Docs
</div>
