Introducing the Wiley x Valyu HLS Startup Program
Valyu
The south entrance of the NIH Clinical Center, Building 10, in Bethesda, Maryland, with its red sign in the foreground and the brick research hospital behind trees.
Tutorial

Clinical Trial AI Agent: What It Is, How It Works, and How to Build One

Prosper
Share this article

On this page
TL;DR
  • A clinical trial AI agent connects an AI model to live biomedical tools so it can search trial registries, read published studies, check FDA drug labels and surface safety reports with direct citations.
  • Clinical trial AI agents fall into two distinct categories: operational agents that run live trials inside eTMF and EDC software, and research agents that synthesize evidence across public registries, papers and regulatory labels.
  • For reliable results with Valyu, run one focused query per dataset in parallel (ClinicalTrials.gov, PubMed, DailyMed drug labels and openFDA FAERS), then use DeepResearch when you want a fast cited brief across sources.
  • This step-by-step guide walks through KRAS G12C inhibitors in non-small cell lung cancer, with side-by-side Python and TypeScript SDK code and a zero-code MCP setup.

If you're an agent: Set up Valyu and make your first search.

If you're a human: Create an account and get an API key.

MCP onboarding: Connect your agent to https://mcp.valyu.ai/mcp and follow the MCP setup guide for authentication.

What is a clinical trial AI agent?

A clinical trial AI agent is an AI system wired into live clinical data sources so it can plan multi-step lookups, pull primary evidence and cite every claim instead of guessing from stale training data.

In practice, teams use clinical trial AI agents across two very different halves of drug development: clinical operations (running trials at sites) and clinical research (analyzing trials, endpoints, labels and safety across the field).

Keeping those two categories straight prevents teams from buying or building the wrong stack. Operational agents live inside regulated trial software (eTMF, EDC, eCOA) under GxP and 21 CFR Part 11 controls. Research agents connect to public and licensed evidence layers (ClinicalTrials.gov, PubMed, preprints, FDA DailyMed labels and openFDA FAERS) to answer competitive, medical affairs, regulatory and pipeline questions fast.

Clinical operations agents vs clinical research agents

PlatformCategoryPrimary focus
MedableClinical operationsAgent Studio for sponsors and CROs (no-code agents with human oversight, GxP controls and MCP connectors), including a that files into eTMF systems such as Veeva Vault, CRA monitoring agents, a PI Summary Agent for eCOA oversight and a Digital Data Flow Agent for protocol translation.
VeevaClinical operations (Vault apps)Veeva AI Agents announced for Vault applications (built with Anthropic and Amazon models on Amazon Bedrock), with clinical operations, regulatory, medical and clinical data agents scheduled across its 2026 Vault releases.
OracleClinical operationsOracle Life Sciences AI Agents for clinical trial operations (announced November 18, 2026 for early adopters) targeting portfolio monitoring, trial planning and conduct with human review before actions. Distinct from Oracle Health Clinical AI Agent, which handles clinical EHR documentation for physicians.
CurebaseClinical operations / eClinical (DCT)AI-powered decentralized clinical trial platform covering ePRO, eCOA, eConsent, patient engagement and integrated EDC.
ValyuClinical research data layerUnified Search, Contents, DeepResearch and MCP across valyu/valyu-clinical-trials , valyu/valyu-pubmed , valyu/valyu-medrxiv , valyu/valyu-drug-labels and valyu/valyu-openfda-drug-events for building and grounding clinical research AI agents.

These two categories complement each other. A sponsor might use Veeva or Medable to manage site operations while using Valyu to power the research agents that track competing Phase 3 trials, compare readouts and watch FDA label changes.

Figure 1. A clinical trial research agent pulls protocols, published readouts, FDA labels and FAERS reports through Valyu Search, DeepResearch and MCP to write a cited brief. Example record: NCT06497556, retrieved November 24, 2026.

Three habits that keep your agent accurate

Three simple design rules separate reliable, citation-backed clinical agents from generic chatbots:

  • Run one focused query per dataset in parallel. Avoid lumping four biomedical sources into one broad Search call. Query valyu-clinical-trials, valyu-pubmed, valyu-drug-labels and valyu-openfda-drug-events concurrently so every evidence type gets its own ranking slot.
  • Query one drug at a time for FDA labels and FAERS. Use the brand name paired with MedDRA terminology for FAERS, and always present FAERS findings as spontaneous case reports rather than incidence rates.
  • Use DeepResearch for cross-source briefs. Let DeepResearch pull trials, journal papers and breaking conference releases into one cited write-up, and always double-check safety denominators and publication dates before quoting them.

Worked example: KRAS G12C inhibitors in non-small cell lung cancer (NSCLC)

To keep every snippet grounded in real, fast-moving clinical data, we will build an agent that tracks KRAS G12C inhibitors in NSCLC. As of November 24, 2026, ClinicalTrials.gov lists 15 recruiting Phase 3 studies across sponsors including Amgen, Mirati Therapeutics (a Bristol Myers Squibb company), Hoffmann-La Roche, Eli Lilly, Merck and Revolution Medicines.

Two approved therapies, sotorasib (Lumakras) and adagrasib (Krazati), hold accelerated FDA approval in previously treated KRAS G12C NSCLC. Meanwhile, Roche's investigational divarasib beat both head-to-head in Krascendo 1 (NCT06497556), presented at ESMO 2026 and published in NEJM on October 25, 2026, while Eli Lilly's olomorasib and Merck's calderasib advance through first-line Phase 3 trials.

Here is the active Phase 3 landscape captured from ClinicalTrials.gov:

NCT IDTrialRegimen & settingLead sponsorStatus (as of Nov 24, 2026)EnrollmentPrimary endpoint(s)Primary completion
CodeBreaK 200Sotorasib vs docetaxel (2L+)AmgenCompleted345 (actual)PFS (BICR)Aug 2, 2022 (actual)
KRYSTAL-12Adagrasib vs docetaxel (2L+)Mirati Therapeutics Inc.Active, not recruiting453 (actual)PFS by BICRDec 30, 2023 (actual)
Krascendo 1Divarasib vs sotorasib or adagrasib (2L+)Hoffmann-La RocheActive, not recruiting338 (actual)PFSMay 19, 2026 (actual)
Krascendo 2Divarasib + pembrolizumab vs pembro + chemo (1L)Hoffmann-La RocheRecruiting600 (est.)PFS; OSNov 30, 2028 (est.)
KRASCENDO 3Divarasib vs immunotherapy or observation (resected II to III)Hoffmann-La RocheRecruiting400 (est.)DFS (investigator)Jan 31, 2032 (est.)
SUNRAY-01Olomorasib + pembrolizumab +/- chemo (1L)Eli Lilly and CompanyRecruiting1,264 (est.)PFS; TEAEs (safety lead-in)Nov 2027 (est.)
SUNRAY-02Olomorasib + pembrolizumab or durvalumab vs placeboEli Lilly and CompanyRecruiting700 (est.)DFS; PFS (BICR)May 2029 (est.)
CodeBreaK 202Sotorasib + chemo vs pembrolizumab + chemo (1L, PD-L1 neg)AmgenRecruiting750 (est.)PFS; OSJun 30, 2027 (est.)
KRYSTAL-4Adagrasib + pembrolizumab + chemo vs placebo + pembro + chemo (1L)Mirati Therapeutics Inc.Recruiting630 (est.)PFS (BICR); OSSep 7, 2029 (est.)
KANDLELIT-004Calderasib (MK-1084) + pembrolizumab vs placebo + pembro (1L, PD-L1 >=50%)Merck Sharp & Dohme LLCRecruiting348 (est.)PFSJan 24, 2028 (est.)

Step 1: search ClinicalTrials.gov with sharp query patterns

Install the SDK for Python or TypeScript and export your API key:

Shell
# Python
pip install valyu
 
# TypeScript / Node.js
npm install valyu-js
 
export VALYU_API_KEY="your-api-key"

Query valyu/valyu-clinical-trials through Valyu Search. The specificity of your query directly controls how clean your trial list comes back:

from valyu import Valyu
 
valyu = Valyu() # reads VALYU_API_KEY
 
queries = [
"KRAS G12C inhibitor non-small cell lung cancer trials",
"recruiting Phase 3 trials of KRAS G12C inhibitors in first-line NSCLC",
"NCT04303780",
]
 
for q in queries:
response = valyu.search(
q,
included_sources=["valyu/valyu-clinical-trials"],
max_num_results=10,
)
print(f"\n### {q} (${response.total_deduction_dollars})")
for r in response.results or []:
print(" -", r.title, "|", r.url)

What works best in Step 1

  • Name the phase, status, mechanism and line of therapy. Searching "recruiting Phase 3 trials of KRAS G12C inhibitors in first-line NSCLC" returned 10 out of 10 recruiting first-line Phase 3 studies in 2.35 seconds.
  • Pass an exact NCT ID for known trials. Querying "NCT04303780" returned the exact study (match_score: 1.0) in 0.49 seconds, making it the fastest way to fetch a specific record.
  • Read structured results right from the record. Each valyu/valyu-clinical-trials hit includes 56 structured fields such as outcome_results, adverse_events, eligibility_criteria and locations. In our tests, posted PFS figures for CodeBreaK 200 (5.62 vs 4.47 months, HR 0.663) and KRYSTAL-12 (5.49 vs 3.84 months, HR 0.58) matched ClinicalTrials.gov to the decimal place.
  • Watch the date field names. In valyu/valyu-clinical-trials, completion_date holds the primary completion date, while final study completion lives in study_completion_date.

Step 2: fan out across trials, PubMed, FDA labels and FAERS in parallel

This is the most important pattern to get right. When we passed three datasets (valyu-clinical-trials, valyu-pubmed and valyu-drug-labels) in a single valyu.search call, trials crowded out the results and returned zero PubMed papers in both Python and TypeScript.

Instead, fan out one focused query per dataset in parallel. Each source gets its own tailored phrasing and full result slots:

from concurrent.futures import ThreadPoolExecutor
from valyu import Valyu
 
valyu = Valyu() # reads VALYU_API_KEY
 
PLAN = {
"valyu/valyu-clinical-trials": "recruiting Phase 3 KRAS G12C inhibitor trials in first-line non-small cell lung cancer",
"valyu/valyu-pubmed": "phase 3 randomised trial KRAS G12C inhibitor versus docetaxel progression-free survival NSCLC",
"valyu/valyu-drug-labels": "Lumakras sotorasib KRAS G12C NSCLC indication hepatotoxicity warnings",
"valyu/valyu-openfda-drug-events": "LUMAKRAS hepatotoxicity",
}
 
def run(source, query):
return source, valyu.search(query, included_sources=[source], max_num_results=5)
 
with ThreadPoolExecutor(max_workers=len(PLAN)) as pool:
results = list(pool.map(lambda kv: run(*kv), PLAN.items()))
 
for source, resp in results:
print(f"\n[{source}] {len(resp.results)} results (${resp.total_deduction_dollars})")
seen = set()
for r in resp.results:
if r.url in seen and "open.fda.gov" not in r.url:
continue
seen.add(r.url)
print(f" - {r.title[:100]} | {r.url}")

Source-by-source tips that keep your agent accurate

  • PubMed (valyu/valyu-pubmed): Deduplicate hits by URL because long PubMed Central papers can return multiple chunks. Since valyu-pubmed indexes Open Access PMC full text, pair it with valyu/valyu-medrxiv for fresh clinical preprints (such as a 2026 study on sotorasib hepatotoxicity after immune checkpoint inhibitors).
  • FDA drug labels (valyu/valyu-drug-labels): Query one drug per call. A combined "sotorasib adagrasib" search returned only Lumakras, while separate calls returned the current DailyMed SPL for each drug. Checking live labels caught a real regulatory change: Krazati's SPL v14 (October 23, 2026) removed its KRAS G12C colorectal cancer accelerated approval indication in August 2026, leaving NSCLC as its sole active indication.
  • FDA FAERS (valyu/valyu-openfda-drug-events): Pair the brand name with a MedDRA reaction term (such as "LUMAKRAS hepatotoxicity" or "LUMAKRAS interstitial lung disease", which returned 10 relevant case reports). Non-MedDRA phrasing like "KRAZATI QT prolongation" returned zero hits (the MedDRA term is "Electrocardiogram QT prolonged"), and FAERS queries can occasionally return empty, so add a simple retry.
  • Keep FAERS counts and narratives separate: valyu-openfda-drug-events returns individual case reports rather than totals. For aggregate numbers, check the openFDA count endpoint (as of October 28, 2026: 3,470 total / 2,851 serious reports for sotorasib; 1,134 total / 878 serious for adagrasib) and always treat FAERS as spontaneous safety signals rather than incidence rates.

What the multi-source evidence shows across the three KRAS G12C Phase 3 readouts

Trial (NCT ID)Comparison (2L+ NSCLC)Median PFS (BICR)Hazard ratio & p-valueGrade >=3 TRAEsPrimary source
CodeBreaK 200 ( )Sotorasib vs docetaxel (n=345, 1:1)5.6 mo (4.3 to 7.8) vs 4.5 mo (3.0 to 5.7)HR 0.66 (0.51 to 0.86), p=0.001733% vs 40%
KRYSTAL-12 ( )Adagrasib vs docetaxel (n=453, 2:1)5.5 mo (4.5 to 6.7) vs 3.8 mo (2.7 to 4.7)HR 0.58 (0.45 to 0.76), p<0.000147% vs 46%
Krascendo 1 ( )Divarasib vs sotorasib or adagrasib (n=338)9.8 mo (8.1 to 12.9) vs 5.7 mo (4.2 to 6.8)HR 0.58 (0.44 to 0.76), p<0.000124.6% vs 34.5% (Grade 3/4); ESMO 2026 / NEJM Oct 25, 2026

Avoid ranking CodeBreaK 200 directly against KRYSTAL-12 from separate trials: median follow-up (17.7 vs 7.2 months), randomization ratios (1:1 vs 2:1) and enrollment windows differ. Krascendo 1 is the only head-to-head comparison, where investigational divarasib (not FDA-approved as of November 24, 2026) also showed an interim overall survival benefit (17.7 vs 12.0 months, HR 0.56, p=0.0005, per OncLive ESMO 2026 coverage).

Step 3: synthesize across sources with DeepResearch

When you want a cited narrative brief instead of stitching together raw search hits yourself, call DeepResearch in instant mode:

from valyu import Valyu
 
valyu = Valyu() # reads VALYU_API_KEY
 
question = (
"For KRAS G12C-mutated non-small cell lung cancer, compare the Phase 3 results of "
"CodeBreaK 200 (sotorasib) and KRYSTAL-12 (adagrasib) versus docetaxel: median PFS, "
"hazard ratio and grade 3 or worse treatment-related adverse events. Then list the "
"Phase 3 trials of divarasib and olomorasib with NCT ID, sponsor, status and primary endpoint."
)
 
task = valyu.deepresearch.create(query=question, mode="instant")
result = valyu.deepresearch.wait(task.deepresearch_id)
 
print(result.output)
for s in result.sources or []:
print("-", s.title, s.url)

In our live run, mode="instant" finished in 27.7 seconds and surfaced both primary Lancet papers (PMID 36764316 and KRYSTAL-12) alongside Roche's July 2026 Krascendo 1 topline release, with accurate PFS, hazard ratio and adverse-event numbers. As a habit, always double-check safety denominators and publication dates on breaking conference readouts before quoting them.

instant mode runs a single step for fast answers, but DeepResearch supports five modes that scale depth and budget: instant (1 step), fast (up to 12 steps), standard (up to 25 steps), heavy (up to 45 steps) and max (up to 75 steps).

For deeper multi-trial syntheses, set mode explicitly to "standard" or "heavy" (Python defaults to "standard", while TypeScript defaults to "fast". You can also pass research_strategy (researchStrategy in TypeScript) and report_format (reportFormat in TypeScript) to steer the brief, plus request downloadable CSV or Excel deliverables in any mode except instant:

from valyu import Valyu
 
valyu = Valyu() # reads VALYU_API_KEY
 
task = valyu.deepresearch.create(
query=(
"Build a competitive clinical brief on KRAS G12C inhibitors in NSCLC: compare "
"CodeBreaK 200 (sotorasib), KRYSTAL-12 (adagrasib), and Krascendo 1 (divarasib) "
"on efficacy, grade 3+ safety, and current FDA label status, plus active first-line Phase 3 trials."
),
mode="standard", # choose "fast", "standard", "heavy", or "max" for deeper multi-step research
research_strategy=(
"Check NCT IDs, enrollment, status, and primary endpoints from ClinicalTrials.gov, "
"primary Phase 3 readouts from journal publications, and current FDA indications from DailyMed drug labels."
),
report_format=(
"Executive summary, Phase 3 efficacy and safety comparison table, active first-line pipeline table, "
"and cited regulatory label notes."
),
deliverables=[
{
"type": "csv",
"description": "One row per Phase 3 KRAS G12C NSCLC trial with NCT ID, drug, sponsor, status, and endpoint.",
"columns": ["nct_id", "trial_name", "drug", "sponsor", "status", "primary_endpoint", "source_url"],
}
],
)
 
result = valyu.deepresearch.wait(task.deepresearch_id)
print(result.output)
for dl in result.deliverables or []:
print(dl.type, dl.title, dl.url)

If you want repeatable, multi-tab Excel trackers and single-trial readout reports out of the box, explore Valyu's curated life-sciences workflows (ls-clinical-trial-tracker and ls-trial-readout) in our companion guide on automating clinical trial tracking and readout analysis.

Step 4: connect the same tools with zero code via MCP

If your team already works inside Claude, ChatGPT, Cursor or another MCP-compatible client, you can stand up the same clinical trial AI agent without writing any code. Connect the remote Valyu MCP server at:

Shell
https://mcp.valyu.ai/mcp

Sign in via OAuth (see the MCP setup guide) , then use a structured prompt that keeps every evidence type separate and cited:

Shell
Use Valyu to map recruiting Phase 3 KRAS G12C NSCLC trials on ClinicalTrials.gov.
For each approved drug (Lumakras and Krazati), pull the current DailyMed FDA label
indications and warnings separately, and retrieve relevant openFDA FAERS reports.
Cite a URL for every claim and keep registry facts, journal results and FAERS reports separate.

Troubleshooting: how to get clean results every time

  • Multi-source search drops PubMed or FDA labels: Fan out one focused valyu.search call per dataset in parallel (Step 2) instead of combining multiple datasets in one call.
  • Two-drug label query returns only one drug: Query valyu/valyu-drug-labels with a single drug per call (Lumakras first, then Krazati).
  • FAERS search returns zero hits: Switch to the brand name plus a MedDRA reaction term (such as "LUMAKRAS hepatotoxicity" or "Electrocardiogram QT prolonged") , add a retry on empty responses, and check openFDA's count endpoint when you need aggregate totals.
  • Completion date looks earlier than expected: In valyu/valyu-clinical-trials, completion_date maps to the primary completion date; use study_completion_date for full study completion.

FAQ

What is a clinical trial AI agent?

A clinical trial AI agent is an AI system connected to live clinical tools and databases that executes multi-step research or operational workflows. Operational agents run inside eTMF, EDC and site software (Medable, Veeva, Oracle), while research agents query ClinicalTrials.gov, PubMed, FDA drug labels and FAERS to analyze trials, readouts and safety with direct citations.

What is the difference between using the ClinicalTrials.gov API directly and using a clinical trial AI agent?

The free ClinicalTrials.gov v2 API relies on strict keyword filtering, returns deeply nested JSON and covers only trial registry entries. A clinical trial AI agent built on Valyu understands plain-English clinical queries and brings ClinicalTrials.gov together with PubMed, preprints, DailyMed FDA labels and FAERS in one workflow.

Which Valyu datasets power a clinical trial AI agent?

The core clinical stack uses valyu/valyu-clinical-trials (ClinicalTrials.gov protocols and posted results), valyu/valyu-pubmed (PubMed Open Access papers), valyu/valyu-medrxiv and valyu/valyu-biorxiv (preprints), valyu/valyu-drug-labels (DailyMed FDA-approved labeling) and valyu/valyu-openfda-drug-events (FAERS case reports). See the full catalog in Valyu data sources.

How do I stop a clinical trial AI agent from hallucinating NCT numbers or enrollment counts?

Require every agent answer to cite NCT IDs and source URLs returned directly by valyu/valyu-clinical-trials, fan out one focused query per dataset rather than cramming everything into one search, and prompt the model to keep registry facts, published readouts, FDA labels and FAERS reports in separate sections.

Can a clinical trial AI agent handle patient PHI or HIPAA-regulated trial data?

Public-registry clinical research agents (like the Valyu workflow in this guide) operate on public registries, published literature, FDA labels and anonymized FAERS reports, with no patient PHI involved. Workflows that screen identifiable patient records or manage live eTMF/EDC data require HIPAA, GxP and 21 CFR Part 11 clinical operations platforms.

Lancet or NEJM paper?

valyu/valyu-pubmed indexes Open Access PubMed Central full text, so paywalled primary papers in The Lancet or NEJM often sit outside PMC. Use DeepResearch (which searches across web and journal sources alongside biomedical datasets) to surface paywalled journal endpoints and recent conference readouts.

How much does it cost to run a clinical trial AI agent with Valyu?

New accounts get free credits every month, up to 2,000 with a work email. In our live tests, an exact NCT lookup cost $0.005, a four-source parallel fan-out cost about $0.03, and a DeepResearch instant synthesis cost $0.05.

How do I connect a clinical trial AI agent to Claude or ChatGPT?

Add https://mcp.valyu.ai/mcp as a custom connector in Claude or ChatGPT, sign in with your Valyu account, and prompt it to search ClinicalTrials.gov, PubMed and DailyMed labels with direct URL citations. See the chat apps guide for step-by-step screenshots.

Build your clinical trial AI agent

Fan out across trial registries, biomedical literature, FDA labels and safety reports, and turn multi-source clinical evidence into cited briefs in seconds. Get an API key, explore biotech and pharma use cases, or read how to find recruiting clinical trials via API, how to map a clinical trial landscape for a drug target and how to build a biomedical research agent.

Cover photograph: NIH Clinical Center South Entrance, Bethesda, Maryland. Masm2016 / Wikimedia Commons. CC BY-SA 4.0. Cropped and resized to 16:9; this adapted version is shared under the same license.

Valyu Add

Join 12,000+ professionals and knowledge workers.

Valyu Add is a free weekly research briefing for builders, investors and operators. Every issue is sourced, cited and verified with Valyu DeepResearch.