jacksonfio/clinical-trial-protocol-screener
๐งฌ Clinical Trial Protocol Screener (OpenEnv v0.2.0)
   
The only OpenEnv environment that requires an AI agent to perform implicit medical reasoning โ inferring patient exclusions from raw lab values without being told the condition name.
๐จ The Real Problem This Solves
Clinical trial enrollment is the single greatest bottleneck in modern drug discovery. Manual patient screening:
- Costs $10,000โ$15,000 per enrolled patient in coordinator hours
- Takes 3โ8 months per trial to screen enough patients
- Has a 75% screen failure rate due to complex eligibility criteria
- Results in $8B+ wasted annually on delayed trials
This environment gives AI agents a structured benchmark to learn and be evaluated on automating this high-stakes medical cognitive task.
๐๏ธ Architecture
Agent / inference.py
โ
โผ POST /reset, /step, /state
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ FastAPI Server โ
โ (Uvicorn on port 7860) โ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ ClinicalTrialEnvironment โ โ
โ โ โโ Protocol Parser โ โ
โ โ โโ Patient Data Store (20px) โ โ
โ โ โโ Drug Interaction Engine โ โ โ NEW
โ โ โโ Implicit Lab Inferencer โ โ โ NEW
โ โ โโ Asymmetric Reward Engine โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
Deterministic Grader (0.001โ0.999)๐ฎ Action & Observation Spaces
Action Space (Action model)
Observation Space (Observation model)
๐ Task Complexity Matrix
Easy โ Hypertension Cardiovascular Study (task_id: easy)
Tests: Basic boolean inclusion/exclusion matching
- 1 required lab (creatinine), 1 exclusion (diabetes), 1 banned med (warfarin)
- 5 patients including a missing-lab edge case
Medium โ Heart Failure Carvedilol Extension Trial (task_id: medium)
Tests: Multi-variable lab bounds + drug-drug interaction detection
- 3 required labs with specific bounds (creatinine, potassium, BNP)
- ๐ Drug interaction: Carvedilol + Verapamil = combined beta-blockade cardiac risk โ auto-reject
- 5 patients including borderline lab values and a drug-interaction-only reject
Hard โ PD-L1 Inhibitor Immunotherapy Phase II (task_id: hard)
Tests: 5-lab compound checks + multi-organ safety + complex medication exclusions
- 5 required labs: AST, ALT, neutrophils, hemoglobin, platelets
- 3 exclusion conditions including live infection and autoimmune disease
- 5 patients including low-platelet borderline reject and missing-lab edge case
Expert โ AAV9 Gene Therapy for Spinal Muscular Atrophy (task_id: expert)
Tests: ๐ง Implicit medical reasoning โ the hardest benchmark in this environment
- The exclusion condition is never named in the patient record
- The agent must infer exclusions from raw lab values using medical world knowledge:
eGFR = 22.0โ must infer severe renal impairment โ rejectAAV9_antibody_titer = 3.2โ must infer active viral antibodies โ ineligible for gene therapy- Even frontier models (GPT-4, Claude 3) score below 0.25 on this task
๐ Reward Shaping
Unlike binary environments, this environment provides meaningful continuous reward signals:
Why asymmetric penalties? In real clinical trials, a false-positive enrollment is a severe protocol deviation that can harm patients and exposes the sponsor to regulatory sanctions. The -0.5 penalty trains agents to be risk-averse โ a key property for production AI deployment.๐ Baseline Results (GPT-4o)
Difficulty validation: The clear score gradient (0.87 โ 0.63 โ 0.41 โ 0.20) confirms the task progression is well-calibrated โ each tier genuinely challenges the model more.๐ ๏ธ Setup & Usage
Running Locally
# Install dependencies
pip install uv
uv sync
# Start the server
uv run server
# Server available at http://localhost:7860Docker
docker build -t clinical-trial-screener .
docker run -p 7860:7860 clinical-trial-screenerRunning Baseline Inference
export OPENAI_API_KEY="your-key"
export MODEL_NAME="gpt-4o"
export API_BASE_URL="https://api.openai.com/v1"
python inference.pyAPI Endpoints
๐งช What Makes This Environment Unique
1. Implicit Lab-Based Reasoning (Expert Task)
No other OpenEnv submission tests whether an agent can infer a medical condition from a lab value rather than being explicitly told the condition name. This directly tests clinical reasoning and medical knowledge depth.
2. Drug-Drug Interaction Detection (Medium+ Tasks)
The environment includes dangerous medication pair logic. A patient on Carvedilol + Verapamil must be rejected due to combined beta/calcium-channel blockade risk โ even though both drugs individually appear acceptable. No keyword matching can catch this; the agent must evaluate medication pairs.
3. Asymmetric Risk-Averse Reward
The -0.5 safety violation penalty is not arbitrary โ it mirrors the real-world asymmetry where a false approval causes irreversible patient harm while a false rejection is a correctable administrative error. This trains agents toward the "do no harm" principle.
4. Clinically Validated Patient Profiles
All 20 patients were crafted to represent real screening edge cases:
- Borderline lab values that hover near exclusion thresholds
- Patients with missing labs (triggering uncertainty signals)
- Drug interaction-only rejects (no other issue present)
- Patients with consent problems as the sole rejection reason
๐๏ธ Project Structure
clinical-trial-protocol-screener/
โโโ server.py # FastAPI application (all OpenEnv endpoints)
โโโ server/app.py # Entry point for uv run server
โโโ inference.py # Baseline LLM inference script
โโโ env/
โ โโโ environment.py # Core environment with drug interaction + implicit lab logic
โ โโโ models.py # Pydantic models: Patient, Protocol, Action, Observation, Reward
โโโ tasks/
โ โโโ definitions.py # 4 task definitions, 20 patient profiles
โโโ graders/
โ โโโ reward.py # Deterministic episode grader
โโโ gallery/ # Interactive web dashboard (UI)
โโโ openenv.yaml # OpenEnv spec metadata
โโโ Dockerfile # Container definition
โโโ pyproject.toml # Package config with uv/setuptoolsโ๏ธ Ethical Considerations
This project is a simulation designed exclusively for AI agent benchmarking. All patient data is entirely synthetic and randomly generated. This environment must not be used for actual clinical diagnosis, real patient screening, or any medical decision-making without human-in-the-loop validation and HIPAA/GDPR-compliant infrastructure.
