Dual-agent system improves analysis of clinical data with sql checks

Large Language Models for Structured Clinical Data Analysis: Dual-Agent Grounding and Validation

Artificial Intelligence

Summary

Analyzing complex medical data accurately is challenging because computer systems need to understand and fetch the right information from databases. The authors created a system called CLEAR-Med that uses two agents: one translates questions into database commands and the other checks those answers independently. This setup helps catch mistakes and makes sure the answers are reliable by linking every answer to the exact data command that generated it. Their tests showed this approach gives much more accurate results than a typical chatbot. The system is designed to handle large datasets and can refuse to answer when not confident, improving trust in clinical data analysis.

What this means in practice

  • For hospital data teams: Use CLEAR-Med to convert clinical questions into database queries with built-in validation to improve accuracy and traceability of clinical data analysis.
  • For electronic health record developers: Integrate a dual-agent approach to provide more reliable SQL-based query handling and error checking within clinical data querying tools.

Tested on one dataset.

Authors

Erfan D. Dehkalani, Seetha Shankaran, Abbot R. Laptook, C. Michael Cotten, P. Ellen Grant, Yangming Ou

Abstract

Objective: To develop and characterize CLEAR-Med, a dual-agent framework for natural-language analysis of structured clinical data that separates SQL-based invocation from independent validation. Methods: CLEAR-Med uses one agent to translate a question into executable Structured Query Language (SQL), retain the executed query and database result, and produce a draft. Deterministic checks and a separately invoked cross-provider Validation Agent then accept the draft, request one bounded repair, or abstain. We formalized the system as a bounded selective pipeline and evaluated CLEAR-Med's configuration and scalability, and the Invocation Agent's accuracy and consistency on a 25-query development benchmark, using a harmonized 21-site neonatal hypoxic-ischemic encephalopathy table containing 532 de-identified infant records and approximately 1,300 variables. Results: CLEAR-Med completed all six nominal scalability configurations, including 500x1300. Across 25 development-benchmark queries repeated five times, the Invocation Agent answered 83 of 125 responses correctly (66.4%; query-cluster bootstrap 95% CI, 48.0-83.2%), compared with 15 of 125 (12.0%; 95% CI, 3.2-22.4%) for the ungrounded ChatGPT baseline, a paired improvement of 54.4 percentage points (95% CI, 36.8-72.0%). Conclusion: CLEAR-Med provides a general architecture for traceable analysis of structured clinical data: numerical claims remain linked to executed SQL, and unresolved cases can fail closed. The reported experiments characterize CLEAR-Med's configuration and scalability and the Invocation Agent's accuracy, while the formal analysis establishes the encoded-property guarantee of the complete control flow; a prospective full-pipeline evaluation of the validation and abstention stages is the next stage of this work.