Abstract
The prescription is a critical bridge between medical diagnosis and therapeutic intervention, embodying a complex decision that balances medical evidence, clinical experience, and individual patient needs. However, the prescribing process faces significant challenges from rising drug costs and the existence of therapeutically similar but economically diverse drug options, creating an urgent need for prescription optimization that maintains therapeutic efficacy while reducing financial burden. While artificial intelligence (AI) agents have demonstrated transformative potential in automating complex tasks across scientific and medical domains, their application has not yet adequately addressed the critical dimension of economic impact within healthcare. To bridge this gap, we develop EcoRxAgent, an AI agent designed to generate economically substitutable prescriptions. This agent operates through a sequential pipeline that retrieves candidate drugs, generates candidate prescription sets, rigorously checks their safety, conducts a cost-effectiveness analysis, and ultimately outputs all economically substitutable prescriptions (i.e. safety-checked prescriptions with lower total cost). Our experimental results on two independent cohorts (total n = 1559) prescriptions show that the agent can automatically generate prescriptions that are therapeutically non-inferior to physicians’ original prescriptions while achieving a significant reduction ratio in overall medication costs ranging from 14.40% to 40.14%. This study demonstrates the substantial potential of AI agents in creating tangible economic benefits within the healthcare domain.
Subject terms: Business and industry, Computational biology and bioinformatics, Health care, Mathematics and computing, Medical research
Introduction
The prescription, serving as a critical component and core vehicle of clinical diagnosis and treatment activities, constitutes a crucial bridge linking medical diagnosis with therapeutic intervention1. In medical practice, physicians synthesize patient complaints, medical history, physical examinations, and auxiliary diagnostic results to form a preliminary diagnosis, ultimately translating the treatment plan into a medication list—the prescription. This document not only precisely specifies drug names, dosages, administration methods, and treatment duration but also embodies the physician’s understanding of disease pathophysiology, treatment goals, and consideration of individual patient factors (such as hepatic and renal function, allergy history, and comorbidities). Therefore, the prescription essentially represents a decision-making outcome resulting from meticulous balancing of the current best medical evidence, clinical experience, and specific patient needs, with its scientific validity and appropriateness directly determining therapeutic efficacy and patient safety.
However, the prescription process faces increasingly complex challenges. Rapidly rising drug costs have become a significant global factor that cannot be ignored2. For the same therapeutic objective, multiple drug options with similar pharmacological mechanisms and comparable efficacy but substantially different prices often exist in clinical practice3. In the absence of real-time, precise pharmacoeconomic data support, physicians under heavy workloads often rely on personal experience or limited drug information when prescribing4,5, potentially leading to suboptimal allocation of medical resources—patients bear unnecessarily higher drug costs without significant improvement in therapeutic outcomes. This contradiction suggests the urgency and potential of conducting “economic optimization” of prescriptions while ensuring efficacy and safety, which holds significant socioeconomic implications for patients, medical institutions, and even the nation2,6. For instance, after the renewal of China’s National Reimbursement Drug List (NRDL), analyzing the long-term and short-term cost-effectiveness of different prescriptions for the same disease has become an important research topic7.
How to automate and intelligently support this decision-making process represents a key scientific question for improving healthcare system efficiency and equity. However, requiring physicians to select cost-effective options by comparing drug functions, unit prices, specifications, dosage requirements, and total prescription costs from a vast array of similar medications would impose a substantial burden. This challenge is particularly pronounced in highly demanding clinical settings such as emergency department (ED), characterized by heavy workloads, broad patient coverage, and extensive medication varieties.
Artificial intelligence (AI) agents, as a core tool for achieving automated and intelligent decision-making support, have demonstrated broad application potential across multiple disciplinary fields, such as chemistry8,9, materials10,11, and biology12,13. Recently, Ding et al. developed an AI agent that autonomously orchestrates hundreds of scientific tools across diverse domains, including biology, chemistry, and materials science14. In the medical field, AI agents have also demonstrated significant importance. For instance, Ferber et al. presented a GPT-4 based clinical agent for supporting personalized clinical decision-making in oncology15. Swanson et al. proposed a Virtual Lab of AI agents that successfully designed new SARS-CoV-2 nanobodies16. Tu et al. designed an AI agent that demonstrated superior diagnostic accuracy and communication skills compared to human primary care physicians in clinical dialogues17. Wu et al. developed an agent-based pipeline that assesses how well large language models (LLMs) cite relevant medical references, which is very crucial in health-related queries18. Higgins et al. developed a reinforcement learning-based AI clinician system that personalizes treatment for Helicobacter pylori infections19. The aforementioned studies demonstrate the capability of AI agents to autonomously conduct complex interdisciplinary medical research, enhance diagnostic quality and patient-centered care, and improve clinical decision-making and patient outcomes through experimentally validated therapeutic candidates. However, while these studies highlight the potential of AI agents in medicine, they have not yet adequately considered the economic impact of agents in the healthcare domain.
To address the above challenges, in this study, we develop and validate an AI agent for generating economically substitutable prescriptions, which is called Economical Prescription Agent (EcoRxAgent). As shown in Fig. 1a, the EcoRxAgent system consists of four tools, namely candidate drug retrieval tool, candidate prescription generation tool, safety-check tool and cost-effectiveness analysis tool. The input to EcoRxAgent is the physician’s original prescription (i.e., baseline prescription). First, the candidate drug retrieval tool utilizes patient’s clinical information, along with the drug list from the baseline prescription to query a large language model (LLM) and generate a candidate drug list from the hospital pharmacy database. Next, the candidate prescription generation tool generates a set of candidate prescriptions by using the candidate drug list together with patient’s clinical information. Subsequently, the safety-check tool evaluates all candidate prescriptions against safety & clinical guidelines in combination with patient’s clinical information, resulting in a set of safety-checked prescriptions. Finally, the cost-effectiveness analysis tool calculates the total cost for each safety-checked prescription based on drug unit prices, specifications, and dosage requirements, and outputs all economically substitutable prescriptions with safety-check and lower total cost than that of baseline prescription. After physician review and selection, the economically substitutable prescription with the highest score is regarded as best possible prescription generated by EcoRxAgent.
Fig. 1. Overview of this study.
a The pipeline of the proposed EcoRxAgent system, which autonomously utilizes four tools so as to generate economically substitutable prescriptions for physician review and selection by taking as input the baseline prescription along with patient’s clinical information, hospital pharmacy database, and safety & clinical guidance. b The experimental validation procedure on the primary Guangzhou cohort, which validates the effectiveness of EcoRxAgent from three different perspectives, namely clinical effectiveness evaluation, cost effectiveness evaluation and joint evaluation, by utilizing 1698 patients with baseline prescription and 423 drugs with standardized daily dose pricing. Because the validation procedure on the Shenshan cohort is very similar to that on the Guangzhou cohort, it is omitted in this figure.
Comprehensive evaluation of EcoRxAgent across 1,698 emergency department patients in the primary Guangzhou cohort demonstrates its capacity to generate clinically sound and economically efficient prescriptions. EcoRxAgent identified economically substitutable prescriptions for 799 patients (47.06%) while maintaining therapeutic quality, as validated through double-blind physician assessment using a standardized five-point Likert scale. Remarkably, for 766 (95.87%) of the 799 patients, EcoRxAgent generated a best possible prescription with a clinical score equivalent to or higher than that of the baseline prescription, with Respiratory conditions showing particular optimization potential. Economic analysis revealed an average cost reduction ratio of 14.40%, with some disease categories like ENT conditions and Respiratory diseases achieving cost reduction ratios exceeding 20%. Joint clinical-cost effectiveness assessment showed that 38.05% of patients maintained comparable expected clinical outcomes while reducing costs by over 40%, demonstrating the agent’s ability to deliver “equal clinical effectiveness at lower cost”.
Crucially, the system’s generalizability was demonstrated through external validation on an independent Shenshan cohort (comprising 760 patients identified from an initial pool of 1,600 patients), where 90.53% of generated prescriptions achieved clinical non-inferiority compared to baseline. The system exhibited consistent performance across diverse clinical scenarios and geographical settings, generating multiple therapeutically valid prescriptions for numerous cases while maintaining consistent safety standards. Differential performance across disease categories—with Respiratory conditions showing both clinical and economic advantages, while Trauma cases exhibited more constrained optimization—provides valuable insights for targeted clinical implementation. This study establishes that AI-driven prescription optimization can simultaneously advance therapeutic quality and economic efficiency, demonstrating the transformative potential of AI in creating more sustainable and accessible healthcare systems.
Results
Patient characteristics and prescription information
In this study, we retrospectively utilized the database of real-world electronic medical records (EMRs) and corresponding prescription records from the Emergency Department of Sun Yat-sen Memorial Hospital, Sun Yat-sen University Guangzhou, China, between January 2022 and March 2023. Structured clinical information was extracted for each patient, including chief complaint, present illness, past medical history, allergy history, physical examination findings, and diagnosis. After rigorous preprocessing and filtering, 1,698 valid patient cases were included for analysis, which is regarded as the primary cohort called Guangzhou cohort. Among these 1698 patient cases, it was found that 799 patient cases contain economically substitutable prescriptions generated by using 423 commonly used drugs in the Emergency Department.
Patient demographic and prescription statistic information of the primary Guangzhou cohort are presented in Table 1. From the table, it is obvious that prescriptions of different categories contain various average number of drugs. Among the five major categories, respiratory conditions and gastrointestinal conditions contain prescriptions with larger average number of drugs. Some representative prescriptions and detailed drug information are provided in the supplementary material. Detailed information on the 423 commonly used drugs and representative prescription examples are provided in the Supplementary Information (Supplementary Tables S1 and S2, respectively).
Table 1.
Patient demographic and prescription statistic information for the Guangzhou cohort
| Characteristic | Patients in the study dataset (n = 1698) | Patients with economically substitutable prescriptions (n = 799) | ||
|---|---|---|---|---|
| Age (mean and range, years) | 37.76 (14–101) | 36.74 (14–89) | ||
| Sex | ||||
| Male | 841 | 408 | ||
| Female | 857 | 391 | ||
| Prescriptions | Prescription number | Drugs per Rx Mean (Med, Range) | Prescription number | Drugs per Rx Mean (Med, Range) |
| Respiratory conditions | 479 | 3.82 (4, 1–10) | 243 | 3.55 (3, 1–7) |
| Gastrointestinal conditions | 219 | 3.29 (3, 1–12) | 107 | 3.49 (4, 1–6) |
| ENT conditions | 121 | 1.54 (1, 1–4) | 62 | 1.48 (1, 1–4) |
| Trauma patients | 601 | 2.14 | 286 | 2.44 |
| Extremity injuries | 239 | 2.14 (2, 1–6) | 123 | 2.40 (2, 1–5) |
| Hand and foot injuries | 147 | 2.16 (2, 1–6) | 59 | 2.78 (3, 1–5) |
| Head injuries | 72 | 1.99 (2, 1–5) | 27 | 2.52 (3, 1–5) |
| Facial injuries | 42 | 2.26 (2, 1–5) | 19 | 2.68 (2, 1–5) |
| Lower back and back injury | 45 | 2.44 (2, 1–8) | 24 | 2.17 (1.5, 1–6) |
| Chest injuries | 20 | 1.65 (1, 1–4) | 15 | 1.67 (1, 1–3) |
| Neck injuries | 10 | 2.20 (2.5, 1–4) | 5 | 2.00 (2, 1–3) |
| Abdominal and pelvic injury | 5 | 2.00 (2, 1–3) | 3 | 2.00 (2, 1–3) |
| Ocular injuries | 3 | 1.67 (2, 1–2) | 0 | 0 |
| Genital injuries | 2 | 2.00 (2, 2–2) | 1 | 2.00 (2, 2–2) |
| Nasal injuries | 2 | 2.50 (2.5, 2–3) | 0 | 0 |
| Other injuries | 14 | 2.14 (1.5, 1–4) | 10 | 2.60 (3, 1–4) |
| Other patients | 278 | 2.02 | 101 | 2.02 |
| Dermatology | 74 | 2.27 (2, 1–6) | 22 | 2.09 (2, 1–4) |
| Musculoskeletal system | 67 | 2.00 (2, 1–6) | 40 | 1.95 (2, 1–4) |
| Urological surgery | 38 | 1.84 (2, 1–6) | 12 | 2.00 (2, 1–4) |
| Nephrology | 28 | 1.96 (2, 1–4) | 10 | 1.80 (1.5, 1–3) |
| Stomatology | 17 | 2.65 (3, 1–5) | 8 | 2.62 (3, 1–3) |
| Environmental injuries | 17 | 1.65 (1, 1–5) | 3 | 2.00 (2, 2–2) |
| Neurological system | 16 | 1.81 (2, 1–3) | 4 | 2.25 (2.5, 1–3) |
| Cardiovascular system | 8 | 1.75 (2, 1–3) | 0 | 0 |
| Gynecology | 8 | 1.62 (1.5, 1–3) | 2 | 1.00 (1, 1–1) |
| Ophthalmology | 4 | 1.25 (1, 1–2) | 0 | 0 |
| Poisoning | 1 | 1.00 (1, 1–1) | 0 | 0 |
To further evaluate the consistency and generalizability of EcoRxAgent, we extended our study to include a multi-center validation cohort collected from external medical institution, namely the Emergency Department of Shenshan Medical Center of Memorial Hospital of Sun Yat-sen University, Shanwei, China in November 2025. Following the same inclusion and exclusion criteria, this external cohort named Shenshan cohort yielded a total of 760 valid patient cases with economically substitutable prescriptions for independent evaluation. A brief version of patient demographic and prescription statistic information of the Shenshan cohort are presented in Table 2.
Table 2.
Patient demographic and prescription statistic information for the external Shenshan cohort
| Characteristic | Patients in the study dataset (n = 1600) | Patients with economically substitutable prescriptions (n = 760) | ||
|---|---|---|---|---|
| Age (mean and range, years) | 44.25 (18.0–99.0) | 38.39 (14–96) | ||
| Sex | ||||
| Male | 804 | 361 | ||
| Female | 796 | 399 | ||
| Prescriptions | Prescription number | Drugs per Rx Mean (Med, Range) | Prescription number | Drugs per Rx Mean (Med, Range) |
| Respiratory conditions | 531 | 3.10 (3, 1–9) | 253 | 3.01 (3, 1–8) |
| Gastrointestinal conditions | 212 | 3.25 (3, 1–11) | 101 | 3.08 (3, 1–11) |
| ENT conditions | 235 | 2.65 (2, 1–9) | 112 | 2.53 (2, 1–8) |
| Trauma patients | 229 | 2.60 (2, 1–8) | 109 | 2.51 (2, 1–6) |
| Other patients | 393 | 2.65 (2, 1–10) | 185 | 2.49 (2, 1–7) |
Regarding the generation rate of substitutable prescriptions, the system demonstrated consistent performance across datasets. In the primary Guangzhou cohort, 799 out of 1698 cases (47.06%) resulted in the generation of economically substitutable prescriptions. Similarly, in the external Shenshan cohort, 760 out of 1600 cases (47.50%) yielded substitutable prescriptions. The remaining cases (899 in the primary and 840 in the external cohort) yielded empty sets. This outcome indicates that for these patients, the baseline prescription was already optimal regarding cost-effectiveness within the safety constraints, or that no pharmacologically equivalent alternatives were available in the hospital formulary. Consequently, the agent correctly refrained from suggesting substitutions, prioritizing patient safety and avoiding unnecessary cost increases.
EcoRxAgent can generate clinically effective prescriptions
To evaluate the clinical effectiveness of EcoRxAgent, in the primary Guangzhou cohort, we first compared the best possible prescription score against baseline prescription score across all 799 patients with economically substitutable prescriptions and within five major disease categories: Respiratory conditions, Gastrointestinal conditions, ENT conditions, Trauma patients (encompassing 12 subcategories), and Other patients (encompassing 11 subcategories). A two-dimensional scatter plot was constructed with the baseline prescription score on the x-axis and the best possible prescription score on the y-axis. As illustrated in Fig. 2a, for the overall cohort, 721 patients (90.24%) exhibited best possible prescription scores identical to their baseline scores, with data points aligning precisely along the angle bisector. This result demonstrates EcoRxAgent’s ability to consistently generate prescriptions that are clinically non-inferior or superior to physician-originated prescriptions from the perspective of senior physician evaluation. Subgroup analyses (Fig. 2b–f) revealed that Respiratory conditions had the highest number of patients (n = 23) with improved scores, suggesting greater optimization potential in this category. Conversely, Gastrointestinal conditions showed the highest incidence of score reductions (n = 10), indicating relatively constrained optimization efficacy for these cases.
Fig. 2. Clinical effectiveness evaluation for the Guangzhou cohort.
a–f Comparison between best possible prescription score and baseline prescription score, where (p) indicates the number of the same points. g–l Capacity to generate multiple clinically effective substitutable prescriptions, quantifying the number of economically substitutable prescriptions per patient that achieved scores equivalent to or higher than the baseline prescription (denoted as Num), e.g., in subfigure g Num = 5 (114) indicates globally, 114 patients had Num=5, meaning EcoRxAgent generated five substitutable prescriptions that were all clinically equivalent or superior to the baseline.
We further investigated the capacity of EcoRxAgent to generate multiple valid alternatives by quantifying the number of economically substitutable prescriptions per patient that achieved scores equivalent to or higher than the baseline prescription (denoted as Num, where Num ranges from 0 to 5, reflecting the system’s design constraint to output a maximum of top-5 recommendations to facilitate efficient clinical review). The distribution of patients across Num values (0–5) was analyzed for the overall cohort and each disease category. As shown in Fig. 2g, globally, 114 patients had Num = 5, meaning EcoRxAgent generated five substitutable prescriptions that were all clinically equivalent or superior to the baseline. This suggests the agent’s capability to consistently offer a spectrum of high-quality alternatives rather than isolated instances, providing physicians with greater flexibility in decision-making. Category-specific analyses (Fig. 2h–l) demonstrated that Respiratory conditions accounted for 85 patients with Num=5, substantially surpassing other categories. This aligns with prior findings, reinforcing that Respiratory conditions exhibit the greatest potential for clinical optimization through EcoRxAgent, while other categories vary in their responsiveness to prescription substitution. In the external Shenshan cohort, similar results on the clinical effectiveness can be obtained, as shown in Fig. 3. The results on both cohorts demonstrated the consistency and generalizability of EcoRxAgent across different geographical settings and pharmacy formularies in generating clinically effective prescriptions.
Fig. 3. Clinical effectiveness evaluation for the Shenshan cohort.
a–f Comparison between best possible prescription score and baseline prescription score, where (p) indicates the number of the same points. g–l Capacity to generate multiple clinically effective substitutable prescriptions, quantifying the number of economically substitutable prescriptions per patient that achieved scores equivalent to or higher than the baseline prescription (denoted as Num).
To address the potential risk of selection bias—where a physician might select a suboptimal alternative from the provided list20—we extended our evaluation to include the entire set of all economically substitutable prescriptions generated by EcoRxAgent, rather than solely the highest-scoring ones. As illustrated in Fig. 4, the clinical scores of these comprehensive candidates were plotted against the baseline scores. Analysis of the full candidate set revealed high consistency in therapeutic quality. In the primary Guangzhou cohort, i.e. Fig. 4a–f, among all generated alternatives, 1764 prescriptions (91.35%) achieved clinical scores equivalent to or higher than the baseline prescription (Score ≥ Baseline). Consistent with the system’s design, the number of generated prescriptions varied per patient, resulting in a total of 1931 generated prescriptions for the 799 patients (Distribution details are provided in Supplementary Fig. S1). Conversely, 167 (8.65%) of the generated prescriptions were rated as inferior to the baseline. This rate indicates that the majority of generated prescriptions are clinically sound, demonstrating the system’s potential as a high-quality decision support tool that functions best under physician oversight. Similar trends were observed in the external Shenshan cohort, i.e. Fig. 4g–l, indicating the stability of the candidate pool quality.
Fig. 4. Comparing all generated economically substitutable prescription scores against baseline prescription scores.
a–f Comparison results for the Guangzhou cohort. g–l Comparison results for the Shenshan cohort.
Notably, regarding the safety dimension, no prescriptions were flagged as “Unsafe” (0% rejection rate) in the Stage 1 safety evaluation. Furthermore, non-critical issues such as therapeutic duplication were not filtered out at this stage but were instead penalized in the Stage 2 holistic scoring (e.g., resulting in ‘Suboptimal’ ratings), ensuring that the final evaluation captured the nuances of clinical rationality beyond basic safety.
EcoRxAgent can generate cost-effective prescriptions
To evaluate cost effectiveness, we analyzed the distribution of cost reduction ratios across prescriptions stratified by their baseline cost levels. The analysis is mainly conducted on the primary Guangzhou cohort. For each of the 799 patients, a scatter plot was generated with baseline prescription total cost on the x-axis and the corresponding cost reduction ratio on the y-axis. The results were further categorized into five intervals based on reduction ratios (0–20%, 20–40%, 40–60%, 60–80%, and 80–100%), with counts annotated for each interval. As shown in Fig. 5a, across all patients, 273 (34.17%) achieved a cost reduction ratio between 0–20%, while 185 (23.15%) and 235 (29.41%) fell into the 20–40% and 40–60% intervals, respectively. This demonstrates EcoRxAgent’s ability to meaningfully reduce prescription costs while reflecting realistic drug price distributions. Subgroup analyses (Fig. 5b–f) revealed that Respiratory conditions (Fig. 5b) exhibited a dispersed distribution of reduction ratios across low- and high-cost prescriptions, indicating consistent cost-effectiveness regardless of initial expense. In contrast, Trauma patients (Fig. 5e) showed limited reduction ratios for high-cost prescriptions (e.g., those around CNY 300), a finding consistent with the clinical characteristics of trauma care, where drug substitutions may be constrained by specific therapeutic requirements.
Fig. 5. Cost effectiveness evaluation for the Guangzhou cohort.
a–f Cost reduction ratio (y-axis) achieved on baseline prescriptions ordered by baseline prescription total cost (x-axis). Each data point represents the best possible economically substitutable prescription for a single patient (n = 799). g–h Mean value of best possible prescription total cost vs. mean value of baseline prescription total cost, along with mean value reduction ratio and absolute cost reduction. In sub-figure g, the prescriptions are categorized by diseases while in sub-figure h, subgroups containing the four drug categories (Antibiotics, PPI, NSAID, Topicals) are listed.
We further compared the mean total costs of baseline and best possible prescriptions to quantify overall economic impact. As summarized in Fig. 5g, across all patients with economically substitutable prescriptions, EcoRxAgent achieved a mean cost reduction ratio of 14.40%, demonstrating its ability to lower expenses without compromising clinical quality. To complement this relative measure, we also analyzed the absolute cost reduction, which provides a direct indicator of tangible financial savings. The data reveal a relatively consistent absolute reduction across different disease categories, ranging from approximately 7.59 CNY (Respiratory) to 11.54 CNY (Trauma). These results indicate that the agent achieves measurable cost reductions across different disease categories. Disease-specific analysis revealed substantial variation: ENT conditions, Other patients, and Respiratory conditions, each exhibited mean reduction ratios exceeding 20%, indicating pronounced economic benefits in these categories. Although Trauma patients showed a more modest mean reduction ratio of 9.03%, the absolute cost savings remained notable, i.e., mean baseline costs of CNY 127.78 were reduced to CNY 116.24 in these 286 Trauma patients with economically substitutable prescriptions, yielding tangible per-prescription savings. These findings highlight EcoRxAgent’s role in delivering economically viable substitutions across diverse clinical scenarios, with particularly strong performance in non-traumatic conditions and meaningful absolute savings even in complex cases such as trauma.
To further dissect the sources of economic savings, we performed a subgroup analysis based on main drug categories (Fig. 5h). The results highlight distinct variations in optimization potential. Topicals emerged as the category with the highest economic impact, achieving a mean cost reduction ratio of 36.18% (Absolute reduction: 9.79 CNY). This suggests high substitutability among external preparations. PPIs (Proton Pump Inhibitors) and NSAIDs demonstrated moderate savings of 18.60% and 12.95%, respectively. Conversely, Antibiotics exhibited a more conservative reduction ratio of 8.64%, potentially reflecting stricter clinical guidelines and limited substitutability for antimicrobial regimens. These category-specific insights allow for more targeted deployment of the agent in high-yield domains.
To further characterize the optimization behavior of EcoRxAgent, we quantified the number of drugs substituted in each generated prescription (Table 3). The analysis revealed that the agent predominantly performs targeted substitutions. Specifically, in 68.96% (551/799) of cases, only a single medication was replaced, while 23.90% (191/799) of cases involved a two-drug substitution. More complex substitutions (3 or more drugs) accounted for 7.13% (57/799) of the total cases. Subgroup analysis indicated significant variation across disease categories. Respiratory conditions exhibited the highest substitution complexity, accounting for all cases where 5 or 6 drugs were substituted. This reflects the multi-drug regimens typical of respiratory treatments (e.g., combinations of antibiotics, antitussives, and mucolytics). In contrast, Trauma and ENT patients showed a high prevalence of single-drug substitutions (80.07% and 77.42%, respectively), likely due to simpler baseline medication structures in these categories.
Table 3.
Distribution of the number of substituted drugs per prescription across different disease categories for the Guangzhou cohort
| Category | Total | 1 Drug | 2 Drugs | 3 Drugs | 4 Drugs | 5 Drugs | 6 Drugs |
|---|---|---|---|---|---|---|---|
| Overall | 799 | 551 | 191 | 30 | 18 | 7 | 2 |
| Respiratory conditions | 243 | 127 | 70 | 21 | 16 | 7 | 2 |
| Trauma patients | 286 | 229 | 56 | 0 | 1 | 0 | 0 |
| Gastrointestinal conditions | 107 | 74 | 24 | 8 | 1 | 0 | 0 |
| Other patients | 101 | 73 | 27 | 1 | 0 | 0 | 0 |
| ENT conditions | 62 | 48 | 14 | 0 | 0 | 0 | 0 |
To further validate the economic efficacy of EcoRxAgent across different formulary environments, we conducted a similar cost-effectiveness analysis on the external Shenshan cohort (n = 760). As illustrated in Fig. 6, the mean cost reduction ratio reached 40.14% (Fig. 6g), with a corresponding absolute cost reduction of CNY 17.37 per prescription (baseline: CNY 43.27 vs. optimized: CNY 25.90). This performance was consistent across major drug categories (Fig. 6h), further demonstrating that the agent’s ability to identify “economic inefficiencies” remains effective even under different pricing systems and pharmacy formularies. Notably, when compared to the primary cohort, these outcomes were superior in key overall metrics, explicitly the mean reduction ratio (40.14% vs. 14.40%) and absolute cost reduction (CNY 17.37 vs. CNY 8.72). This comparative advantage was also consistently observed across specific subgroups, such as the mean reduction ratio for ENT conditions (49.47% vs. 34.07%) and the absolute cost reduction for antibiotic prescriptions (CNY 18.24 vs. CNY 11.05).
Fig. 6. Cost effectiveness evaluation for the Shenshan cohort.
a–f Cost reduction ratio (y-axis) achieved on baseline prescriptions ordered by baseline prescription total cost (x-axis). Each data point represents the best possible economically substitutable prescription for a single patient (n = 760). g–h Mean value of best possible prescription total cost vs. mean value of baseline prescription total cost, along with mean value reduction ratio and absolute cost reduction. In sub-figure g, the prescriptions are categorized by diseases while in sub-figure h, subgroups containing the four drug categories (Antibiotics, PPI, NSAID, Topicals) are listed.
Joint evaluation of therapeutic efficacy and economic impact
To comprehensively evaluate EcoRxAgent’s performance in balancing clinical and economic outcomes, in the primary Guangzhou cohort, we stratified the 799 patients into three groups based on the relationship between best possible and baseline prescription scores: Group 1 (best possible prescription score = baseline prescription score, n = 721), Group 2 (best possible prescription score > baseline prescription score, n = 45), and Group 3 (best possible prescription score < baseline prescription score, n = 33). For each group, we analyzed the distribution of cost reduction ratios using 10% intervals (≤10%, 10–20%, 20–30%, 30–40%, 40–50%, > 50%), with bar charts illustrating patient counts per interval. While Group 1 was further analyzed across five disease categories, Groups 2 and 3 were assessed only at the aggregate level due to limited sample sizes.
Analysis of Group 1 (Fig. 7a) revealed that 151 patients (20.94%) achieved cost reduction ratios exceeding 50% while maintaining clinical scores identical to baseline prescriptions. And, additional 153 patients (21.22%) attained reduction ratios between 40 and 50%, demonstrating EcoRxAgent’s capacity to deliver significant economic benefits without compromising therapeutic quality. Subgroup analyses (Fig. 7b-f) showed distinct patterns across categories: Respiratory conditions (Fig. 7b) exhibited a gradually decreasing distribution of cost reduction ratios, consistent with earlier findings, while Other patients (Fig. 7f) contained the largest number of patients with > 50% cost reductions. These results suggest EcoRxAgent’s potential to generate prescriptions with comparable effectiveness at lower cost in the evaluated clinical scenarios.
Fig. 7. Joint evaluation of therapeutic efficacy and economic impact for the Guangzhou cohort.
a–f Group 1: maintained clinical effectiveness with substantial cost reduction. g Group 2: enhanced clinical effectiveness with cost savings. h Group 3: trade-offs between cost and clinical effectiveness.
As shown in Fig. 7g, among the 45 patients in Group 2, 12 (26.67%) achieved cost reduction ratios exceeding 50% alongside improved clinical scores. This represents the most desirable outcome, i.e., “enhanced effectiveness at lower cost”, demonstrating EcoRxAgent’s potential in selected cases to simultaneously optimize both clinical and economic dimensions of care, though such instances were relatively uncommon in our dataset.
Analysis of Group 3 (Fig. 7h) indicated that more than half of the patients (18/33, 54.55%) achieved cost reduction ratios exceeding 50%, though at the expense of reduced clinical scores. These cases represent a “cost-for-effectiveness trade-off” scenario, where economic gains came with clinical compromises. This group constituted 4.13% of all analyzed cases. These findings help delineate the boundaries of EcoRxAgent’s current capabilities and highlight areas for future refinement in balancing economic and clinical priorities.
To verify the reproducibility of these trade-off patterns, we performed an identical joint evaluation on the external Shenshan cohort (n = 760) (Fig. 8). The results demonstrated a favorable shift towards comprehensive optimization. Specifically, the majority of patients (n = 519, 68.29%) fell into Group 1, maintaining clinical standards while reducing costs (Fig. 8a–f). Most notably, the proportion of patients in Group 2—achieving "enhanced effectiveness at lower cost”—increased significantly to 22.24% (n = 169), compared to the primary cohort (Fig. 8g). This replication not only supports the system’s ability to preserve clinical quality across different settings but also suggests that in certain environments, EcoRxAgent can identify opportunities to improve therapeutic outcomes and economic efficiency simultaneously.
Fig. 8. Joint evaluation of therapeutic efficacy and economic impact for the Shenshan cohort.
a–f Group 1: maintained clinical effectiveness with substantial cost reduction. g Group 2: enhanced clinical effectiveness with cost savings. h Group 3: trade-offs between cost and clinical effectiveness.
Beyond the analysis of the best possible prescriptions, we also evaluated the internal composition of the candidate sets to assess the risk of presenting inferior options alongside superior ones (a “mixed set” scenario). Such scenarios could theoretically introduce a risk where physicians are tempted to select a lower-quality option for greater cost savings. Our analysis revealed that 91 out of 799 patients (11.39%) were presented with a candidate set containing any inferior options. For the majority of patients (708 cases, 88.61%), the generated candidate sets consisted entirely of clinically non-inferior alternatives (Score ≥ Baseline). This structural consistency ensures that in most cases, physicians can focus primarily on economic optimization without navigating complex clinical trade-offs among the AI suggestions.
Illustrating example
A concrete example from the primary Guangzhou cohort is provided in Fig. 9 to illustrate the operational efficacy of EcoRxAgent in generating clinically sound and economically optimized prescriptions.
Fig. 9. Illustrating example of EcoRxAgent and senior physicians’ double-blind evaluation for a 71-year-old female patient in the Guangzhou cohort.
Compared to the baseline (CNY 22.72, score: 5.0), EcoRxAgent generated Prescriptions 1 and 2, reducing costs to CNY 15.76 (−30.63%) and CNY 17.60 (−22.54%). In blind evaluations, Prescription 1 perfectly matched the baseline score, outperforming Prescription 2 (4.67).
Discussion
EcoRxAgent represents an AI agent framework based on large language models, designed to achieve an optimal balance between therapeutic efficacy and pharmacoeconomic efficiency. Its primary advantage lies in enabling efficient cost optimization while ensuring therapeutic equivalence and safety. By integrating drug prices, dosage standards, and hospital pharmacy formularies, the agent can generate economically substitutable prescriptions with similar efficacy but superior economic profiles. This capability not only alleviates patients’ financial burden but also aligns with national objectives of promoting rational drug use and controlling healthcare expenditures. Furthermore, the framework demonstrates strong cross-system adaptability, allowing for broad application across different pricing systems and healthcare policy environments.
From the perspective of clinical effectiveness, evaluation by senior physicians revealed that approximately 95.87% and 90.53% (Guangzhou and Shenshan cohorts, respectively) of the best possible prescriptions generated by EcoRxAgent were rated as therapeutically equivalent or superior to baseline prescriptions, indicating that the economically oriented reasoning process did not compromise treatment effectiveness. These results demonstrate that the model’s optimization logic is not merely cost minimization, but rather reasonable economic optimization while maintaining therapeutic integrity, highlighting the feasibility of AI-generated prescriptions in maintaining efficacy under economic constraints.
In terms of economic performance, EcoRxAgent achieved significant prescription cost reductions. Overall, medication expenditure decreased by an average of 14.40% and 40.14% (Guangzhou and Shenshan cohorts, respectively), with consistent savings observed across multiple disease categories. In the Guangzhou cohort, the most substantial reductions were seen in ENT conditions (34.07%) and Respiratory conditions (32.98%), indicating the system’s ability to identify more cost-effective solutions in categories with higher drug substitutability. This optimization is accomplished autonomously by the model without manual parameter adjustments, demonstrating its adaptability to different hospital drug formularies and pricing systems. The consistent cost reduction ratio trend validates EcoRxAgent’s feasibility and scalability as a pharmacoeconomic decision-support framework.
Previous studies have emphasized that price differences among therapeutically similar medications often lead to inefficient and unequal healthcare spending21,22. Addressing this long-standing issue, EcoRxAgent demonstrates the capability to achieve economic optimization without compromising clinical efficacy. Joint evaluation of therapeutic efficacy and economic impact in the primary Guangzhou cohort showed that over 65% of the prescriptions with equivalent scores achieved cost reduction ratios exceeding 20%, indicating that EcoRxAgent can generate significant economic savings without affecting clinical efficacy. These results macroscopically validate the system’s potential for sustained economic optimization while maintaining treatment quality, suggesting feasibility for large-scale deployment in hospital and healthcare insurance systems. Early research has identified that irrational prescription resource allocation often stems from physicians relying on personal experience when pharmacoeconomic data is unavailable23,24. EcoRxAgent addresses this gap through a data-driven cost assessment mechanism, enabling physicians to make more economically rational medication choices while maintaining therapeutic efficacy.
Despite the system’s demonstrated performance, several limitations and challenges remain. First of all, our extended analysis of the full candidate sets revealed that for 11.39% of patients (91/799), the generated options included at least one clinically inferior alternative, and for 4.13% of patients (33/799), all generated alternatives were inferior. Given these findings, a critical limitation is that this study did not evaluate how physicians would select a final prescription when presented with such mixed options. Specifically, the risk that a physician might be inadvertently induced by substantial cost savings to select a therapeutically suboptimal regimen was not assessed. Consequently, EcoRxAgent must function strictly as a decision-support tool where clinician review serves as a safety checkpoint to prioritize clinical efficacy over cost reduction, and the impact of clinician preferences and workflow constraints on prescription selection will require future user-centered studies. In addition, safety validation in this study was retrospective and relied on an LLM-based screening component, without prospective deployment or integration with formal drug–drug interaction databases. As a result, rare but serious safety risks may not be fully captured, and future work will require prospective evaluation and incorporation of authoritative pharmacological knowledge bases. Moreover, the analytic cohort was restricted to EMR cases with complete structural data and validity as detailed in Supplementary Fig. S2. While such filtering was necessary to ensure computational feasibility and valid ground-truth comparisons, it may not fully capture the high variability and documentation noise (e.g., missing fields, ambiguous placeholders) present in raw real-world emergency practice. As highlighted by Beede et al.25, algorithmic systems validated on curated datasets can exhibit diminished performance when deployed in routine clinical environments due to such data quality shifts. Future prospective evaluations on unfiltered EMRs will therefore be essential to assess the consistency and generalizability of EcoRxAgent under operational conditions. Finally, this study did not evaluate downstream patient outcomes such as symptom resolution, re-admission rates, or adverse events. Evaluation was limited to prescription-level clinical acceptability (via physician ratings) and economic impact, and the relationship between EcoRxAgent-generated prescriptions and patient-centered outcomes remains to be established in future prospective studies. Simultaneously, the system’s coverage is limited by missing price information or pharmacologically equivalent alternatives for certain drugs, resulting in some baseline prescriptions lacking valid substitution options. These unprocessed prescriptions define the system’s practical scope and indicate the need for enhanced completeness through expanded drug formularies and external databases. Integration with regional drug price resources and external pharmacy databases could reduce such uncovered cases. By incorporating pharmacoeconomic reasoning into clinical decision-making, EcoRxAgent bridges the gap between efficacy-oriented and economy-oriented prescription models identified in previous research, promoting a more balanced and sustainable approach to rational drug use.
In conclusion, despite challenges in data completeness and dynamic price management, EcoRxAgent has established a structured prescription optimization framework that synergistically achieves both therapeutic and economic objectives. This research represents a crucial step toward intelligent, transparent, patient-centered medical decision-making and provides an extensible foundation for future artificial intelligence pharmacoeconomic research.
Methods
This study was approved by the Ethics Committee of Sun Yat-sen Memorial Hospital, Sun Yat-sen University (SYSKY-2025-982-01), which waived the requirement for written informed consent. The requirement for informed consent was waived by the committee as the research involved only the analysis of anonymized data on symptoms and treatment regimens, without utilizing any additional identifiable patient information.
Data acquisition and preprocessing
In this retrospective study, we utilized a dataset of electronic medical records (EMRs) and corresponding prescriptions from the Emergency Department of Sun Yat-sen Memorial Hospital collected between January 2022 and March 2023. To ensure the reliability and computational feasibility of the data, we applied a multi-step screening process as detailed in the data attrition diagram (Supplementary Fig. S2). Representative examples of excluded records are provided in the figure to illustrate the screening criteria. Specifically, we excluded records that were structurally deficient (e.g., containing only placeholders or missing key fields), administrative entries (e.g., follow-ups or inpatients), records containing laboratory test items (e.g., complete blood count, antigen testing), and pediatric cases (age <14). Furthermore, to ensure fair economic comparison, prescriptions containing drugs not indexed in the standardized hospital formulary were excluded. This rigorous preprocessing process yielded a final analytical cohort of 1,698 adult patient cases with complete, structurally valid data for agent evaluation. In this study, each patient case corresponds to a distinct clinical encounter associated with a single baseline prescription.
The study cohort demonstrated characteristics typical of emergency department populations, with a balanced gender distribution (841 males, 857 females) and a mean age of 37.76 years (range: 14–101 years), reflecting the broad demographic spectrum encountered in acute care settings. Trauma cases represented the largest patient subgroup (n = 601, 35.39%), predominantly comprising extremity injuries (n = 239), hand and foot injuries (n = 147), and head injuries (n = 72), consistent with the injury patterns commonly seen in emergency practice. Respiratory conditions constituted the second largest category (n = 479, 28.21%), followed by gastrointestinal disorders (n = 219, 12.90%) and ENT conditions (n = 121, 7.13%).
Notably, 799 patients (47.06%) were identified as having economically substitutable prescriptions generated by using 423 commonly used drugs in the Emergency Department. And this subgroup demonstrates similar demographic and clinical characteristics to the overall cohort. The comprehensive dataset, refined through stringent quality control measures, provides a robust foundation for investigating prescription optimization strategies in real-world emergency care settings while ensuring the clinical relevance and applicability of our findings.
To further evaluate the robustness and generalizability of EcoRxAgent, we extended our study to include an external validation cohort. This dataset was retrospectively collected from the Emergency Department of Sun Yat-sen Memorial Hospital Shenshan Center in November 2025. Following the same strict inclusion and exclusion criteria as the primary cohort, we processed a total of 1600 EMRs. From this external dataset, 760 patient cases were identified as having valid economically substitutable prescriptions and were included for independent evaluation.
EcoRxAgent pipeline
The pipeline of EcoRxAgent consists of four tools, which take as input the baseline prescription along with patient’s clinical information, hospital pharmacy database, and safety & clinical guidance, and generates economically substitutable prescriptions.
Candidate drug retrieval tool
The candidate drug retrieval tool serves as the foundational stage of the EcoRxAgent pipeline, initiating the process of identifying therapeutically equivalent yet potentially more cost-effective drug alternatives. This tool takes the drug list from the physician’s baseline prescription as its primary input and enriches this context with patient’s clinical information. This integrated data is structured into a sophisticated prompt for a large language model (LLM): 
Placeholder definitions:
[Candidate Drug List]: A list of candidate drugs, output of this tool.
[Pharmacy Inventory]: Drug list from the hospital pharmacy database, including drug names and brand names.
[Baseline Drug List]: Original prescribed medications.
[Patient's Clinical Information]: Chief complaint, present illness, past medical history, allergy history, physical examination findings, and diagnosis.
The LLM, leveraging its broad knowledge of pharmacology and clinical guidelines, processes this query to generate a preliminary candidate drug list from the hospital pharmacy database, which consists of medications that offer similar therapeutic effects while being appropriate for the patient’s unique clinical context. This step effectively broadens the scope of available options for subsequent economic and safety evaluations.
Candidate prescription generation tool
The candidate prescription generation tool constitutes the second core module of EcoRxAgent, tasked with transforming the broad list of candidate drugs into actionable, patient-tailored prescription alternatives. This tool leverages the power of a large language model (LLM) to perform the intricate task of combinatorial prescription assembly. The candidate drug list does not specify how these drugs can be logically combined to form complete and safe treatment regimens. To achieve this, the tool constructs a sophisticated prompt that presents the LLM with the candidate drug list and patient’s clinical information. A designed prompt for this step could be: 
Placeholder definitions:
[Candidate Prescription Set]: Candidate prescriptions, output of this tool.
[Patient's Clinical Information]: Chief complaint, present illness, past medical history, allergy history, physical examination findings, and diagnosis.
[Candidate Drug List]: A list of candidate drugs.
The LLM processes this instruction to synthesize the available components into a set of coherent candidate prescriptions (i.e., candidate prescription set), each representing a viable alternative to the physician’s original baseline prescription.
Safety-check tool
The safety-check tool serves as a critical safeguard in the EcoRxAgent pipeline, designed to evaluate all generated candidate prescriptions from the perspective of a senior attending physician. This tool leverages established safety considerations, integrating patient’s clinical information, to conduct a safety assessment. It operationalizes this through a specifically designed prompt for the large language model, which instructs it to: 
Placeholder definitions:
[Candidate Prescription]: Prescription to be checked.
[Patient's Clinical Information]: Chief complaint, present illness, past medical history, allergy history, physical examination findings, and diagnosis.
All prescriptions in the candidate set undergo a structured safety review. Only those satisfying all safety criteria are retained in the final safety-checked prescription set. This process filters candidates based on explicit safety assessments and detailed rationales, as visualized in Fig. 9.
Unlike systems that provide simple judgments, the safety-check tool generates a structured JSON output comprising (1) a definitive safety verdict and (2) a comprehensive clinical rationale. For example, when validating a regimen, the system explicitly cites pharmacological mechanisms (e.g., administration routes) and patient-specific factors (e.g., allergy history) to support its decision. A complete illustrative example of this structured safety evaluation is provided in Supplementary Fig. S3. This interpretability facilitates human verification and ensures adherence to clinical safety standards.
Cost-effectiveness analysis tool
The cost-effectiveness analysis tool functions as the final decision-making stage in the EcoRxAgent pipeline, where economic optimization is concretely achieved through a deterministic and transparent calculation process. This module systematically processes the safety-checked prescription set, accessing the hospital pharmacy database to retrieve precise unit prices, specifications, and dosage requirements for every medication within each prescription. It then executes a straightforward yet critical algorithm, acting as an automated calculator, to compute the total treatment cost for each safety-checked prescription by aggregating the costs of all constituent drugs based on their prescribed dosage and duration. Based on the total cost for each prescription, the tool outputs all economically substitutable prescriptions with safety-check and lower total cost than that of baseline prescription for physician review and selection. In implementation, if the number of all economically substitutable prescriptions is larger than 5, the EcoRxAgent system eventually outputs the top-5 ones with the lowest total cost.
Clinical effectiveness evaluation of the prescriptions
To validate the clinical effectiveness of EcoRxAgent, we implemented a rigorous double-blind evaluation protocol. For each baseline prescription and its corresponding set of k economically substitutable prescriptions (k≤5), a panel of six senior physicians performed independent assessments. All prescriptions, including both the original and AI-generated alternatives, were presented in randomized-order alongside complete patient clinical information. Each physician independently evaluated these k + 1 prescriptions using a five-point Likert scale (1: very poor, 2: poor, 3: average, 4: good, 5: excellent)26, scoring each prescription’s appropriateness given the patient’s clinical context. To ensure objective and consistent ratings, the participating physicians were provided with standardized instructions to evaluate each prescription using a two-stage clinical evaluation protocol.
Stage 1: Safety Check. First, physicians performed an independent safety screening to identify absolute contraindications, known allergies, or severe drug-drug interactions. This step served as a strict prerequisite; any prescription flagged as “Unsafe” was automatically rejected and excluded from further efficacy scoring.
Stage 2: Holistic Clinical Quality Scoring. For prescriptions that passed the safety check, physicians assigned a 5-point Likert score based on a holistic assessment of three key dimensions: (1) Indication Appropriateness, (2) Dosage and Regimen Rationality, and (3) Adherence to Clinical Guidelines. Note that non-critical issues, such as therapeutic duplication or redundant medications (which do not pose immediate safety threats), were retained in Stage 1 but subsequently penalized in the Stage 2 efficacy scoring to reflect their suboptimal clinical rationality. Detailed scoring criteria are provided in Supplementary Table S3.
The scores from all six physicians were then averaged to generate a single composite score for each prescription, yielding both a baseline prescription score and corresponding scores for all economically substitutable prescriptions. From these evaluated alternatives, the highest-scoring prescription was selected as the final best possible prescription, with the total cost serving as the tie-breaking criterion when multiple prescriptions achieved identical top scores, ensuring both clinical excellence and economic efficiency in the final selection.
Pharmacoeconomic evaluation of the prescriptions
To ensure fairness and comparability in cost calculations while closely reflecting clinical reality, we established a standardized pharmacoeconomic evaluation framework. All drug names were extracted from both baseline prescriptions and economically substitutable prescriptions, with corresponding entries retrieved from a standardized drug list to maintain price source consistency. Drug dosages, specifications, and administration frequencies were uniformly normalized to the common clinical standard of “single or daily usage” typically adopted by emergency department physicians. For medications available in multiple specifications or packaging forms, prices were normalized based on the unit price per daily dose to eliminate bias introduced by packaging differences. Following dosage and price alignment, total costs for baseline and substitutable prescriptions were calculated under this unified metric to enable economic comparison. A prescription was considered economically advantageous if its total cost was lower than the baseline while maintaining equivalent pharmacological action, indications, and safety profiles. A key metric derived from this process was the cost reduction ratio, defined as
| 1 |
This computational framework ensures scientific rigor, reproducibility, and clinical interpretability, providing a reliable foundation for the cost-effectiveness analysis conducted in this study.
Implementation detail
All experiments were conducted under Linux (Ubuntu 22.04) using Python 3.13.7. Core dependencies included PyTorch 2.8.0, LangChain 0.3.27, LangChain-Core 0.3.76, and Pandas 2.3.3. Model inference and generation were performed via the Alibaba Cloud Model Studio using the Qwen3-Max (2025-09-23) version. All large language model computations were executed on cloud-hosted resources, while local tasks—including data preprocessing, workflow orchestration, and result evaluation—were carried out on CPU servers. This hybrid architecture ensured both computational efficiency and reproducibility within a controlled software environment.
EcoRxAgent is built upon a single foundational Large Language Model (Qwen3-Max) orchestrated through a sequential agentic workflow. Instead of fine-tuning separate models for each task, we employ task-specific prompt engineering to guide the base model. This approach leverages the broad medical knowledge and reasoning capabilities of the SOTA foundation model while ensuring process control through modular design.
Supplementary information
Acknowledgements
This work was supported in part by the National Key Research and Development Program of China under Grant No. 2024YFA1011900 and Science and Technology Program of Guangzhou, China No. 2024A03J1188.
Author contributions
C.L.: study conceptualization and design, construction of model, technical implementation, code implementation, statistical analysis, manuscript drafting; P.L.: study conceptualization and design, construction of model, technical implementation, data analysis, statistical analysis, manuscript drafting; N.Z.: study conceptualization and design, prescription scoring, data analysis; Cai W.: prescription scoring, data analysis; H.C.: construction of model, code implementation, statistical analysis; G.Z., H.W., Gq.Z., Tq.Y.: prescription scoring, data analysis; Lian L., X.Y.: data preparation, resources; L.Li.: investigation, data analysis; J.L.: study conceptualization and design, resources; C.W.: study conceptualization and design, construction of model, manuscript drafting, data analysis, statistical analysis, resources; T.Y.: study conceptualization and design, data preparation, manuscript drafting, resources. All authors reviewed the manuscript.
Data availability
The clinical datasets from the Guangzhou and Shenshan cohorts used to train and validate EcoRxAgent are not publicly available due to their potentially identifiable nature. De-identified data are available from the corresponding author on reasonable request.
Code availability
The custom code is made publicly available at https://github.com/AllminerLab/EcoRxAgent. This repository includes the source code for the EcoRxAgent system.
Competing interests
The authors declare no competing interests.
Footnotes
Publisher’s note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
These authors contributed equally: Cheng Li, Peiyuan Lai, Na Zhang.
Contributor Information
Changdong Wang, Email: wangchd3@mail.sysu.edu.cn.
Tao Yu, Email: yut@mail.sysu.edu.cn.
Supplementary information
The online version contains supplementary material available at 10.1038/s41746-026-02612-7.
References
- 1.Innes, G. K., Ogden, C. L., Crentsil, V., Concato, J. & Fakhouri, T. H. Prescription medication use among older adults in the US. JAMA Intern. Med.184, 1121–1123 (2024). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 2.Zou, H. et al. Economic burden and quality of life of hepatocellular carcinoma in greater China: a systematic review. Front. Public Health10, 801981 (2022). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 3.Hu, Y. et al. Long-term clinical and economic effects of switching to once-weekly semaglutide from other GLP-1 RAs among patients with type 2 diabetes in China: a modeling projection study. Adv. Ther.42, 904–917 (2025). [DOI] [PubMed] [Google Scholar]
- 4.Tversky, A. & Kahneman, D. Judgment under uncertainty: Heuristics and biases: Biases in judgments reveal some heuristics of thinking under uncertainty. Science185, 1124–1131 (1974). [DOI] [PubMed] [Google Scholar]
- 5.Glasziou, P. et al. Evidence for underuse of effective medical services around the world. Lancet390, 169–177 (2017). [DOI] [PubMed] [Google Scholar]
- 6.Rohde, L. E., Bertoldi, E. G., Goldraich, L. & Polanczyk, C. A. Cost-effectiveness of heart failure therapies. Nat. Rev. Cardiol.10, 338–354 (2013). [DOI] [PubMed] [Google Scholar]
- 7.Hu, Y. et al. Long-and short-term cost-effectiveness of once-weekly Semaglutide versus Dulaglutide for the treatment of type 2 diabetes in China: A hypothetical modeling exercise. Diab. Ther.16, 915–929 (2025). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 8.Boiko, D. A., MacKnight, R., Kline, B. & Gomes, G. Autonomous chemical research with large language models. Nature624, 570–578 (2023). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 9.M. Bran, A. et al. Augmenting large language models with chemistry tools. Nat. Mach. Intell.6, 525–535 (2024). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 10.Montoya, J. H. et al. Autonomous intelligent agents for accelerated materials discovery. Chem. Sci.11, 8517–8532 (2020). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 11.Bazgir, A., Chandra Praneeth Madugula, R. & Zhang, Y. MatAgent: a human-in-the-loop multi-agent LLM framework for accelerating the material science discovery cycle. In AI for Accelerated Materials Design - ICLR 2025 (2025).
- 12.de Almeida, B. P. et al. A multimodal conversational agent for DNA, RNA and protein tasks. Nat. Mach. Intell.7, 928–941 (2025). [Google Scholar]
- 13.Wang, Z. et al. GeneAgent: Self-verification language agent for gene-set analysis using domain databases. Nat. Methods22, 1677–1685 (2025). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 14.Ding, K. et al. SciToolAgent: a knowledge-graph-driven scientific agent for multitool integration. Nat. Comput. Sci. 1–11 (2025). [DOI] [PubMed]
- 15.Ferber, D. et al. Development and validation of an autonomous artificial intelligence agent for clinical decision-making in oncology. Nat. Cancer6, 1337–1349 (2025). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 16.Swanson, K., Wu, W., Bulaong, N. L., Pak, J. E. & Zou, J. The Virtual Lab of AI agents designs new SARS-CoV-2 nanobodies. Nature 1–8 (2025). [DOI] [PubMed]
- 17.Tu, T. et al. Towards conversational diagnostic artificial intelligence. Nature642, 442–450 (2025). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 18.Wu, K. et al. An automated framework for assessing how well LLMs cite relevant medical references. Nat. Commun.16, 3615 (2025). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 19.Higgins, K. et al. The Helicobacter pylori AI-clinician harnesses artificial intelligence to personalise h. pylori treatment recommendations. Nat. Commun.16, 6472 (2025). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 20.Rayo, M. F. et al. Comparing the effectiveness of alerts and dynamically annotated visualizations (DAVS) in improving clinical decision making. Hum. factors57, 1002–1014 (2015). [DOI] [PubMed] [Google Scholar]
- 21.Vanholder, R. et al. Inequities in kidney health and kidney care. Nat. Rev. Nephrol.19, 694–708 (2023). [DOI] [PubMed] [Google Scholar]
- 22.Owens, C. E. et al. The economic costs of precision medicine for clinical translational research among children with high-risk cancer. NPJ Precis. Oncol.8, 224 (2024). [DOI] [PMC free article] [PubMed] [Google Scholar]
- 23.Neumann, P. J., Cohen, J. T. & Ollendorf, D. A.The right price: A value-based prescription for drug costs (Oxford University Press, Oxford, UK, 2021).
- 24.Wang, Y. et al. Cost-effectiveness of community-based integrated care model for patients with diabetes and depressive symptoms. Nat. Commun. 16 2986 (2025). [DOI] [PMC free article] [PubMed]
- 25.Beede, E. et al. A human-centered evaluation of a deep learning system deployed in clinics for the detection of diabetic retinopathy. In Proceedings of the 2020 CHI conference on human factors in computing systems, 1–12 (2020).
- 26.Hong, E. K. et al. Value of using a generative AI model in chest radiography reporting: a reader study. Radiology314, e241646 (2025). [DOI] [PubMed] [Google Scholar]
Associated Data
This section collects any data citations, data availability statements, or supplementary materials included in this article.
Supplementary Materials
Data Availability Statement
The clinical datasets from the Guangzhou and Shenshan cohorts used to train and validate EcoRxAgent are not publicly available due to their potentially identifiable nature. De-identified data are available from the corresponding author on reasonable request.
The custom code is made publicly available at https://github.com/AllminerLab/EcoRxAgent. This repository includes the source code for the EcoRxAgent system.









