Introduction
MedMitra’s AI system employs a multi-agent architecture powered by LangGraph to process complex medical cases. The system orchestrates specialized agents that work together to analyze patient data, extract insights from medical documents, and generate comprehensive clinical assessments.Architecture Overview
The AI system consists of two primary specialized agents:Medical Insights Agent
Analyzes lab reports, generates SOAP notes, and provides diagnostic insights
Vision Agent
Processes radiology images using vision models to extract medical findings
System Components
1. Agent Orchestration Layer
Theagentic_process function in backend/agentic.py serves as the main orchestrator:
backend/agentic.py
2. State Management
The system uses TypedDict state models to track processing through the pipeline. The primary state container isMedicalAnalysisState:
backend/models/state_models.py
3. Data Flow
Processing Pipeline
The complete case analysis follows this sequence:File Upload & Categorization
Files are uploaded and categorized as either
lab or radiology documentsDocument Processing
- Lab files: Extracted using PDF parser to text
- Radiology files: Analyzed by Vision Agent for visual findings
Medical Analysis Workflow
The Medical Insights Agent processes documents through a LangGraph workflow:
- Process lab documents
- Process radiology documents
- Generate case summary
- Generate SOAP note
- Generate primary diagnosis
- Compile insights
Key Features
Parallel Processing
The system can process multiple documents concurrently:backend/agentic.py
Confidence Scoring
Every analysis step generates a confidence score (0.0-1.0) that reflects the model’s certainty:backend/agents/medical_ai_agent.py
Error Handling
The system tracks errors throughout the pipeline and updates case status accordingly:LangGraph Integration
MedMitra uses LangGraph to define the workflow as a directed graph. This provides:- Stateful processing: Each node updates the shared state
- Clear dependencies: Edges define the execution order
- Parallel execution: Independent nodes can run concurrently
- Error recovery: Failed nodes can be retried or alternative paths taken
Models Used
| Agent | Model | Purpose |
|---|---|---|
| Medical Insights Agent | llama-3.3-70b-versatile | Text analysis, diagnosis generation |
| Vision Agent | meta-llama/llama-4-scout-17b-16e-instruct | Medical image analysis |
Next Steps
Medical Insights Agent
Deep dive into the text analysis agent
Vision Agent
Learn about medical image processing
Workflow Details
Understand the complete processing pipeline
API Reference
Integrate with the case creation API
