Agent Incident Triage

AI-powered triage with conviction-based risk assessment, deterministic escalation rules, and full audit trail.

Next.js 15FastAPIGPT-4oPostgreSQLDockerVercelRailwayGitHub ActionspytestESI TriageRisk SignalsVoice
Open Triage Dashboard

How It Works

1. Input & Transcription

Patient describes symptoms via text chat or voice recording. Voice input uses gpt-4o-transcribe (Whisper) for speech-to-text conversion. Model is configurable per deployment.

2. Medical Extraction

gpt-4o extracts structured data: symptoms, pain scale (0-10), mental status, vitals, and risk signals with conviction scores (0.0-1.0). Uses JSON schema validation for reliable output.

3. Conviction-Based Escalation

Each risk signal (chest pain, breathing issues, suicidal ideation) has a conviction score. Deterministic rules compare against thresholds. If conviction >= threshold, the flag triggers. No LLM decides escalation.

4. ESI Classification

rules.py assigns Emergency Severity Index (ESI 1-5) based on red flags count, pain level, mental status. ESI-1/2 or any triggered risk flag → automatic escalation to human provider.

5. Response Generation

AI generates contextual follow-up questions or escalation message. For voice mode, gpt-4o-mini-tts converts response to speech. Model choices configurable for cost/quality tradeoffs.

6. Full Audit Trail

Every step logged with TOOL_CALL /TOOL_RESULT pattern: model used, latency, token counts, human-readable explanations. Full explainability for compliance.

Risk Signal Thresholds

Lower threshold = more sensitive (escalate with less certainty). Psychiatric signals use 20% to catch subtle hints.

Suicidal Ideation: 20%Self-Harm: 20%Homicidal: 40%Chest Pain: 50%Breathing: 50%Neurological: 50%Bleeding: 50%

Safety-First Architecture: The LLM is treated as an "untrusted helper" — it extracts information and generates responses, but all safety-critical escalation decisions are made by deterministic rules with explicit thresholds. This prevents prompt injection from bypassing medical safety checks.