Editor’s introduction
The study evaluates SurroPilot, an AI platform designed to assist in assessing surrogate endpoints in clinical trials by enabling natural-language interaction throughout the analytical workflow. It supports tasks such as data understanding, variable selection, and subgroup-specific mediation analysis, using a framework that identifies patient subgroups with differing surrogate validity. The platform integrates a human-in-the-loop design where LLM-generated outputs are validated through iterative code inspection, ensuring statistical rigor is maintained. Findings from the ACTG175 HIV trial demonstrate that SurroPilot delivers a reproducible, end-to-end workflow for heterogeneous surrogate evaluation without replacing established causal inference methods. The study does not assess broader clinical outcomes or generalizability beyond the specific trial context, limiting its scope to the application of heterogeneous mediation analysis in one clinical setting.
Introduction
Evaluating the clinical benefit of a new therapeutic intervention, defined by improvements in survival, symptoms, or functional outcomes, often requires prolonged follow-up, particularly in chronic or life-threatening diseases. To address the inherent delays associated with measuring such endpoints, the U.S. Food and Drug Administration (FDA) established the Accelerated Approval pathway in 1992. This regulatory mechanism permits approval of drugs for serious conditions with unmet medical needs on the basis of surrogate or intermediate clinical endpoints, thereby expediting patient access to potentially effective therapies. A surrogate endpoint is a biomarker, such as a laboratory measurement, radiographic finding, or physical sign, that is intended to predict clinical benefit but does not itself directly measure it. An intermediate clinical endpoint similarly reflects a therapeutic effect that is reasonably likely to forecast ultimate clinical benefit, for example through its influence on irreversible morbidity or mortality. By substituting such endpoints for definitive outcomes, the accelerated approval framework can substantially shorten the drug development timeline. In oncology, for instance, regulatory approval may be granted based on tumor response rather than overall survival (OS), under the assumption that tumor shrinkage is reasonably likely to predict meaningful clinical benefit.
Despite the widespread use of surrogate endpoints in drug development, existing evaluation frameworks generally treat surrogate validity as a homogeneous, population-level property. This assumption is rarely examined and may not hold in the presence of substantial biological and clinical heterogeneity across patients. Consequently, a surrogate biomarker that reliably predicts clinical benefit for one subgroup may perform poorly for another, limiting the generalizability of population-level validation. This limitation has important regulatory implications because accelerated approval based on surrogate endpoints requires subsequent confirmatory trials to verify that improvements in the surrogate translate into meaningful clinical benefit, such as OS. However, an increasing number of confirmatory studies have failed to demonstrate the anticipated clinical benefit. To date, FDA has withdrawn accelerated approval for 31 oncology drugs, including 25 since 2020, as well as nine additional drugs in non-oncology indications. In response, between 2023 and 2025 the FDA issued a series of draft guidances strengthening the evidentiary requirements for accelerated approvals based on surrogate endpoints, including the expectation that confirmatory trials be underway at the time of approval. These developments underscore the need to move beyond population-level assessments and evaluate surrogate validity at the patient subgroup level.
Causal mediation analysis has emerged as a principled statistical framework for evaluating surrogate biomarkers by quantifying the extent to which treatment effects are transmitted through intermediate endpoints. Unlike traditional correlation-based approaches, causal mediation analysis enables a mechanistic assessment of surrogate validity by decomposing treatment effects into direct and indirect components under explicit causal assumptions. Building upon this framework, recent methodological advances have extended mediation analysis to account for patient heterogeneity. In particular, proposed a heterogeneous survival mediation framework that identifies clinically interpretable patient subgroups with differential surrogate validity, allowing surrogate biomarkers to be evaluated at the subgroup level rather than assuming a single population-wide relationship. These developments provide a more nuanced and clinically meaningful framework for surrogate endpoint evaluation. Collectively, these advances provide a more flexible and clinically meaningful framework for surrogate endpoint evaluation and have the potential to improve precision medicine by identifying patient populations that benefit through distinct biological pathways.
Despite these methodological advances, applying heterogeneous causal mediation analysis in clinical trials remains challenging in practice. A rigorous analysis requires a sequence of complex statistical decisions, including identifying biologically plausible surrogate biomarkers, selecting appropriate covariates, specifying causal models that satisfy underlying identification assumptions, and determining clinically meaningful patient subgroups. In addition, researchers must perform extensive data preprocessing, implement specialized statistical methods, assess model diagnostics, and interpret often complex subgroup-specific mediation results. These tasks demand substantial expertise in causal inference, biostatistics, and clinical trial methodology, creating a steep learning curve for investigators without specialized training. Consequently, advanced surrogate evaluation remains largely inaccessible to many biomedical and clinical researchers, limiting the broader adoption of heterogeneous mediation methodologies in practice.
Recent advances in artificial intelligence (AI), particularly LLMs, offer a promising opportunity to lower the technical barriers associated with advanced statistical analyses by enabling natural-language interaction with complex analytical workflows. Regulatory agencies, including the FDA, have increasingly recognized the potential of AI and machine learning to support clinical trial design, conduct, data management, endpoint assessment, and clinical trial analytics. Existing AI-assisted applications have demonstrated considerable value in improving research efficiency through tasks such as protocol development, patient recruitment, eligibility screening, data extraction, and automated documentation. However, these systems have largely focused on operational and administrative workflows, while the use of AI to support statistical inference, causal reasoning, and interpretable clinical trial analyses remains limited. As a result, AI has yet to realize its full potential in enabling rigorous and accessible statistical analyses for modern clinical research.
To address these challenges, we propose SurroPilot, an AI-assisted statistical framework for heterogeneous surrogate endpoint evaluation that integrates LLMs with validated causal mediation methodology. Rather than replacing statistical methodology or human expertise, SurroPilot adopts a human-in-the-loop paradigm in which LLMs facilitate data understanding, variable selection, statistical computation, and interpretation, while all causal inference is performed using validated statistical procedures. The main contributions of this work are summarized as follows. First, we present, to the best of our knowledge, the first AI-assisted framework for heterogeneous surrogate endpoint evaluation in clinical trials. By combining natural-language interaction with heterogeneous causal mediation analysis, SurroPilot substantially lowers the technical barrier to applying advanced causal inference methods while preserving statistical rigor and reproducibility. Second, we develop an LLM-assisted statistical workflow that automates the major analytical components of heterogeneous mediation analysis, including data understanding, preprocessing, mediator and covariate selection, heterogeneous subgroup identification, result interpretation, and report generation. This unified workflow enables reproducible end-to-end analyses from natural-language instructions rather than manually written statistical code. Third, we introduce a shared-context programmer–inspector self-correction mechanism that iteratively refines LLM-generated R code and validates variable selections through execution feedback. By maintaining a shared conversational context throughout the analytical process, the proposed framework improves the reliability and robustness of AI-assisted statistical computing. Finally, we evaluate SurroPilot using the ACTG175 Phase III clinical trial and demonstrate that state-of-the-art LLMs can reliably recover expert-defined mediators and adjustment covariates and reproduce heterogeneous subgroup analyses consistent with expert-guided analyses. These results demonstrate the feasibility of integrating large language models with modern causal inference methodology for practical clinical trial analysis.
AI-assisted Clinical Trial Analytics
Recent advances in AI, particularly LLMs, have created new opportunities to support clinical trial design, conduct, and analysis. Regulatory agencies have increasingly recognized the potential of AI to facilitate disease characterization, identify clinically meaningful patient subgroups, improve endpoint assessment, and enhance clinical trial analytics. Recent FDA guidance further emphasizes that AI-generated evidence can contribute to regulatory decision-making when accompanied by appropriate credibility assessment and human oversight.
The emergence of LLMs has substantially expanded the capabilities of AI-assisted systems beyond traditional task automation. Through their abilities in natural-language understanding, knowledge retrieval, reasoning, and code generation, LLM-powered agents are increasingly capable of interacting with complex analytical workflows and assisting users in solving domain-specific problems. Consequently, LLM-based assistants have been successfully applied in diverse areas, including software engineering, scientific discovery, healthcare, and biomedical research.
Within clinical research, existing AI-assisted systems have primarily focused on operational and administrative tasks, such as protocol development, patient recruitment, eligibility screening, clinical documentation, literature synthesis, and clinical decision support. These applications have demonstrated the potential of LLMs to improve research efficiency and reduce the burden associated with increasingly complex clinical studies. However, the application of LLMs to statistical inference and causal analysis remains largely unexplored. In particular, no existing AI-assisted framework is specifically designed to support heterogeneous causal mediation analysis and surrogate endpoint evaluation, despite the substantial methodological complexity and practical importance of these analyses in modern clinical trials.
AI Data Understanding & Preparation
Following the user input stage, SurroPilot performs AI-assisted data understanding and preparation. Based on the user-provided dataset description and the extracted dataset metadata, the LLM first interprets the dataset structure and identifies the preprocessing operations required for downstream analysis. Typical operations include filtering observations according to user-defined criteria, handling missing values, recoding variables, transforming data types, and constructing derived variables when appropriate.
After identifying the required preprocessing operations, the LLM assumes the role of a programmer and generates executable R code to implement the requested data preparation tasks. The generated code is executed automatically within the R environment, enabling an end-to-end data preparation workflow without requiring manual programming. Because LLM-generated code may occasionally contain syntactic or logical errors, SurroPilot incorporates an iterative self-correction mechanism to improve execution reliability and robustness.
Specifically, if code execution fails, the LLM switches from the programmer role to an inspector role. The inspector analyzes both the generated R code and the corresponding execution error messages to identify the underlying causes of failure and produces targeted revision suggestions. These suggestions are then provided to the programmer, which regenerates corrected code for re-execution. This programmer–inspector cycle is repeated until the code executes successfully or a predefined maximum number of iterations is reached.
Results and Interpretation
To facilitate clinical interpretation, the proposed framework automatically generates a collection of visualization and reporting outputs following the heterogeneous causal mediation analysis. First, an interpretable subgroup profile is produced based on the fitted decision tree, providing explicit decision rules that characterize each identified subgroup using clinically relevant covariates. This representation enables users to understand the defining characteristics of patient subpopulations exhibiting distinct mediation patterns.
To further summarize the estimated heterogeneous mediation effects, boxplots of the estimated NIECC are generated for each identified subgroup. These visualizations illustrate the distribution of individual-level mediation effects within and across subgroups, allowing users to assess both the magnitude and variability of the indirect treatment effect. Together, the subgroup profiles and NIECC visualizations provide complementary perspectives for interpreting heterogeneous mediation patterns.
To facilitate result dissemination and improve analysis reproducibility, SurroPilot automatically generates a comprehensive analysis report upon completion of the heterogeneous causal mediation analysis. The report is organized into four sections: Background, Methods, Results, and Interpretation, providing users with a standardized and reproducible summary of the entire analytical workflow.
The Background section introduces the principles of causal mediation analysis and treatment effect heterogeneity, summarizes the clinical motivation for the analysis, and provides an overview of the uploaded dataset, including variable descriptions and descriptive statistics. This section establishes the analytical context and documents the data used throughout the study.
The Methods section summarizes all user-specified analysis settings, including the treatment and outcome variables, selected mediator, adjustment covariates, and additional domain-specific information provided by the user. It also presents the causal mediation diagram, documents the rationale for selecting the mediator and covariates generated by the LLM, and briefly describes the underlying heterogeneous causal mediation framework.
The Results section reports the identified patient subgroups together with their corresponding decision-tree profiles, subgroup-specific summary statistics, and the estimated NIECC distributions. Figures are automatically generated to visualize the subgroup structure and quantify heterogeneous mediation effects. When no statistically credible heterogeneity is detected through the calibration procedure, the report explicitly states this finding rather than presenting potentially spurious subgroup results.
Comparison of LLMs for Mediator and Covariate Selection
To evaluate the reliability of SurroPilot in identifying mediators and covariates, we compared the variable selections produced by different LLMs with a reference set defined by human experts based on prior clinical knowledge and published literature. Selection performance was evaluated using Precision, Recall, F1 score, and Jaccard similarity. Since many clinical datasets cannot be uploaded to cloud-based services due to privacy regulations, we compared both open-source offline models (Llama-3 and Qwen2.5-14B) and commercial cloud-based models (GPT-5.4-nano and GPT-5.4).
The expert-defined mediator was CD4 count at 20 weeks. The reference covariates set consisted of CD4 baseline, age, weight, hemophilia, homosexual status, Karnofsky score, pre-antiretroviral treatment, race, gender, and symptomatic status. To ensure a fair comparison, all LLMs received the same dataset description, metadata, and task instructions. The complete input prompt is provided in Appendix B.
For covariate selection, GPT-5.4-nano and GPT-5.4 achieved substantially higher recall (0.91 and 0.88, respectively) than the open-source models, indicating that they successfully recovered nearly all expert-selected covariates. Although their precision was moderate (approximately 0.58), suggesting that additional clinically plausible variables were occasionally included, both GPT models achieved the highest overall F1 scores and Jaccard similarities, demonstrating the closest agreement with human experts.
Overall, these results demonstrate that modern LLMs can effectively translate domain knowledge into statistically appropriate variable selections. While commercial models provide the highest accuracy, open-source models offer a practical offline alternative for privacy-sensitive clinical environments where cloud-based services are not permitted.
Discussion
SurroPilot extends the role of large language models in clinical trials from operational assistance to AI-assisted statistical inference. By integrating natural-language interaction with validated heterogeneous causal mediation methodology, the proposed framework enables end-to-end surrogate endpoint evaluation while preserving statistical rigor through a human-in-the-loop design. Rather than replacing statistical methodology or domain expertise, SurroPilot combines LLM-assisted reasoning with validated causal inference procedures to improve the accessibility, reproducibility, and efficiency of heterogeneous surrogate biomarker analysis. Experimental results from the ACTG175 Phase III clinical trial further demonstrate that modern LLMs can reliably assist with clinically relevant analytical tasks, supporting the feasibility of integrating foundation models into advanced statistical workflows.
A key contribution of this work is the integration of AI-assisted statistical computing with heterogeneous causal mediation analysis. Existing LLM-assisted applications in clinical trials have primarily focused on operational tasks, such as protocol development, patient recruitment, data extraction, and clinical documentation, whereas statistical inference has remained largely beyond the scope of AI-assisted systems. SurroPilot demonstrates that LLMs can effectively assist with data understanding, preprocessing, mediator and covariate selection, statistical workflow configuration, and result interpretation, while the underlying causal estimation is performed using validated statistical methodology. This collaborative paradigm substantially lowers the technical barriers to heterogeneous mediation analysis without compromising methodological transparency, reproducibility, or expert oversight.
Beyond improving analytical efficiency, SurroPilot enables subgroup-specific surrogate endpoint evaluation, which has important implications for precision medicine and clinical trial design. Conventional surrogate validation relies primarily on population-average measures and implicitly assumes homogeneous surrogate validity across patients. However, biological mechanisms, treatment responses, and disease progression frequently vary across clinically meaningful patient subgroups. By integrating heterogeneous mediation analysis with interpretable subgroup identification, SurroPilot enables investigators to identify patient populations in which a surrogate biomarker provides stronger or weaker evidence for long-term clinical benefit. Rather than asking whether a biomarker is a valid surrogate on average, the proposed framework addresses a clinically more informative question: for whom is the surrogate valid? Such subgroup-specific evaluation has the potential to improve patient stratification, biomarker-driven clinical trial design, regulatory decision-making, and precision medicine.
Another important finding is that state-of-the-art LLMs achieved high agreement with expert-defined mediator and covariate selections. These results suggest that LLMs are capable of translating domain knowledge expressed in natural language into statistically appropriate analytical decisions. Importantly, SurroPilot does not rely on autonomous decision-making. Instead, all recommendations remain transparent, explainable, and subject to user confirmation before downstream analyses are performed. This human–AI collaborative paradigm provides a practical approach for integrating foundation models into rigorous statistical workflows while maintaining scientific accountability.
Several limitations should be acknowledged. First, the current implementation is primarily designed for randomized Phase III clinical trials and therefore has not been extensively evaluated in observational studies or other clinical research settings. Second, although the proposed programmer–inspector framework substantially improves the reliability of AI-generated code and variable selection, LLMs may still occasionally generate inaccurate recommendations or unsupported analyses, making human verification essential throughout the analytical process. Third, the current framework focuses on structured clinical datasets and has not yet incorporated multimodal information, such as medical imaging, genomics, electronic health records, or external biomedical knowledge bases. Finally, the statistical workflow currently centers on heterogeneous causal mediation analysis, and further investigation is needed to determine whether similar AI-assisted statistical computing paradigms can be generalized to other classes of causal inference and statistical learning methods.
Future work will focus on extending both the statistical methodology and the AI capabilities of SurroPilot. From a methodological perspective, incorporating Bayesian mediation models, historical borrowing methods, adaptive clinical trial designs, and real-world evidence may further improve the precision and efficiency of heterogeneous surrogate evaluation, particularly for rare patient subgroups. From an AI perspective, integrating more advanced reasoning models, domain-specific biomedical foundation models, and multimodal LLMs may further enhance the robustness, reliability, and interpretability of AI-assisted statistical computing. Continued improvements in user interaction, visualization, and report generation will further facilitate the adoption of advanced statistical methodologies by clinicians and biomedical researchers.


