Stateful Symptom Triage, Human-in-the-Loop Doctor Verification & Multi-Agent Clinical Research Orchestrator
An enterprise-grade agentic workspace applying LangGraph and LangChain to healthcare assistant design patterns. Features three distinct architectural clinical patterns: basic symptom triage conversation, human-in-the-loop clinical decision support with manual doctor overrides, and supervisor-supervised multi-agent systems for medical risk analysis and research report generation.
This repository contains independent modules built on top of LangGraph's state machine execution model. Each module is contextualized around a critical healthcare application, demonstrating how state management, loops, and human-in-the-loop workflows operate in high-integrity domains.
View Healthcare AI Agent Suite Flow Diagram
graph TD
classDef main fill:#1C3C3C,stroke:#333,stroke-width:1px,color:#fff;
classDef chatbot fill:#3776AB,stroke:#333,stroke-width:1px,color:#fff;
classDef human fill:#F55036,stroke:#333,stroke-width:1px,color:#fff;
classDef multi fill:#008080,stroke:#333,stroke-width:1px,color:#fff;
classDef tool fill:#f4f4f4,stroke:#333,stroke-width:1px,color:#333;
Workspace([User Clinical Request]) --> Route{Select Workflow}
%% Pattern 1: Triage Bot
Route -->|Symptom Triage| P1[1-BasicChatBot]:::chatbot
P1 --> ChatbotNode["Triage Bot Node"]:::chatbot
ChatbotNode -->|Triage Advice| Output1([Patient Instructions])
%% Pattern 2: HIL Clinical Assistant
Route -->|Doctor Approval| P2[Human Assistance]:::human
P2 --> HILChat["Clinical Assistant Node"]:::human
HILChat -->|Conditional Edge| HILTools[Tool Node]:::tool
HILTools -->|TavilySearch| WebSearch["Medical Database Search"]:::tool
HILTools -->|human_assistance| Interrupt["Doctor Override / Interrupt"]:::human
Interrupt -->|Doctor Approval/Edits| ResumedChat[Resume Graph Execution]:::human
%% Pattern 3: Clinical Supervisor
Route -->|Clinical Multi-Agent| P3[Multi-Agent System]:::multi
P3 --> Sup["Medical Supervisor Node"]:::human
Sup --> Router{"Supervisor Router"}:::main
Router -->|assign research| ResAgent["Medical Researcher Node"]:::multi
Router -->|assign analysis| AnaAgent["Clinical Analyst Node"]:::multi
Router -->|assign writing| WritAgent["Medical Writer Node"]:::multi
Router -->|DONE| End([Compiled Case Brief])
ResAgent -->|return research_data| Sup
AnaAgent -->|return analysis| Sup
WritAgent -->|return final_report| Sup
Because clinical safety and accurate guidance are the primary objectives of this agent suite, a multi-tiered safety guardrails architecture is implemented across the graph designs:
graph TD
classDef safety fill:#F55036,stroke:#333,stroke-width:1px,color:#fff;
classDef agent fill:#3776AB,stroke:#333,stroke-width:1px,color:#fff;
classDef tool fill:#f4f4f4,stroke:#333,stroke-width:1px,color:#333;
Input([Clinical Input]) --> Triage[Symptom Triage Gate]:::safety
Triage -->|Check Scope Constraints| Assistant[Clinical Assistant Node]:::agent
Assistant -->|Generate Advice/Prescription| DoctorCheck{Human Doctor Review Gate}:::safety
DoctorCheck -->|Interrupt State| ReviewNode[State Interrupt & Resume]:::tool
ReviewNode -->|Clinical Override/Signature| Output[Patient Output]:::agent
subgraph Multi-Agent Workspace
Supervisor[Chief Medical Supervisor]:::safety -->|Handoff Policy Control| WorkerAgents[Specialized Worker Nodes]:::agent
end
-
Symptom Triage Gate (Input Guardrails)
- Mechanism: System prompts strictly forbid the triage chatbot from diagnosing conditions or prescribing medications.
- Boundary: Limits assistant behavior to query collection and clinic routing recommendations.
-
Doctor Verification Gate (Human-in-the-Loop Resumption)
- Mechanism: Suspends the thread execution using LangGraph
interruptwhen medical prescriptions or specific diagnosis labels are detected. - Boundary: The state is serialized to a persistent database checkpoint, preventing user disclosure until a licensed medical professional reviews and reschedules the state.
- Mechanism: Suspends the thread execution using LangGraph
-
Supervisor Handoff Policy Control (Structured Delegation)
- Mechanism: The supervisor enforces separation of concerns by reading custom variables (
has_research,has_analysis,has_report). - Boundary: Prevents downstream agents from executing tasks out-of-order or accessing tools outside their clinical scope.
- Mechanism: The supervisor enforces separation of concerns by reading custom variables (
- Clinical Symptom Triage β Conversational flows for gathering patient symptoms, history, and concerns using
groq:llama-3.3-70b-versatileinside a LangGraphStateGraph. - Human-in-the-Loop Verification β Ensures patient safety by interrupting execution when prescription or diagnostic outputs are generated, allowing a licensed doctor to review, override, and resume the graph run.
- Hierarchical Medical Supervision β Coordinated team of specialized agents led by a Chief Medical Supervisor who evaluates variables dynamically to route research, data analysis, and documentation.
- Fact-Based Medical Grounding β Integration of Tavily search engines to retrieve peer-reviewed medical publications, clinical guidelines, and drug database specs.
- State Persistence & Checkpointers β Full context-aware memory retention for conversational histories and doctor overrides via
MemorySaver.
.
βββ 1-BasiChatBot/
β βββ 1-basicchatbot.ipynb # Basic patient triage and dialogue graph
βββ HumanAssitance/
β βββ HumaninLoop.ipynb # Doctor-in-the-loop safety interrupt & review node
βββ MultiAgents/
β βββ Agents.ipynb # Medical Supervisor, Researcher, Analyst & Writer team
βββ main.py # Global entrypoint script
βββ pyproject.toml # UV tool configuration & dependency specifications
βββ requirements.txt # Standard requirements file
βββ .env # API secrets (GROQ & TAVILY)
βββ README.md # Healthcare suite documentation
- Python 3.13+
- A Groq API Key (get one from console.groq.com)
- A Tavily API Key (get one from tavily.com)
# Clone the repository
git clone https://github.com/your-username/langgraph-healthcare-agents.git
cd langgraph-healthcare-agents
# Create and activate a virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies using uv (recommended)
uv pip install -r requirements.txt
# Or using standard pip:
pip install -r requirements.txtCreate a .env file in the root of the project to configure your credentials:
GROQ_API_KEY=your_groq_api_key_here
TAVILY_API_KEY=your_tavily_api_key_hereLocated in 1-basicchatbot.ipynb, this workflow configures a symptom collection and triage chat bot. The conversational agent prompts patients for symptom profiles, timeline, and intensity before offering routing suggestions (e.g., advising ER vs. primary care clinic visits).
Located in HumaninLoop.ipynb, this workflow implements strict human oversight safeguards.
When the AI proposes diagnostic summaries or treatment suggestions, the system calls a human_assistance tool which registers an interrupt state.
graph TD
classDef chatbot fill:#3776AB,stroke:#333,stroke-width:1px,color:#fff;
classDef human fill:#F55036,stroke:#333,stroke-width:1px,color:#fff;
classDef tool fill:#f4f4f4,stroke:#333,stroke-width:1px,color:#333;
Start([Patient Input]) --> Assistant[Assistant Node]:::chatbot
Assistant -->|Decide Diagnostic Suggestion| ToolNode[Tool Execution Node]:::tool
ToolNode -->|Require Doctor Check| Interrupt[State Interrupt]:::human
Interrupt -->|Doctor Approval/Correction| Resume[Resume Graph Execution]:::human
Resume --> Output([Diagnostic Report Delivered])
Caution
Safety Critical Boundary No diagnosis, prescription, or clinical guidance is ever surfaced to the user output before state resumption. A licensed practitioner must approve the clinical output.
Located in Agents.ipynb, this notebook implements a hierarchical clinical workspace. A Chief Medical Supervisor coordinates a team of specialized agents, dynamically updating routing based on case state variables.
graph TD
classDef supervisor fill:#F55036,stroke:#333,stroke-width:1px,color:#fff;
classDef worker fill:#3776AB,stroke:#333,stroke-width:1px,color:#fff;
classDef router fill:#1C3C3C,stroke:#333,stroke-width:1px,color:#fff;
Case([Medical Case Input]) --> Sup[Chief Medical Supervisor]:::supervisor
Sup -->|Determine Phase| Router{State Router}:::router
Router -->|gather findings| Res["Medical Researcher Agent"]:::worker
Router -->|evaluate safety| Ana["Clinical Analyst Agent"]:::worker
Router -->|write case brief| Writ["Medical Writer Agent"]:::worker
Router -->|all complete| End([Final Case Brief Compiled])
Res -->|adds research_data| Sup
Ana -->|adds analysis| Sup
Writ -->|adds final_report| Sup
Note
SupervisorState Definition The state of the clinical supervisor model is tracked using custom schema definitions:
class SupervisorState(MessagesState):
next_agent: str # Tracks routing targets (researcher/analyst/writer/end)
research_data: str # Gathers clinical study results and literature checks
analysis: str # Evaluates drug interaction risks and diagnostic flags
final_report: str # Houses the finalized case brief compiled by the writer
task_complete: bool # Signal flag to trigger END
current_task: str # Stores original patient case file metadataThe medical agent suite is designed to be highly modular and extensible. You can adapt it to any clinical domain:
| Component | Target File | Modification Details |
|---|---|---|
| Change LLM Model | pyproject.toml / Jupyter Notebooks | Modify init_chat_model("groq:llama-3.3-70b-versatile") parameters in notebooks to target different clinical fine-tunes. |
| Alter Supervisor Logic | Agents.ipynb | Edit prompt templates inside create_supervisor_chain to enforce strict compliance guidelines (e.g. HIPAA standards). |
| Add Specialized Agents | Agents.ipynb | Add new nodes (e.g. pharmacist_agent for drug interactions) and update router Literal endpoints. |
| Configure Local DB Checkpointing | HumaninLoop.ipynb | Replace in-memory checkpointer (MemorySaver) with persistent SQLite or Postgres savers for production clinical session tracking. |
- Model Context Protocol (MCP) for standardizing application-tool interaction.
- LangGraph Documentation for state graph architecture and patterns.
- Groq Cloud for high-performance Llama 3.3 model inference.