CoolFace
Apppublic

Hemakshiy/icde-openenv

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
App README

๐Ÿšจ Incident Command Decision Environment (ICDE)

![OpenEnv](https://github.com/openenv) ![HuggingFace](https://huggingface.co/spaces) ![Docker](https://docker.com)

An OpenEnv-compliant benchmark where an AI agent plays Incident Commander managing real-world emergencies using the ICS (Incident Command System) โ€” the exact framework used by FEMA, hospitals, fire departments, and militaries worldwide.

๐ŸŽฏ Overview & Motivation

Real emergency response requires:

  • โ€”Conflicting information โ€” 4 agencies reporting simultaneously with contradictory data
  • โ€”Causal reasoning โ€” wrong step 3 decisions show up as casualties at step 18
  • โ€”Resource scarcity math โ€” cannot send 3 units to 5 locations simultaneously
  • โ€”Protocol knowledge โ€” ICS structure matters, not just intent
  • โ€”Adaptive response โ€” new complications inject mid-episode

This makes ICDE a rigorous benchmark for evaluating whether LLMs can reason under uncertainty, reconcile conflicting information, and make defensible decisions with real consequences โ€” skills that go far beyond trivia or code generation.


๐Ÿ—๏ธ Project Structure

icde/
โ”œโ”€โ”€ env/
โ”‚   โ”œโ”€โ”€ __init__.py       # Package exports
โ”‚   โ”œโ”€โ”€ models.py         # Pydantic: Action, Observation, State, Reward
โ”‚   โ”œโ”€โ”€ environment.py    # Core: step() / reset() / state()
โ”‚   โ”œโ”€โ”€ reward.py         # Dense reward shaping logic
โ”‚   โ””โ”€โ”€ simulator.py      # Incident simulation engine
โ”œโ”€โ”€ tasks/                # Task definitions (see graders)
โ”œโ”€โ”€ graders/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ grader1.py        # Task 1: Resource allocation
โ”‚   โ”œโ”€โ”€ grader2.py        # Task 2: Multi-agency conflict
โ”‚   โ””โ”€โ”€ grader3.py        # Task 3: Cascading crisis
โ”œโ”€โ”€ data/
โ”‚   โ””โ”€โ”€ scenarios.json    # 3 fully-defined incident scenarios
โ”œโ”€โ”€ server.py             # FastAPI server (OpenEnv HTTP API)
โ”œโ”€โ”€ inference.py          # โœ… OpenAI client baseline script (ROOT)
โ”œโ”€โ”€ openenv.yaml          # OpenEnv metadata
โ”œโ”€โ”€ Dockerfile
โ”œโ”€โ”€ requirements.txt
โ””โ”€โ”€ README.md

๐Ÿงช Tasks

Task 1 โ€” Resource Allocation Under Scarcity (Easy)

Scenario: Industrial warehouse fire with 3 active zones and 4 limited resources.

ZoneThreatResources Needed
Zone A (Loading Dock)Active flames, 4 trappedEngine
Zone B (Chemical Storage)Acetylene cylinders, explosion riskHazmat FIRST, then Engine
Zone C (Office Wing)Smoke inhalationMedical

Challenge: Conflicting reports โ€” Security Guard says "zone A looks clear" (reliability: 0.3), Engine 7 confirms 4 workers trapped. Agent must flag unreliable report.

Grader criteria (โ†’ 1.0):

  • โ€”Hazmat dispatched to Zone B: +0.35
  • โ€”No double assignment: +0.25
  • โ€”Unreliable report flagged: +0.20
  • โ€”Medical to Zone C: +0.10
  • โ€”No looping behavior: +0.10

Baseline score: ~0.60


Task 2 โ€” Multi-Agency Conflict Resolution (Medium)

Scenario: Hospital mass casualty event. Fire, EMS, Police, and Hospital all reporting simultaneously with contradictory casualty counts and safety assessments.

Key conflicts:

  • โ€”Fire IC: "15 casualties inside" vs EMS: "8 transported, 20 still on scene"
  • โ€”Hospital Director: "ER structurally unsafe โ€” do NOT enter"
  • โ€”Police Sergeant: "ER looks fine, safe to enter" โ† reliability: 0.25, should be flagged

Cascade triggers if not addressed:

  • โ€”No rescue to ER by step 10 โ†’ 3 critical patients die
  • โ€”No police to access road by step 6 โ†’ ambulance blocked, 2 deaths

Baseline score: ~0.45


Task 3 โ€” Cascading Multi-Site Crisis (Hard)

Scenario: Simultaneous earthquake + gas main rupture + hospital power failure across a city grid. 30 steps. Early decisions have irreversible downstream consequences.

5 active sites: | Site | Threat | Critical Window | |------|--------|----------------| | Gas District | 16-inch rupture, explosion risk | Cascade at step 12 without hazmat | | Hospital | 45 ICU patients, 2hr battery | Cascade at step 15 without power unit | | Residential | Partial collapse, 15 trapped | Cascade at step 20 without rescue | | School | 200 students, structural damage | Low severity, can wait | | Bridge | Cracked โ€” no heavy vehicles | Routing constraint |

Injected complications: aftershock at step 5, hospital update at step 10, road closure at step 18.

Cascade chains: Wrong priority decision at step 1-3 โ†’ hospital loses life support at step 15 โ†’ 8 ICU patients die.

Baseline score: ~0.30


๐Ÿ† Action & Observation Spaces

Action Space (ICDEAction)

python
class ICDEAction(BaseModel):
    command: CommandAction          # dispatch | recall | establish_command | 
                                    # flag_conflict | escalate | stand_down |
                                    # request_mutual_aid | issue_directive
    resource_type: Optional[str]    # engine | hazmat | medical | police | rescue | power
    target_zone: Optional[str]      # zone identifier
    priority: Optional[str]         # critical | high | medium | low
    directive: Optional[str]        # free-text order (max 500 chars)
    flags: Optional[List[str]]      # report IDs to flag as unreliable

Observation Space (ICDEObservation)

python
class ICDEObservation(BaseModel):
    step: int
    task_id: str
    incident_type: str
    active_zones: List[str]
    field_reports: List[FieldReport]         # Per-agency reports (reliability hidden)
    available_resources: List[ResourceStatus]
    assigned_resources: List[ResourceStatus]
    recent_events: List[str]                 # Last 5 events
    civilian_status: Dict[str, int]          # safe / at_risk / casualties
    time_remaining: int
    warnings: List[str]                      # Active unresolved warnings

Reward Function (Dense, Range: -1.0 to +1.0)

ComponentRangeDescription
life_safety-0.4 to +0.4Civilian outcomes vs optimal
resource_efficiency-0.15 to +0.15No double-assignment
conflict_resolution0 to +0.2Correct flags raised
protocol_compliance0 to +0.1ICS structure followed
penalty_loop-0.23x repeated identical action
penalty_cascade-0.3Preventable cascade triggered

๐Ÿš€ Setup & Usage

Local Development

bash
git clone <repo>
cd icde
pip install -r requirements.txt
python server.py

Run Baseline Inference

bash
export HF_TOKEN=your_token_here
export API_BASE_URL=https://router.huggingface.co/v1
export MODEL_NAME=Qwen/Qwen2.5-72B-Instruct
python inference.py

Docker

bash
docker build -t icde .
docker run -p 7860:7860 -e HF_TOKEN=$HF_TOKEN icde

API Usage

bash
# Reset task
curl -X POST http://localhost:7860/reset \
  -H "Content-Type: application/json" \
  -d '{"task_id": "task1_resource"}'

# Take action
curl -X POST http://localhost:7860/step \
  -H "Content-Type: application/json" \
  -d '{
    "task_id": "task1_resource",
    "action": {
      "command": "dispatch",
      "resource_type": "hazmat",
      "target_zone": "zone_b",
      "priority": "critical"
    }
  }'

# Get current state
curl http://localhost:7860/state?task_id=task1_resource

# Get episode grade
curl http://localhost:7860/grade?task_id=task1_resource

๐Ÿ“Š Baseline Performance

TaskDifficultyBaseline ScoreThreshold
task1_resourceEasy0.600.50
task2_multiagencyMedium0.450.45
task3_cascadeHard0.300.35

Baseline model: Qwen/Qwen2.5-72B-Instruct via Hugging Face Inference API


๐Ÿ”’ Anti-Reward-Hacking Design

  • โ€”Life safety verified by simulated outcomes โ€” not keyword matching
  • โ€”Protocol compliance checked structurally โ€” not by buzzwords
  • โ€”Cascade penalties only fire on verified causal chains
  • โ€”Reliability scores are hidden from agent โ€” must reason about contradictions
  • โ€”Loop detection prevents degenerate policies

๐Ÿ“‹ OpenEnv Validation

bash
pip install openenv-core
openenv validate

๐Ÿ”ฌ Real-World Basis

The ICS framework used in this environment is the actual system mandated by FEMA for all US incident management. The scenario designs are based on:

  • โ€”NIMS (National Incident Management System) training scenarios
  • โ€”Multi-agency coordination case studies from FEMA training materials
  • โ€”Hospital emergency operations plan templates

This makes ICDE directly applicable to training AI systems for:

  • โ€”Emergency dispatch assistance
  • โ€”Incident Commander decision support
  • โ€”Multi-agency coordination tools
  • โ€”Crisis simulation and training

๐Ÿ“„ License

MIT License โ€” see LICENSE file.