An OpenEnv environment where AI agents learn to triage, route, and respond to operational messages through adversarial curricula and GRPO fine-tuning. Built for the Meta × OpenEnv × Hugging Face × PyTorch Hackathon.
🎯 Why This Matters
Operational message overload — routing alerts to the wrong team, missing critical VP requests, responding to vendor spam — costs engineering teams hours every week. This environment trains RL agents to be automated message triage specialists, a task humans perform manually every day across DevOps, executive assistants, and operations roles.
Real-world utility: Operations teams, executive assistants, and DevOps engineers manually triage hundreds of messages daily across Slack, email, and ticketing systems. This environment provides a standardised benchmark for training and evaluating agents that automate this process with verifiable, graded outcomes.
1# Copy the example and fill in your secrets2cp .env.example .env
34# Edit .env — at minimum set:5# HF_TOKEN=hf_your_token_here6# OPENENV_URL=http://localhost:8000
Web Interface (Gradio UI)
When deployed to Hugging Face Spaces (or run locally), the environment provides a custom Gradio web UI at /ui with:
🔽 Dropdowns for action_type and target_directory
📝 Textbox for message_id with queue display
📄 Multi-line textarea for response_payload and reasoning
🖥️ Terminal-style action log with colour-coded rewards
📬 Rich message queue cards with alert-level badges
To enable locally:
bash
1uvicorn server.app:app --reload --host 0.0.0.0 --port 80002# Then open http://localhost:8000/ui
Local Development
bash
1# Clone the repository2git clone https://github.com/elizabeth07-m/email_gym.git
3cd email_gym
45# Install dependencies6pip install -e ".[dev]"78# Run the server9uvicorn server.app:app --reload --host 0.0.0.0 --port 80001011# Run tests12pytest tests/ -v
Docker
bash
1# Build and run2docker compose up --build
34# Or manually5docker build -t email-gym .6docker run -p 8000:8000 email-gym
API Usage Examples
bash
1# Health check2curl http://localhost:8000/health
34# Reset (warmup task)5curl -X POST http://localhost:8000/reset \6 -H "Content-Type: application/json"\7 -d '{"task_id": "task_warmup_noise"}'89# Step (route a message)10curl -X POST http://localhost:8000/step \11 -H "Content-Type: application/json"\12 -d '{"action": {"action_type": "route_directory", "message_id": "1", "target_directory": "promotions"}}'1314# Step (respond to stakeholder)15curl -X POST http://localhost:8000/step \16 -H "Content-Type: application/json"\17 -d '{"action": {"action_type": "respond", "message_id": "2", "response_payload": "Acknowledged. The deployment window is confirmed for 15:00."}}'1819# Step (dismiss to vault)20curl -X POST http://localhost:8000/step \21 -H "Content-Type: application/json"\22 -d '{"action": {"action_type": "dismiss", "message_id": "3"}}'2324# Get state25curl http://localhost:8000/state
2627# Get schemas28curl http://localhost:8000/schema
Running Inference
bash
1# Export environment variables2exportAPI_BASE_URL="https://router.huggingface.co/v1"3exportHF_TOKEN="your-token-here"4exportMODEL_NAME="elizabeth07-m/email_gym"5exportOPENENV_URL="http://localhost:8000"67# Run baseline inference8python inference.py
🚢 Deployment (OpenEnv Push)
This environment is designed for one-command deployment to Hugging Face Spaces via the OpenEnv CLI.
Step 1 — Validate
bash
1openenv validate
2# [OK] email-gym: Ready for multi-mode deployment
Step 2 — Test locally
bash
1uvicorn server.app:app --host 0.0.0.0 --port 80002# Server starts at http://localhost:80003# Verify: curl http://localhost:8000/health
Step 3 — Deploy to Hugging Face Spaces
bash
1# Login to Hugging Face (if not already)2huggingface-cli login
34# Push to your HF Space5openenv push --repo-id elizabeth07-m/email_gym
This will:
Create the elizabeth07-m/email_gym Space on Hugging Face (if it doesn't exist)
Upload all environment files, Dockerfile, and openenv.yaml
Build and deploy the Docker container automatically on HF infrastructure
Step 4 — Verify deployment
bash
1# Health check (replace with your Space URL)2curl https://elizabeth07-m-email-gym.hf.space/health
34# Run inference against the deployed Space5OPENENV_URL="https://elizabeth07-m-email-gym.hf.space" python inference.py
Deployment Options
bash
1# Deploy as a private Space2openenv push --repo-id elizabeth07-m/email_gym --private
34# Create a PR instead of pushing directly5openenv push --repo-id elizabeth07-m/email_gym --create-pr
📊 Baseline Scores
Scores are from the baseline inference agent using Qwen/Qwen2.5-72B-Instruct:
Task
Difficulty
Score
Steps
task_warmup_noise
Warmup
~0.82
4
task_intermediate_ack
Intermediate
~0.51
6
task_advanced_conflict
Advanced
~0.28
8
Average
~0.54
Scores are approximate and may vary based on model temperature and API availability.