β οΈ PROTOTYPE ONLY β This is a clinical decision support prototype for research and educational purposes. It is NOT a real medical diagnostic system and must NOT be used for actual medical decisions.
An Agentic AI-powered medical triage system that orchestrates multiple specialized agents using a hybrid neuro-symbolic architecture to assess symptoms, detect emergencies, assign urgency levels, and generate structured clinical briefings β all running locally with Ollama.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Streamlit Frontend β
β Multi-step card UI β Demographics β Symptoms β History β ... β
βββββββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββ
β REST API
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FastAPI Backend β
β /api/questions /api/triage β
βββββββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β LangGraph Workflow Engine β
β β
β ββββββββββββ ββββββββββββ ββββββββββββ β
β β Intake ββββββΆβ Critic ββββββΆβ Triage β β
β β Agent β β Agent β β Agent β β
β βββββββββββββββββββββββββββββ ββββββ¬ββββββ β
β β² (reflection loop) β β
β β βΌ β
β βββββ΄βββββββ ββββββββββββββββ β
β βEscalationβ β Synthesis β β
β β Handler β β Agent β β
β ββββββββββββ ββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Ollama (Local LLM) β
β llama3.2 (or any model) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
This system implements a true multi-agent architecture where independent agents operate with defined roles, shared state, and iterative routing.
Each agent:
- Operates autonomously within its responsibility boundary
- Communicates via structured Pydantic state objects
- Participates in a controlled LangGraph workflow
- Can trigger routing changes (e.g., escalation, reflection loop)
This design mirrors real-world clinical workflow systems rather than simple prompt-based chatbots.
| Agent | Role |
|---|---|
| Intake Agent | Parses demographics, detects red flags via keyword scan, uses LLM to extract structured symptom details |
| Critic Agent | Reviews intake for clinical gaps, detects missed red flags via LLM, drives the reflection loop |
| Triage Agent | Hybrid rule+LLM urgency classification (EMERGENCY β NON_URGENT) + department routing |
| Synthesis Agent | Generates full structured medical briefing with differentials, workup recommendations, and clinician notes |
intake β [escalation?] β critic β [approved?] β triage β synthesis β END
β βββ [rejected, loop back] βββ
βββ (red flags β fast-path EMERGENCY)
medical_triage/
βββ main.py # API server entrypoint
βββ requirements.txt
βββ .env.example
β
βββ config/
β βββ __init__.py
β βββ settings.py # All config, red flags, symptom tree
β
βββ backend/
β βββ __init__.py
β βββ agents/
β β βββ intake_agent.py # Patient intake + red flag detection
β β βββ critic_agent.py # Quality review + reflection loop
β β βββ triage_agent.py # Urgency + department classification
β β βββ synthesis_agent.py # Clinical briefing generation
β βββ graph/
β β βββ workflow.py # LangGraph StateGraph orchestration
β βββ models/
β β βββ schemas.py # All Pydantic data models
β βββ api/
β β βββ server.py # FastAPI endpoints
β βββ utils/
β βββ logger.py # Structured logging
β βββ ollama_client.py # Ollama REST client
β
βββ frontend/
βββ app.py # Streamlit multi-step card UI
- Python 3.11+
- Ollama installed and running
- 8GB+ RAM recommended
git clone https://github.com/bharath2957s/MedTriage-Agentic-AI
cd medical_triage
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt# Install Ollama from https://ollama.ai
# Then pull the model:
ollama pull llama3.2
# Start Ollama server (if not already running):
ollama servecp .env.example .env
# Edit .env to change model name, ports, etc. if needed# From project root:
python main.py
# Or with uvicorn directly:
uvicorn backend.api.server:app --host 0.0.0.0 --port 8000 --reloadVerify: Open http://localhost:8000/docs
# In a new terminal, from project root:
streamlit run frontend/app.py --server.port 8501Open: http://localhost:8501
- Demographics β Enter patient age, sex, and chief complaint
- Symptoms β Answer dynamically generated follow-up questions
- History β Enter past medical history, medications, and allergies
- Analysis β Watch the AI agents process the case in real-time
- Results β View triage urgency, department routing, and clinical briefing
The Doctor Dashboard tab provides the full structured clinical report including differentials, recommended workup, and clinician notes β downloadable as JSON.
If Ollama is not running, the system gracefully falls back to the /api/demo endpoint, which returns a realistic pre-built cardiac emergency example for UI testing.
| Variable | Default | Description |
|---|---|---|
OLLAMA_MODEL |
llama3.2 |
Any Ollama-compatible model |
OLLAMA_TEMP |
0.3 |
Lower = more deterministic |
MAX_CRITIC_ITERATIONS |
2 |
Reflection loop depth |
API_PORT |
8000 |
Backend API port |
DEBUG |
false |
Enable hot reload |
Recommended models (in order of quality/speed):
llama3.2β Fast, good quality (recommended)llama3.1:8bβ Slightly slower, higher qualitymistralβ Alternative good optionphi3β Fastest, lighter quality
| Model | Purpose |
|---|---|
IntakeState |
Full patient session state passed through the graph |
TriageDecision |
Urgency level + department + rationale + confidence |
MedicalSummary |
Complete final briefing with all agent outputs |
CriticFeedback |
Critique results from the reflection loop |
SymptomDetail |
Structured individual symptom with severity/duration |
The system uses a two-layer neuro-symbolic emergency detection architecture:
- Deterministic Pattern-Based Rule Engine (Clinical Rule Layer) β Structured, normalized pattern matching for life-threatening presentations (e.g., crushing chest pain, stroke symptoms, uncontrolled bleeding, respiratory failure, suicidal intent). Triggers immediate escalation without relying on LLM output.
- LLM Contextual Detection (Critic + Triage Agents) β Identifies subtle, progressive, or context-dependent red flags not explicitly captured by deterministic patterns (e.g., concerning severity progression, high-risk comorbidities, neurologic warning signs).
When escalation triggers:
- LLM reasoning is bypassed (deterministic fast path)
- Triage Agent returns EMERGENCY immediately
- Emergency department routing is enforced
- High-priority actions are generated automatically
- A prominent emergency alert is displayed in the frontend.
| Endpoint | Method | Description |
|---|---|---|
/health |
GET | Health check |
/api/questions |
POST | Get dynamic symptom questions |
/api/triage |
POST | Run full triage workflow |
/api/demo |
GET | Demo result (no LLM needed) |
/docs |
GET | Interactive Swagger UI |
This system is a research prototype demonstrating multi-agent AI orchestration patterns. It:
- Does NOT replace professional medical judgment
- Should NOT be used for real medical decisions
- Has NOT been validated clinically
- Is intended for educational and research purposes only
Always consult a licensed healthcare professional for medical concerns.