CodeRedEnv — Emergency Medical Coordination Simulation
A multi-subsystem OpenEnv-compatible RL benchmark where an AI agent coordinates emergency
medical response across Prakashnagar, India — a 12-node hub-and-spoke city with 3 hospital tiers
and 5 ambulances.
Environment Description
CodeRedEnv simulates the critical first-30-minutes of a mass-casualty emergency response.
The agent must prioritize, dispatch, triage, and resource-manage under time pressure and
disruption events. It combines ambulance routing, hospital OR preparation, specialist paging,
blood bank allocation, and mutual aid coordination into a single RL benchmark.
Motivation: Emergency coordination is a real-world domain where sequential
decision-making under uncertainty directly maps to RL formulation. Unlike toy benchmarks,
CodeRedEnv has non-trivial state, cascading consequences, and resource contention — all
real challenges faced by EMS dispatchers.
Action & Observation Spaces
Actions (14 total)
Action
Description
Phase
dispatch_ambulance
Dispatch ambulance to patient node (Phase 1)
1
dispatch_als
Dispatch ALS ambulance to pending 911 call (Phase 2)
2
dispatch_bls
Dispatch BLS ambulance to pending 911 call (Phase 2)
2
triage_call
Classify a pending 911 call
2
assign_hospital
Assign patient to destination hospital
1+2
prepare_or
Begin OR preparation at hospital
1+2
page_specialist
Page specialist at hospital
1+2
preempt_or
Clear an OR for emergency use
1+2
allocate_blood
Allocate blood units for patient
1+2
transfer_blood
Transfer blood between hospitals
1+2
request_mutual_aid
Request mutual aid ambulance
1+2
query_blood_type
Query patient blood type (5-min delay)
1+2
query_or_status
Query detailed OR status
1+2
maintain_plan
No-op
1+2
Observations
Full state includes: active patients with vitals/location/status, ambulance positions/status/ETAs,
hospital OR/specialist/ICU availability, pending 911 calls, blood bank stock, road network status,
disruption alerts, and score previews.
1# Required2exportHF_TOKEN=hf_... # Your API key34# Optional (defaults shown)5exportAPI_BASE_URL=https://router.huggingface.co/v1 # LLM endpoint6exportMODEL_NAME=Qwen/Qwen2.5-72B-Instruct # Model identifier7exportBENCHMARK=codered_env # Benchmark name for logs8exportMAX_STEPS=30# Max episode steps9exportSUCCESS_THRESHOLD=0.1# Score threshold for success
Expected baseline (gpt-5-nano, seeds 0-2, no tuning):
Task
Mean Score
Notes
task1
~0.3–0.6
Simple single-patient dispatch
task2
~0.2–0.5
Multi-patient coordination
task3
~0.1–0.3
Mass casualty, high disruption
task4
~0.2–0.4
Dispatch triage learning
task5
~0.1–0.2
Full cascade management
Deployment
The environment deploys as a containerized Hugging Face Space tagged with openenv:
bash
1# Build and push2docker build -f codered_env/Dockerfile -t ghcr.io/<user>/codered-env:latest .3docker push ghcr.io/<user>/codered-env:latest
45# Or use the HF Space SDK6huggingface_hub.upload_folder(...)
Set HF_TOKEN as a secret in your HF Space settings for gated model access.
API Endpoints
Method
Path
Description
POST
/reset
Start new episode (seed, task_id)
POST
/step
Execute action, return observation
GET
/state
Current environment state
GET
/tasks
List all 5 task definitions
POST
/grader
Run dummy agent and grade episode
POST
/baseline
Run OpenAI baseline on seeds 0-2
Citation
@misc{coderedenv2026,
title={CodeRedEnv: Emergency Medical Coordination Simulation},
author={Darsh},
year={2026}
}