Virtual trials use routinely collected clinical data to evaluate treatment strategies, yet turning a study protocol into an executable analysis requires mapping clinical concepts and study requirements onto the available data and keeping those mappings consistent throughout the workflow. These choices depend on local data models and operational conventions, involving source selection, patient and encounter identity, linkage, and temporal interpretation.
We introduce VirtualTrialHarness (VTHarness), an agent‑based framework that automatically selects reusable procedural skills for each workflow stage and enforces explicit contracts to preserve uniform study decisions across stages. Alongside we provide VTBenchmark for assessing source selection and cohort construction quality.
Across three complex synthetic environments, VTHarness, after requirement clarification, produced all required cohort outputs matching the references in 95.1% of workflows, compared with 60.4% when retrieving from the same procedural corpus alone. Procedural skills boosted source recovery for three language models and increased overlap with analyst code in 13 Mayo Clinic cases. Site‑specific adaptation enabled reference‑matched cohort execution for eight MIMIC‑IV tasks.
Within the Mayo Clinic Virtual Trials Program, the framework supported investigator review of cohort construction and endpoint analysis, demonstrating that coupling procedural guidance with workflow decisions improves virtual‑trial implementation across intricate clinical schemas.
Review: The system’s agent‑driven skill selection and contract mechanism deliver efficient, consistent virtual trial operations, offering a practical pathway for deployment in real‑world clinical data settings.