arXiv:2611.05551cs.AINov 2026

Manuscript Offprint

arXiv:2611.05551

VirtualTrialHarness: Coordinating Agentic Operationalization of Virtual Trial Protocols Across Complex Clinical Schemas

Pengze Li, Jingna Feng, Yue Yu, Yining Wu, Xinyue Hu, Jie Lin, Avanti Bhandarkar, Cui Tao

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Virtual trials use routinely collected clinical data to evaluate treatment strategies, but translating a study protocol into an executable analysis requires determining how clinical concepts and study requirements should be represented in the available data and applied consistently across the workflow. These decisions depend on local data representations and operational conventions and can involve source selection, patient and encounter identity, linkage, and temporal interpretation. Here we introduce VirtualTrialHarness (VTHarness), an agent framework that coordinates virtual-trial operationalization by selecting reusable procedural skills for each workflow stage and uses explicit contracts to maintain consistent study decisions across stages. We also introduce VTBenchmark for evaluating source selection and cohort construction. Across three complex synthetic environments, VTHarness successfully produced all required cohort outputs matching the references in 95.1% of workflows after requirement clarification, compared with 60.4% using retrieval from the same procedural corpus. Procedural skills improved source recovery across three language models and increased source overlap with analyst code in 13 Mayo Clinic cases. Site-specific adaptation enabled reference-matched cohort execution across eight MIMIC-IV tasks. Within the Mayo Clinic Virtual Trials Program, the framework supported investigator review of cohort construction and endpoint analysis. These findings support coordinating procedural guidance with workflow decisions to improve virtual-trial implementation across complex clinical schemas.

1 Introduction

Randomized controlled trials (RCTs) are the benchmark for evaluating clinical interventions, but recruiting and following participants can be costly or infeasible ¹. Clinical data recorded in hospital electronic health records (EHRs) can complement RCTs with evidence on effectiveness, safety, and treatment-effect heterogeneity ². We use virtual trial (VT) to denote a protocol-defined treatment comparison implemented using routinely collected EHR data. Target-trial emulation specifies the protocol of a hypothetical randomized trial—including eligibility criteria, treatment strategies, time zero, follow-up, outcomes and estimand—and implements it using observational records ³. Transparent reporting also requires specifying how the target-trial protocol is mapped to the observational data used for its emulation ⁴. Our focus is the operational translation of a supplied protocol into linked cohort and analysis workflows.

Implementing a VT protocol requires mapping clinical requirements to site-specific data structures, vocabularies and operational conventions ⁵,⁶. Common data models such as OMOP standardize data structures and clinical concepts, substantially reducing heterogeneity ⁷,⁸. However, standardization does not guarantee that every study-relevant source or clinical detail has been mapped, nor does it eliminate local differences in linkage, data coverage, and event interpretation ⁹,¹⁰. Implementation may therefore require working across standardized, partially harmonized, and native hospital data. Even when relevant records conform to a common model, their completeness and suitability for the intended analysis still require assessment 11{}^{11}.

Operationalizing virtual trials in health-system data environments can be substantially more complex than working with curated research datasets. Research datasets such as MIMIC-IV undergo preparation that consolidates and reorganizes source tables to facilitate retrospective analysis 12{}^{12}. In institutional environments, by contrast, clinically related information may be distributed across operational, terminology, and specialty data sources, with multiple representations of patients, encounters, clinical events, and event times. In our work with physician-submitted VT requests at Mayo Clinic, for example, the institutional data dictionary covered more than 150 tables and 2,000 documented fields in its base EHR component alone, with additional specialty datasets (Supplementary Section S1). Although an individual study may use only a small subset of this catalog, identifying that subset and determining how its records should be linked and interpreted requires knowledge of local data practices. Enterprise text-to-SQL benchmarks such as Spider 2.0 similarly emphasize metadata search and multi-step execution across complex database environments 13{}^{13}.

These challenges make VT operationalization more than a criteria-to-SQL task. Electronic phenotyping and criterion-to-query systems address important parts of the problem, including concept extraction, temporal interpretation, and executable cohort definition 14−16{}^{14-16}. Formal representations such as Temporal Ensemble Logic additionally capture temporal dependencies across trial components 17{}^{17}. Yet identifying candidate fields is different from determining how they should be used at a particular hospital. Schema metadata describes available fields and relationships, but does not by itself establish which source, linkage path or event clock satisfies a particular protocol. For example, implementing a treatment-initiation rule may require distinguishing prescription orders from administrations, following a locally validated patient-linkage path, and selecting an event time that consistently anchors eligibility and follow-up. A query can execute successfully while using the wrong treatment source or temporal anchor. Resolving these choices often depends on knowledge accumulated through prior analyst implementations and local operational documentation 10{}^{10}. VT operationalization therefore requires local procedural knowledge to guide individual queries and remain consistent across the workflow.

Agents built on large language models (LLMs) offer a way to combine protocol interpretation, access to local resources, and iterative execution 18−20{}^{18-20}. Recent systems support study-to-code translation, multi-stage EHR analysis, and reuse of prior analytic experience 21−23{}^{21-23}. Clinical retrieval-augmented generation studies also show that corpus organization and retrieval configuration influence performance on medical knowledge tasks 24,25{}^{24,25}. However, access to procedural documentation alone does not determine which procedure applies, when it is needed or how an accepted decision should constrain later stages. These responsibilities fall to the agent harness, the software layer that manages an LLM's context, tools, workflow state and checks 26−29{}^{26-29}. A central question is whether coordinating the selection and exposure of local procedures with the current workflow stage improves protocol execution beyond query-driven retrieval of the same procedural corpus.

We introduce VirtualTrialHarness (VTHarness), an agent harness with a role-based multi-agent architecture for VT operationalization. Specialized roles cover protocol interpretation, source grounding, cohort-base construction, eligibility assessment and endpoint analysis. In the evaluated implementation, a single language-model agent enacted these roles sequentially. Reusable skills express recurring source, identity and event-time rules separately from study-specific clinical definitions. Progressive selection and exposure use the current requirement, workflow stage and acquired schema information to choose applicable skills and supply their operation-specific guidance. Explicit contracts specify how each role should use accepted study decisions and which outputs and checks it must provide. Schema tools and execution feedback support implementation, while human review allows study outputs to be inspected and revised. Within the Mayo Clinic Virtual Trials Program, physicians and analysts reviewed how VTHarness interpreted and implemented study requirements.

Existing benchmarks assess clinical text-to-SQL question answering, as in EHRSQL, and interactive patient-level EHR tasks, as in MedAgentBench 30,31{}^{30,31}. Evaluating VT operationalization additionally requires assessing whether agents select appropriate data sources and preserve protocol requirements across interdependent executable outputs. We therefore also introduce VTBenchmark, a dedicated benchmark for VT operationalization. Its execution environments abstract challenges encountered in institutional VT implementation: selecting among clinically related sources, resolving patient and encounter identities, interpreting event times and navigating a broad catalog. Its complex-schema component comprises 24 base protocol tasks, each represented in four synthetic database environments that capture these challenges. Its source-grounding component comprises 90 study tasks derived from target-trial emulation publications and Mayo Clinic intake materials and assesses recovery of the data sources needed to implement study requirements. Together, these components assess source grounding and executable workflow delivery.

Using VTBenchmark, we test whether the way procedural knowledge is selected and supplied changes implementation outcomes. In the three complex-schema environments, progressive skill selection and exposure achieved 95.1% complete delivery of the five required cohort products after clarification of a study requirement, compared with 60.4% for query-driven retrieval of the same procedural corpus within the same harness. Additional evaluations examined skill use across model backbones and Mayo Clinic cases, and site adaptation in MIMIC-IV. Together, the framework and benchmark assess how procedural guidance supports correct cohort construction and consistent summaries.