Skip to content

Latest commit

 

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

MIRA

Medical Intelligence for Reasoning and Action
An electronic health record–integrated medical AI agent and evaluation environment.

Published in Nature (2026)

flowchart TB
    subgraph C["EHR-integrated clinical encounter"]
        direction LR
        P("Patient simulator<br/>History and responses") <--> A("MIRA<br/>Medical agent")
        A <--> T("Clinical tool layer<br/>11 tools · >85,000 actions")
        T <--> E("FHIR EHR sandbox<br/>Read / write records")
    end
    C -->|Encounter traces| V("Evaluation harness<br/>Diagnosis · guidelines · safety · robustness")
    classDef agent fill:#111827,stroke:#F97316,stroke-width:3px,color:#FFFFFF;
    classDef context fill:#F1F5F9,stroke:#94A3B8,stroke-width:1px,color:#0F172A;
    classDef tools fill:#FFF7ED,stroke:#F97316,stroke-width:1px,color:#7C2D12;
    classDef evaluation fill:#ECFDF5,stroke:#6EE7B7,stroke-width:1px,color:#064E3B;
    class A agent;
    class P,E context;
    class T tools;
    class V evaluation;
    style C fill:#FFFFFF,stroke:#CBD5E1,stroke-width:1px,color:#475569;
    linkStyle default stroke:#64748B,stroke-width:1.5px;
Loading

Original repository schematic. EHR: electronic health record.

MIRA — Medical Intelligence for Reasoning and Action — connects clinical reasoning to structured actions in a sandboxed electronic health record (EHR). It combines a patient-simulation loop, 11 clinical tools, and more than 85,000 possible clinical actions, covering history taking, investigations, diagnosis, medication orders, procedures, and admission planning.

📊 Published results

The study evaluates simulated clinical encounters grounded in retrospective MIMIC-IV patient records. The full diagnostic benchmark and physician-comparison subset are reported separately.

Evaluation Published result Evaluation scope
Diagnostic accuracy 88.9% 574 cases across eight diagnoses, evaluated against MIMIC-IV discharge diagnoses
Diagnostic accuracy versus board-certified physicians 87.8% vs. 78.1% Same 311 cases; four board-certified physicians; P < 0.001
Diagnostic accuracy versus mixed-seniority physicians 87.8% vs. 71.1% Same 311 cases; two board-certified physicians and four residents; P < 0.001
Prescribing-guideline adherence +35 percentage points Mean paired difference versus board-certified physicians
Prescribing-safety audit No high-severity findings in five prespecified domains 56 cases: drug interactions, kidney-adjusted dosing, allergies, cardiac-rhythm risk, and opioid prescribing. A sixth domain, therapeutic duplication, yielded three flags judged clinically reasonable.

Ten physicians participated across the two comparison cohorts. Robustness analyses also examined patient sex, language, anxiety and illness beliefs, plus simulator consistency, fidelity to the recorded history, and resistance to premature diagnostic disclosure under adversarial prompting.

See the paper and supplementary information for the full methods, statistical analyses, safety assessments, and study limitations. These are research-evaluation results, not evidence of prospective clinical deployment.

🧩 Architecture and code

The implementation separates agent orchestration, typed clinical tools, record operations using Fast Healthcare Interoperability Resources (FHIR), and evaluation. The published experiments used o1-preview for planning and GPT-4o for simulation.

Component Entry points
Agent orchestration and tools assistants.py, routines.py, tools.py, tool_execs.py
EHR integration backend/, mimic_to_fhir.py, fhir_handlers.py
Dataset preparation dataset/
Baseline and robustness runs runs/
Agent and physician evaluation evaluations/
Central paths and configuration paths.py, config.py, .env.example

⚙️ Getting started

Prerequisites

  • Python 3.12 and the dependencies in src/pyproject.toml.
  • Docker for the local FHIR server and Qdrant service.
  • Model-provider credentials and access to the models configured for the selected experiment.
  • Authorized access to the MIMIC-IV datasets needed for the experiment; see Data access and responsible use.

Run installation commands from the repository root:

git clone https://github.com/Dyke-F/MIRA.git
cd MIRA
python3.12 -m venv src/.venv
source src/.venv/bin/activate
python -m pip install -U pip uv
uv pip install -e ./src

Create a local src/.env using src/.env.example as the template. Configure dataset locations, model credentials, and service settings for your environment. Keep credentials and patient-level artifacts out of version control.

The model names used in the publication identify the original experimental setup. Check provider access and configuration before running experiments; using a different model constitutes a new experimental condition.

🔬 Reproduction workflow

The workflow is dataset preparation → context preparation → local services → procedure database → simulations → evaluations. Run shell commands from MIRA/; use the notebook working directories specified below. Read the linked component README before each stage.

1. Prepare diagnosis datasets

Configure the MIMIC source directories in src/.env as described in the dataset guide, then run:

uv run --project src python src/dataset/make_dataset.py

Diagnosis datasets are written to src/raw/derived/diagnosis_datasets/, or to the location selected with MIRA_DIAGNOSIS_DATASETS_DIR.

For an initial subset, the extraction script supports:

export MIRA_DATASET_DIAGNOSES="appendicitis,pancreatitis"
export MIRA_MAX_DIAGNOSES=1
export MIRA_MAX_HADM_IDS_PER_DIAGNOSIS=20
export MIRA_OVERWRITE_DATASETS=ask

The overwrite options are ask, yes, and no. With ask, the script requests confirmation before replacing an existing diagnosis dataset. Review the output locations before selecting yes for an unattended run.

For extraction across all diagnoses, clear the subset controls:

unset MIRA_DATASET_DIAGNOSES
unset MIRA_MAX_HADM_IDS_PER_DIAGNOSIS
unset MIRA_MAX_DIAGNOSES
uv run --project src python src/dataset/make_dataset.py

2. Prepare pancreatic-cancer context when needed

For experiments containing pancreatic-cancer cases, run extract_pancreatic_cancer_info.ipynb after dataset extraction. It uses OPENAI_API_KEY and writes the context resource to src/resources/pancreatic_cancer_info.json.

See the notebook guide for prerequisites and execution order.

3. Start the local services

Start the FHIR backend using the existing Docker Compose configuration:

docker compose -f src/backend/hapi-fhir-server/docker-compose.yml up -d

See the backend guide for the FHIR service configuration.

Start Qdrant with local persistent storage:

docker run -p 6333:6333 -p 6334:6334 \
  -v "$(pwd)/src/raw/runtime/qdrant/main:/qdrant/storage:z" \
  -e QDRANT__TELEMETRY_DISABLED=true \
  qdrant/qdrant

4. Build the procedure database

With Qdrant running, execute build_procedure_db.ipynb, following the notebook guide.

5. Run the selected experiments

Open simulation notebooks from src/runs/ so their local imports resolve correctly.

Experiment Notebook
Baseline simulation run_simulation.ipynb
Patient-attribute robustness run_simulation_bias.ipynb
Admission decisions run_simulation_optional_admission.ipynb
Leakage and adversarial analysis run_leakage_and_adversarial.ipynb

Review each notebook's initial parameter cells before execution, including diagnosis selection, sample limits, and admission IDs. Notebooks include selective-run controls such as break and RUN_CELL=False; configure these deliberately for the intended experiment size. Full runs can take substantial time and incur model-API costs.

Outputs are stored under src/raw/evaluable_outputs/. The leakage/adversarial analysis uses existing encounter outputs. Further details are in the run guide.

6. Evaluate encounter outputs

Open evaluation notebooks from src/evaluations/ and follow the evaluation guide:

Optional preparation and maintenance

Admission-focused extraction uses:

uv run --project src python src/dataset/make_admission_datasets.py

Prepare its edited Excel inputs under src/raw/inputs/optional_admission/pneumonia/ and src/raw/inputs/optional_admission/pe/ according to the dataset guide.

Enum and medication-code-map regeneration are separate maintenance tasks, described in MimicEnums/README.md and codes/README.md. Standard runs use the versioned mappings.

🔒 Data access and responsible use

MIMIC-IV is distributed through PhysioNet under its own credentialing and data-use requirements. Obtain access directly from the data provider and follow the applicable requirements for processing, storage, and model-service use.

Keep source records, patient-level prompts, encounter transcripts, generated clinical outputs, and credentials in your authorized research environment. Do not publish them in repositories, issues, screenshots, or logs. Source-code and article licenses do not override dataset access restrictions.

See raw/README.md and resources/README.md for the separation of input resources and generated outputs. The software is intended for research and evaluation in controlled environments.

📚 Citation

@article{ferber2026mira,
  title   = {Towards autonomous medical artificial intelligence agents},
  author  = {Ferber, Dyke and Hilgers, Lars and H{\"o}per, Christiane and
             Kinny-K{\"o}ster, Benedict and Eckardt, Jan-Niklas and
             Egger-Heidrich, Katharina and Bill, Marius and
             Schneider, Martin M. K. and Clusmann, Jan and Kadric, Lejla and
             Oehme, Marcel and Mayrhofer-Schmid, Maximilian and Oeser, Alexander and
             W{\"o}lflein, Georg and Wiest, Isabella C. and Middeke, Jan Moritz and
             Iafrate, A. John and Truhn, Daniel and J{\"a}ger, Dirk and
             Kather, Jakob Nikolas},
  journal = {Nature},
  volume  = {655},
  pages   = {1282--1291},
  year    = {2026},
  doi     = {10.1038/s41586-026-10675-5},
  url     = {https://doi.org/10.1038/s41586-026-10675-5}
}

⚖️ Licenses and attribution

Repository code is covered by the existing MIT license. The article is published under Creative Commons Attribution 4.0, subject to its third-party credit lines. This README provides a new summary of the study rather than reproducing the article or its figures. Data, external models, and third-party software retain their own terms.

About

No description, website, or topics provided.

Resources

Stars

94 stars

Watchers

4 watching

Forks

Releases

Packages

Contributors

Languages