← Latest papers
💻 computer science

PhenoAgent: agentic LLM framework for phenotyping electronic health records via structured query decomposition and self-correction

PhenoAgent is a privacy-preserving, agentic LLM framework that utilizes structured query decomposition, self-correction, and multi-model consensus to accurately extract clinical phenotypes from free-text electronic health records, significantly outperforming traditional baselines while matching physician-level performance on Japanese hospital datasets.

Original authors: Yuki Kashiwada, Rieko Sakurai, Yuta Yokokawa, Kenichiro Ando, Chinatsu Gocho, Chiaki Murata, Kosuke Tohda, Maki Tanioka, Shinya Sonobe, Tatsuya Harada, Jun Takayama

Published 2026-06-28
📖 5 min read🧠 Deep dive

Original authors: Yuki Kashiwada, Rieko Sakurai, Yuta Yokokawa, Kenichiro Ando, Chinatsu Gocho, Chiaki Murata, Kosuke Tohda, Maki Tanioka, Shinya Sonobe, Tatsuya Harada, Jun Takayama

Original paper licensed under CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine a hospital as a massive library where every patient's story is written in a unique, messy diary (the Electronic Health Record). Most of these stories are written in free-flowing paragraphs, not neat checklists. If a doctor wants to find all the patients who had a specific, complex situation—like "a heart attack that required a specific life-support machine"—they can't just search for the words "heart attack" and "machine." They have to read through thousands of messy diaries to find the ones where those two things happened together, often described in different ways or hidden in the middle of long sentences.

PhenoAgent is a new, smart tool designed to act like a super-efficient, privacy-focused librarian who can read these messy diaries and find exactly the right patients without ever leaving the hospital building.

Here is how it works, broken down into simple steps:

1. The "Recipe Breakdown" (Structured Query Decomposition)

Imagine you ask a chef to make a "Spicy Beef Stir-fry with Tofu." Instead of just shouting the order, PhenoAgent first breaks that order down into a strict shopping list:

  • Must have: Beef
  • Must have: Tofu
  • Must have: Spicy sauce
  • Must NOT have: Chicken

In the paper, this is called structured query decomposition. The system takes a complex medical question and turns it into a clear, structured checklist (a JSON schema) before it even starts reading the patient records. This stops the computer from getting confused by messy language.

2. The "Self-Correction Loop" (Self-Correction)

Sometimes, even smart computers get confused and write their answers in the wrong format (like writing a paragraph instead of a checklist). PhenoAgent has a built-in "spell-checker" for logic.

  • It asks three different AI "experts" to read the patient diary and fill out the checklist.
  • If an expert makes a mistake or writes the answer in the wrong format, the system says, "Wait, that doesn't look right. Try again."
  • The expert tries again (up to two more times) until the answer fits the checklist perfectly. This is the self-correction loop.

3. The "Unanimous Jury" (Unanimous Ensemble Voting)

This is the most important safety rule. PhenoAgent doesn't just ask one AI; it asks three different AI models (GPT-OSS-20B, DeepSeek-32B, and Llama-3.1-Swallow-70B).

  • Think of these three AIs as a jury.
  • To decide that a patient does match the criteria, all three jurors must vote "Yes."
  • If even one juror says "No" or "I'm not sure," the patient is not selected.
  • This makes the system very careful. It might miss a few patients (lower sensitivity), but it is extremely unlikely to pick someone who doesn't belong (high precision). It's better to be safe than sorry when dealing with medical data.

Why is this special?

Most AI tools today live in the "cloud" (on big servers owned by tech companies). Hospitals often can't send patient data there because of privacy laws.

  • The "Local" Advantage: PhenoAgent is designed to run entirely on a single computer inside the hospital. It uses "open-weight" models (like free, open-source software) so the hospital keeps all the data on its own walls. No data leaves the building.
  • The "Non-English" Advantage: It was tested specifically on Japanese hospital records, which are notoriously difficult for computers because they mix different writing systems and abbreviations.

The Results: How well did it work?

The researchers tested PhenoAgent on real patient records from two different Japanese hospitals.

  • The Gold Standard: They compared the AI's work against two human doctors. A patient was only counted as a "match" if both doctors agreed they fit the criteria.
  • The Score: PhenoAgent performed almost as well as the two doctors agreeing with each other. It scored a "macro-F1" of about 71.6, which is very close to the human agreement score of 71.4.
  • Beating the Old Ways: It crushed the old methods (like simple keyword searching or standard database searches) by a huge margin—improving accuracy by 24 to 43 points.

The Catch (Limitations)

The paper notes that because PhenoAgent uses the "Unanimous Jury" rule, it is very strict.

  • If a patient's condition is described vaguely or indirectly in the notes, the AI might say "No" because the three jurors couldn't all agree.
  • This is a trade-off: The system prioritizes accuracy (making sure it doesn't pick the wrong people) over finding every single possible match. This is great for clinical research where you need a very clean list of patients, but it might miss some rare cases.

Summary

PhenoAgent is a privacy-safe, locally-run AI librarian that breaks complex medical questions into checklists, double-checks its own work, and requires three different AI experts to agree before selecting a patient. It proved it could find the right patients in messy Japanese hospital records almost as well as human doctors, without ever sending sensitive data to the internet.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →