sumit01-sj/Email_Triage_OpenEnv
๐ง Email Triage OpenEnv
A production-grade reinforcement learning environment simulating real-world email triage and management โ the kind of work that takes hours of human attention every day in every company.
  
๐ฏ Motivation
Email overload is a universal workplace problem. Professionals spend 28% of their workday managing email. Effective triage โ classifying urgency, routing to the right team, detecting sensitive information, and crafting appropriate responses โ requires both domain knowledge and nuanced judgment.
This environment challenges agents to perform this full pipeline, providing rich incremental feedback and progressively harder tasks.
๐๏ธ Environment Overview
๐ Action Space
Actions are JSON objects with the following types:
Urgency levels: low | medium | high | critical
Categories: billing | support | inquiry | complaint | spam | hr | legal | internal
Departments: billing | technical-support | sales | hr | legal | general
๐๏ธ Observation Space
Each observation is a JSON object containing:
{
"inbox": [...],
"processed": [...],
"step": 3,
"task_id": "email-triage-hard",
"instructions": "...",
"available_actions": ["classify", "route", "flag_pii", "draft_response", "submit_report", "skip"],
"progress": 0.4,
"errors": []
}๐ Tasks
Task 1: Email Classification (Easy)
- ID:
email-triage-easy - Emails: 5 realistic business emails
- Objective: Classify each email by urgency and category
- Max Steps: 10
- Score Threshold: 0.75
Task 2: Email Routing + PII Detection (Medium)
- ID:
email-triage-medium - Emails: 8 emails (HR, legal, enterprise sales scenarios)
- Objective: Classify + route to correct department + flag any PII
- Max Steps: 15
- Score Threshold: 0.70
Task 3: Full Email Triage Pipeline (Hard)
- ID:
email-triage-hard - Emails: 10 emails including a CEO emergency and a regulatory compliance notice
- Objective: Full pipeline: classify โ route โ PII โ draft critical responses โ submit summary report
- Max Steps: 20
- Score Threshold: 0.65
๐ Reward Function
Rewards are incremental โ given after every action, not just at episode end.
๐ Baseline Performance
๐ Setup & Usage
Local Setup
git clone <your-repo>
cd email-triage-openenv
pip install -r requirements.txt
python server.pyRunning Inference
export HF_TOKEN="your-api-key"
export API_BASE_URL="https://api.openai.com/v1"
export MODEL_NAME="gpt-4.1-mini"
export TASK_ID="email-triage-hard"
python inference.pyDocker
docker build -t email-triage-openenv .
docker run -p 7860:7860 email-triage-openenv๐ API Reference
๐งช Running Tests
python -m pytest tests/ -v40 tests covering: reset, all three tasks, grader accuracy, reward correctness, and edge cases.
๐ Project Structure
.
โโโ inference.py # Hackathon submission entry point
โโโ server.py # FastAPI OpenEnv HTTP server
โโโ openenv.yaml # Environment metadata
โโโ requirements.txt
โโโ Dockerfile
โโโ README.md
โโโ env/
โ โโโ __init__.py
โ โโโ environment.py # EmailTriageEnv (main class)
โ โโโ models.py # Pydantic models
โ โโโ email_data.py # Realistic email datasets + ground truth
โ โโโ graders.py # Deterministic scoring functions
โโโ tests/
โโโ test_environment.py