deep-thinker/er-triage-env
0
๐ฅ ER Triage Decision Environment (OpenEnv)
๐ Overview
This project implements a real-world reinforcement learning environment simulating emergency room (ER) triage decisions.
The agent acts as a triage nurse, assigning:
- ESI level (1โ5) โ urgency classification
- Care pathway โ treatment routing
The goal is to maximize patient safety and triage accuracy.
๐ฏ Problem Motivation
Emergency triage is a high-stakes decision-making task:
- Under-triage โ life-threatening delays
- Over-triage โ resource overload
- Ambiguous cases โ require reasoning
This environment evaluates whether AI systems can:
- interpret patient data
- make safe decisions
- handle uncertainty
๐ง Environment Design
๐น Observation Space
Each observation represents a patient:
PatientObservation:
patient_id: str
age: int
chief_complaint: str
vitals: Dict[str, float]
symptoms: List[str]
medical_history: List[str]
arrival_mode: str
time_in_waiting_room_minutes: int
queue_length: int
task_id: str
done: bool
reward: float
masked: bool
attempts_remaining: int
message: str๐น Action Space
TriageAction:
triage_level: int # 1 (most urgent) to 5 (least urgent)
care_pathway: str # resuscitation | acute | fast_track | observation | discharge_likely
confidence: float # 0.0 to 1.0๐น State
ERTriageState:
episode_id: str
step_count: int
current_patient_id: str
task_id: str
max_attempts: int๐ Interaction Flow
reset() โ returns patient case
step(action) โ returns reward + feedback
state โ environment metadataEach episode:
- One patient case
- Agent makes triage decision
- Reward assigned
- Episode ends
๐ฏ Tasks (Difficulty Levels)
The environment includes 3 task categories:
๐ข 1. Classic Presentations (Easy)
- Clear symptoms
- Obvious triage decisions
- Example: cardiac arrest, severe trauma
๐ก 2. Ambiguous Cases (Medium)
- Mixed symptoms
- Requires reasoning
- Example: chest pain + anxiety
๐ด 3. Masked Presentations (Hard)
- Hidden or misleading symptoms
- High risk of misclassification
- Example: atypical heart attack
๐ Reward Design (0.0 โ 1.0)
The reward function is continuous and safety-aware.
โ Base scoring:
- Correct ESI โ 0.7
- Off by 1 โ 0.4
- Off by 2 โ 0.2
- Incorrect โ 0.0
โ Bonus:
- Correct care pathway โ +0.2
- Confidence (if correct) โ +0.1 ร confidence
โ Penalty:
- Incorrect confident decisions โ โ0.05 ร confidence
- Critical under-triage โ 0.0 (severe penalty)
๐ Final reward:
Clamped between 0.0 and 1.0๐งช Example Interaction
obs = env.reset()
action = TriageAction(
triage_level=2,
care_pathway="acute",
confidence=0.8
)
result = env.step(action)
print(result.reward)
print(result.message)โ๏ธ Setup Instructions
1. Install dependencies
pip install -r requirements.txt2. Run locally
uvicorn server.app:app --reloadCheck:
http://localhost:8000/health3. Run inference
export HF_TOKEN=your_token
export MODEL_NAME=your_model
export ENV_BASE_URL=http://localhost:8000
python inference.py๐ณ Docker
Build:
docker build -t er-triage-env -f server/Dockerfile .Run:
docker run -p 8000:8000 er-triage-env๐ Deployment (Hugging Face)
openenv push --repo-id <username>/er-triage-envAccess:
https://<username>-er-triage-env.hf.space๐ Evaluation
The system is evaluated on:
- Accuracy of ESI classification
- Correct care pathway
- Safety (avoiding under-triage)
- Robustness across tasks
Final score:
Average across all tasks๐ Key Features
- โ Real-world healthcare scenario
- โ Continuous reward function (not binary)
- โ Multi-difficulty tasks
- โ Safety-aware penalties
- โ Type-safe design
- โ OpenEnv compliant
โ ๏ธ Notes
- Ground truth labels are never exposed to the agent
- Masked tasks intentionally hide key signals
- Designed to challenge advanced LLM reasoning
๐ง Summary
This environment tests whether AI systems can make safe, accurate, and context-aware medical triage decisions under uncertainty.
