sc-likes-to-code/openenv-customer-support-env
๐ซ Support Ticket Resolution Environment (OpenEnv)
A real-world, multi-step customer support simulation environment built on the OpenEnv framework. Designed to train and evaluate AI agents on tasks that mirror genuine human support workflows.
๐ Overview
Unlike toy RL environments, this system simulates a realistic customer support pipeline where an agent must:
- Classify support tickets by issue type
- Detect sentiment and apply policy-aware responses
- Ask clarifying questions when information is missing
- Use conversation memory across turns
- Decide whether to resolve or escalate issues
This makes it a high-value benchmark for evaluating multi-step reasoning, policy compliance, and stateful decision-making in AI agents.
๐๏ธ Project Structure
my-env/
โโโ inference.py # Baseline agent โ runs all 3 tasks
โโโ models.py # Pydantic models: Action, Observation, Reward
โโโ openenv.yaml # OpenEnv spec metadata (name, tasks, spaces, rewards)
โโโ pyproject.toml # Project metadata and dependencies
โโโ requirements.txt # Python dependencies
โโโ uv.lock # Locked dependency versions
โโโ Dockerfile # Container definition
โโโ client.py # HTTP client for the environment
โโโ __init__.py # Root package
โโโ server/
โโโ __init__.py # Server package
โโโ app.py # FastAPI server (reset / step / state / health)
โโโ grader.py # Task graders with reward shaping
โโโ tasks.py # Task definitions (easy / medium / hard)
โโโ your_environment.py # Core SupportEnv class๐ OpenEnv Spec (openenv.yaml)
This environment is fully compliant with the OpenEnv specification:
name: openenv-customer-support-env
version: "1.0.0"
tags: [openenv]
entrypoint: server.app:app
tasks:
- id: easy | difficulty: easy | max_steps: 6
- id: medium | difficulty: medium | max_steps: 6
- id: hard | difficulty: hard | max_steps: 8Validated via:
openenv validateโ๏ธ Core API
reset(task: str) -> Observation # Initialize episode for given task
step(action: Action) -> (Observation, Reward, done, info) # Take one action
state() -> dict # Inspect full current episode stateHTTP Endpoints
๐ Observation Space
{
"tickets": [
{"id": 1, "text": "Customer message here"}
],
"current_ticket_id": 1,
"history": [
{"user": "...", "agent": "...", "action_type": "classify"}
]
}๐ฎ Action Space
Action(
action_type: str, # "classify" | "respond" | "escalate" | "ask"
ticket_id: int, # ID of the ticket being handled
content: Optional[str] # Classification label or response text
)๐ Tasks
๐ข Easy โ Ticket Classification & Response
Max steps: 6
Agent must classify the ticket and provide an appropriate response.
Max achievable: 1.0
๐ก Medium โ Sentiment-Aware Policy Resolution
Max steps: 6
Agent must detect issue type, show empathy, and generate a policy-compliant response.
Max achievable: 1.0
๐ด Hard โ Multi-Turn Memory-Based Resolution
Max steps: 8
Agent must follow the full sequence: classify โ ask โ respond, using conversation memory.
Penalties:
Max achievable: 1.0
๐ Reward Design
This environment uses dense reward shaping โ agents receive meaningful signal at every step, not just at episode end.
- Partial credit for each correct intermediate action
- Efficiency bonuses for faster resolution
- Memory bonuses for using context from prior turns
- Penalties for skipping required steps, repeating actions, or escalating unnecessarily
- Episode ends early on near-perfect score (โฅ0.95) or after max steps
๐ Baseline Scores
Achieved by the fallback rule-based agent (no LLM, no API key required):
A frontier LLM agent is expected to score significantly higher.
๐ Setup Instructions
Clone repository
git clone <repo-url>
cd my-envCreate virtual environment
python -m venv venv
venv\Scripts\activate # Windows
source venv/bin/activate # Linux/MacInstall dependencies
pip install -r requirements.txt๐ Environment Variables
If no API key is set, the agent runs in fallback mode using rule-based actions. All 3 tasks still complete successfully.
โถ๏ธ Run Inference
python inference.pyRuns all 3 tasks in sequence and outputs:
[START] task=easy env=support_env model=Qwen/Qwen2.5-72B-Instruct
[STEP] step=1 action={...} reward=0.50 done=false error=null
[STEP] step=2 action={...} reward=0.50 done=true error=null
[END] success=true steps=2 rewards=0.50,0.50
[SUMMARY] task=easy score=0.500 success=true steps=2
...
[AGGREGATE] tasks=3 avg_score=0.433๐ณ Docker Usage
docker build -t support-env .
docker run -p 7860:7860 support-envTest endpoints:
curl -X POST http://localhost:7860/reset?task=easy
curl http://localhost:7860/healthโ OpenEnv Validation
pip install openenv-core
openenv validateโ๏ธ Deployment
Deployed as a Hugging Face Docker Space โ fully containerized, CPU-friendly, and responds within the 20-minute inference runtime limit.
๐ฎ Future Improvements
- Multi-ticket queue handling
- Memory persistence across episodes
- Advanced policy rule engine
- Human-in-the-loop simulation
- More task difficulty levels
๐ License
MIT
