AdamK29/Meta-OpenENV-Hackathon
๐ RL Email Triage Environment (OpenEnv)
An end-to-end Reinforcement Learning (RL) environment for intelligent email triage, where agents learn to classify, prioritize, and manage emails sequentially under real-world constraints.
๐ Live Environment (Hugging Face Space): https://adamk29-meta-openenv-hackathon.hf.space
๐ง Problem Statement
Modern email systems require more than classification:
- Emails arrive sequentially
- Some require urgent action
- Delays have consequences
- Mistakes accumulate over time
๐ This project models email handling as a Sequential Decision Making (RL Problem)
๐ฏ Objective
Train an intelligent agent that can:
- Process incoming emails
- Identify urgent emails correctly
- Clear inbox efficiently
- Maximize long-term reward
- Avoid critical failures
๐๏ธ Project Architecture
/
โโโ core/ # Core logic (dataset, reward, models)
โโโ server/ # OpenEnv server (FastAPI)
โโโ data/ # Email dataset
โโโ scripts/ # Validation scripts
โ
โโโ train_agent.py # RL training
โโโ test_agent.py # Model testing
โโโ inference.py # Rule-based baseline
โโโ interactive_ui.py # RL visualization UI
โโโ demo.py # Full pipeline
โ
โโโ client.py # Env client
โโโ Dockerfile
โโโ pyproject.toml
โโโ uv.lock
โโโ README.md๐ Environment Design
๐งฉ State (Observation)
Each step returns:
- email_text
- sender
- subject
- history
- message
๐ฎ Action Space
spam | important | urgent
๐ Environment Dynamics
- Emails arrive sequentially
- Agent acts per step
- Environment transitions
- Episode ends when inbox is cleared or failure occurs
๐งฉ Dataset
- Enron-style emails
- File: data/enron_sample.txt
๐ท๏ธ Labeling Logic
if contains (urgent/asap/deadline) โ urgent if contains (free/win/offer/$) โ spam else โ important
๐ Reward Design (Core RL)
- Correct classification โ +2.0
- Wrong classification โ -0.5
- Correct urgent handling โ +1.5
- Missed urgent โ -1.0
- Step penalty โ -0.01
- Progress reward โ +1/(remaining emails)
- Stability bonus โ +0.2
- Completion bonus โ up to +5
๐ Designed similar to goal-driven RL environments (like AirSim)
๐ค RL Training
Policy Gradient (REINFORCE):
- Neural network policy
- Action sampling
- Discounted rewards
- Entropy for exploration
โถ๏ธ Train Agent
python train_agent.pyModel saved as: email_agent.pth
๐งช Testing
โถ๏ธ Test Model
python test_agent.pyIncludes:
- Environment evaluation
- Custom samples
โก Inference (Baseline)
python inference.py๐จ Interactive UI
python interactive_ui.pyOpen: http://127.0.0.1:7860
Features:
- Trajectory view
- Reward curve
- RL logs
๐ฅ Full Demo
python demo.pyโ Train โ Test โ Launch UI โ Auto open browser
๐ ๏ธ Setup Guide
1. Clone Repo
git clone https://github.com/RongalaGeethikaLahari/Meta-OpenENV-Hackathon.git
cd Meta-OpenENV-Hackathon 2. Create Environment
python -m venv env
source env/bin/activate 3. Install Dependencies
pip install -r requirements.txt 4. Run Server (optional)
uvicorn server.app:app --port 8000 ๐ Hosted Environment
https://adamk29-meta-openenv-hackathon.hf.spaceโ ๏ธ Common Errors & Fixes
๐ SSL Error
Error: SSL: CERTIFICATEVERIFYFAILED
Fix:
pip install certifi
export SSL_CERT_FILE=$(python -m certifi) OR:
import ssl, certifi
ssl._create_default_https_context = ssl.create_default_context(cafile=certifi.where()) ๐ WebSocket Error
Use EXACT URL:
https://adamk29-meta-openenv-hackathon.hf.space
Do NOT use:
- http
- trailing /
๐ณ Docker (Optional)
docker build -t email-env .
docker run -p 8000:8000 email-envRL
- Sequential decisions โ
- Delayed rewards โ
- State transitions โ
- Exploration โ
- Episode termination โ
๐ Developer Usage
env = EmailEnvClient(base_url="https://adamk29-meta-openenv-hackathon.hf.space")
obs = await env.reset()
obs = await env.step(action) ๐ Highlights
- Real RL environment
- OpenEnv compliant
- Hugging Face deployed
- Trainable agent
- Interactive UI
๐ License
MIT
Authors
- Rongala Geethika Lahari
- Koda Adam
- Bobbili Revanth ---
๐ฅ Demo Link
https://adamk29-meta-openenv-hackathon.hf.space๐ Built for OpenEnv Hackathon
