cop91/Customer-Service-Agents-OpenEnv
Customer Service OpenEnv
  ![Score]()
A production-grade OpenEnv environment for training AI agents to handle real-world customer support workflows — one of the 4 officially highlighted use cases for the Meta × PyTorch OpenEnv Hackathon.
Business Impact
Customer service AI is one of the highest-ROI AI applications in 2026:
A mid-size company with 500K tickets/year saves $1.6M+ annually if AI handles 40% autonomously. This environment trains agents to achieve exactly that.
Environment Overview
The agent resolves customer support tickets by calling tools across three difficulty levels. Each episode ends when the agent closes or escalates the ticket, with a score from 0.0 to 1.0.
Customer Ticket
↓
Agent calls tools (search_kb, get_order_details, send_reply, issue_refund, ...)
↓
Grader scores: tool use + empathy + resolution + efficiency
↓
Score 0.0 – 1.0 returnedTasks
Reward Function
Partial progress signals are given at every step — not just on completion:
Baseline Results
Running inference.py with llama-3.3-70b-versatile on Groq:
easy [████████████████████] 1.0000 (3 steps)
medium [████████████████████] 1.0000 (5 steps)
hard [████████████████████] 1.0000 (6 steps)
Grand average: 1.0000 / 1.0Action Space
Each action is a JSON object with two fields:
{
"tool": "<tool_name>",
"params": { "<param_key>": "<param_value>" }
}Example:
{"tool": "search_kb", "params": {"query": "password reset"}}
{"tool": "issue_refund", "params": {"amount": 79.99, "reason": "Item lost in transit"}}
{"tool": "close_ticket", "params": {"final_message": "Issue resolved. Thank you!"}}Observation Space
Each step returns a JSON observation with these fields:
Example observation:
{
"ticket": {"id": "TKT-E001", "subject": "Password Reset", "status": "open", ...},
"conversation": [{"role": "customer", "content": "I forgot my password"}],
"available_tools": ["search_kb", "send_reply", "close_ticket"],
"step_count": 1,
"done": false,
"reward": 0.05,
"tool_result": {"found": true, "answer": "Reset link sent within 30 minutes..."},
"info": {"partial_reward": 0.05}
}API
Reset
curl -X POST https://YOUR_SPACE.hf.space/reset \
-H "Content-Type: application/json" \
-d '{"task_id": "hard", "seed": 42}'Step
curl -X POST https://YOUR_SPACE.hf.space/step \
-H "Content-Type: application/json" \
-d '{"tool": "search_kb", "params": {"query": "password reset"}}'Available Tools
Running Locally
git clone https://huggingface.co/spaces/YOUR_USERNAME/customer-service-env
cd customer-service-env
pip install -r requirements.txt
# Start server
uvicorn app.main:app --host 0.0.0.0 --port 7860
# Run baseline agent (in another terminal)
export GROQ_API_KEY_1=gsk_...
python inference.py --task all
# Full evaluation across multiple seeds
python evaluate.py --runs 3Project Structure
customer-service-env/
├── Dockerfile
├── openenv.yaml ← OpenEnv manifest
├── inference.py ← Baseline LLM agent (Groq-powered)
├── evaluate.py ← Multi-seed evaluation script
├── requirements.txt
└── app/
├── main.py ← FastAPI server (/reset /step /state /health)
├── env.py ← Core environment + reward logic
├── models.py ← Pydantic schemas
├── tools.py ← 8 simulated tools + order database
├── tasks/ ← Task definitions (easy / medium / hard)
├── graders/ ← Automated graders returning 0.0–1.0
└── data/
├── knowledge_base.json ← 10 FAQ articles
└── ticket_templates.json ← 15 diverse ticket scenariosLicense
MIT
