Harshvardhan-M/customer-support-triage
0
๐ง Customer Support Triage โ OpenEnv Environment
An OpenEnv-compliant RL environment where AI agents learn to triage real-world customer support tickets: classify urgency, route to departments, escalate sensitive cases, and draft responses.
๐ [Interactive Demo โ](/demo)
Why This Environment?
Customer support triage is a high-volume, high-stakes real-world task:
- Misrouting or mis-prioritizing tickets costs revenue and customer trust
- Requires multi-step reasoning: inferring urgency from tone, applying business rules, recognising legal risk
- Evaluation is deterministic โ no human labellers needed
- The RL/agent community can immediately use this for evaluation and training
Tasks
API
# Reset
curl -X POST http://localhost:7860/reset \
-H "Content-Type: application/json" \
-d '{"task_name": "full_triage"}'
# Step
curl -X POST http://localhost:7860/step \
-H "Content-Type: application/json" \
-d '{"action_type": "classify", "urgency": "critical"}'
# State
curl http://localhost:7860/state
# Validate spec compliance
curl http://localhost:7860/validateObservation Space
{
"current_ticket": {
"ticket_id": "TKT-005",
"subject": "URGENT: Production database is DOWN",
"body": "...",
"product": "CloudDB Enterprise",
"channel": "phone",
"created_at": "2024-03-15T02:47:00Z"
},
"customer": {
"email": "sre@megacorp.com",
"tier": "enterprise",
"account_age_days": 1825,
"total_tickets": 42,
"previous_tickets": [...]
},
"queue_position": 3,
"total_in_queue": 5,
"task_name": "full_triage",
"available_actions": ["classify","route","escalate","draft_response","resolve"],
"step_count": 7,
"episode_reward": 0.85,
"done": false,
"last_action_feedback": "dept='technical' vs 'billing' โ 0.00",
"last_action_error": null
}Action Space
{
"action_type": "draft_response",
"response_draft": "We are treating this as a P0 incident and escalating immediately.",
"reasoning": "Enterprise customer, $3k/min revenue loss โ needs immediate human escalation."
}Reward Function
Shaped across the full trajectory โ not sparse:
Reward clamped to [โ1.0, 1.0] per step.
Setup
# Local
pip install -r requirements.txt
uvicorn app:app --host 0.0.0.0 --port 7860
# Docker
docker build -t cst-env .
docker run -p 7860:7860 cst-env
# Run baseline agent
export API_BASE_URL="https://api.openai.com/v1"
export MODEL_NAME="gpt-4o-mini"
export HF_TOKEN="your-key"
export ENV_BASE_URL="http://localhost:7860"
python inference.py
# Pre-submission validation
python validate.pyBaseline Scores
Measured with gpt-4o-mini at temperature 0:
The hard task genuinely challenges frontier models โ escalation decisions and response quality both require multi-step business reasoning.
Project Structure
โโโ app.py FastAPI app (HF Space entry point)
โโโ demo.py Gradio interactive demo (mounted at /demo)
โโโ inference.py Baseline agent script
โโโ validate.py Pre-submission validator
โโโ openenv.yaml OpenEnv spec metadata
โโโ Dockerfile
โโโ requirements.txt
โโโ README.md
โโโ env/
โโโ __init__.py
โโโ environment.py Core OpenEnv class: reset() / step() / state()
โโโ models.py Pydantic models: Observation, Action, Reward
โโโ ticket_data.py 13 synthetic tickets with ground-truth labels
โโโ graders.py Deterministic graders for all 3 tasks
โโโ reward.py Shaped reward functionOpenEnv Compliance
- [x] Typed Pydantic models:
TriageObservation,TriageAction,TriageReward - [x]
reset(task_name)โTriageObservation - [x]
step(action)โ(observation, reward, done, info) - [x]
state()โ full internal state dict - [x]
openenv.yamlwith complete metadata - [x] 3 tasks: easy โ medium โ hard
- [x] All grader scores in [0.0, 1.0], deterministic
- [x] Non-sparse shaped reward
- [x]
inference.pyusing OpenAI client - [x] Working
Dockerfile - [x] 22/22 unit tests passing
