CoolFace
Apppublic

sc-likes-to-code/openenv-customer-support-env

sourceHugging Facemitupdated 5mo agoView on Hugging Face
0likes
App README

๐ŸŽซ 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:

yaml
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: 8

Validated via:

bash
openenv validate

โš™๏ธ Core API

python
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 state

HTTP Endpoints

MethodEndpointDescription
POST/reset?task=easyStart a new episode
POST/stepSubmit an action
GET/stateGet current episode state
GET/healthHealth check (returns 200)

๐Ÿ“Š Observation Space

json
{
  "tickets": [
    {"id": 1, "text": "Customer message here"}
  ],
  "current_ticket_id": 1,
  "history": [
    {"user": "...", "agent": "...", "action_type": "classify"}
  ]
}

๐ŸŽฎ Action Space

python
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
)
ActionPurpose
classifyCategorize the issue: billing or technical
respondProvide a resolution or acknowledgment
askRequest missing information from the user
escalateHand off to a human agent

๐Ÿ“‹ Tasks

๐ŸŸข Easy โ€” Ticket Classification & Response

Max steps: 6

Agent must classify the ticket and provide an appropriate response.

StepActionReward
1Correct classification (billing/technical)+0.5
2Response with refund/sorry keywords+0.4
2Urgency keyword bonus (urgent/immediately)+0.1

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.

StepActionReward
1Correct classification+0.3
2Empathetic language (sorry/understand/apologize)+0.3
2Policy-compliant response (fix/refund keywords)+0.4

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.

StepActionReward
1Correct classification+0.2
2Ask for missing info (transaction ID etc.)+0.2
3+Response with correct keywords+0.3
3+Memory bonus (asked_info was used)+0.1
AnyEfficiency bonus (resolved in โ‰ค3 steps)+0.1
AnyCorrect escalation decision+0.1

Penalties:

ConditionPenalty
Respond at step 2 without asking firstโˆ’0.3
Unnecessary escalationโˆ’0.2
Repeated action typeโˆ’0.2

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):

TaskScoreSuccessSteps
Easy0.500โœ…2
Medium0.500โœ…2
Hard0.300โœ…3
Aggregate0.433
A frontier LLM agent is expected to score significantly higher.

๐Ÿš€ Setup Instructions

Clone repository

bash
git clone <repo-url>
cd my-env

Create virtual environment

bash
python -m venv venv
venv\Scripts\activate      # Windows
source venv/bin/activate   # Linux/Mac

Install dependencies

bash
pip install -r requirements.txt

๐Ÿ” Environment Variables

VariableRequiredDefaultDescription
HF_TOKENโœ… Yesโ€”Your Hugging Face API token
API_BASE_URLNohttps://router.huggingface.co/v1LLM API endpoint
MODEL_NAMENoQwen/Qwen2.5-72B-InstructModel identifier
If no API key is set, the agent runs in fallback mode using rule-based actions. All 3 tasks still complete successfully.

โ–ถ๏ธ Run Inference

bash
python inference.py

Runs 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

bash
docker build -t support-env .
docker run -p 7860:7860 support-env

Test endpoints:

bash
curl -X POST http://localhost:7860/reset?task=easy
curl http://localhost:7860/health

โœ… OpenEnv Validation

bash
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