medR: Reward Engineering for Clinical Offline Reinforcement Learning via Tri-Drive Potential Functions

Qianyi Xu, Gousia Habib, Feng Wu, Yanrui Du, Zhihui Chen, Swapnil Mishra, Dilruk Perera, Mengling FengarXiv 2026

TL;DR

medR is an automated pipeline that leverages Large Language Models (LLMs) to solve the "reward engineering" bottleneck in clinical Reinforcement Learning. By formulating rewards through a "Tri-Drive" potential function—balancing patient survival, data confidence, and treatment competence—the framework generates policies that significantly outperform clinician baselines across diverse critical care tasks.

What Problem Does This Paper Address?

Reinforcement Learning (RL) is ideal for optimizing Dynamic Treatment Regimes (DTRs), but it faces a major hurdle in healthcare: reward engineering. In clinical settings, the ultimate goal (survival) is sparse and delayed, occurring only at the end of an ICU stay. This makes it incredibly difficult for an RL agent to know which specific actions led to that outcome—a classic credit assignment problem.

Existing approaches often rely on manual heuristics, which are brittle and fail to generalize across different diseases. Furthermore, clinical RL is strictly offline; you cannot "explore" on real patients to see if a reward signal works. This often leads to "Pyrrhic Victories," where an agent optimizes for survival through aggressive, toxic interventions, or "reward hacking," where the agent learns to keep a patient in a stable but non-improving state just to collect intermediate bonuses.

Methods

The authors propose medR, an automated pipeline that integrates medical domain knowledge from LLMs with rigorous control-theoretic principles. The framework consists of three main phases:

  1. Interpretable Feature Selection: Instead of dumping all available data into the model, an LLM acts as a "clinical data scientist." It analyzes statistical metadata (correlation with mortality, missingness rates) to select the most relevant physiological features for a specific disease.
  2. Tri-Drive Reward Generation: The LLM is prompted to synthesize executable Python code for a reward function based on three "drives":
  3. Survival: Rewards states moving toward homeostasis (physiological stability).
  4. Confidence: Penalizes decisions made using "stale" or uncertain data by scaling rewards based on the time elapsed since the last observation.
  5. Competence: Acts as a regularization term, penalizing excessive or invasive interventions to ensure treatment efficiency.
  6. Multi-Objective Selection: The pipeline generates multiple candidate reward functions. These are evaluated using offline fitness metrics and a genetic algorithm (NSGA-II) to identify the "Pareto-optimal" reward structure that best balances survival, confidence, and competence before any policy training begins.
Figure 1: Framework pipeline of medR.

Technically, medR utilizes Potential-Based Reward Shaping (PBRS). By defining the reward as the difference in a health potential function ($\gamma\Phi_{t+1} - \Phi_t$), the authors ensure the agent focuses on state improvement rather than just state maintenance.

Datasets

The framework was validated on three distinct, high-stakes clinical tasks using large-scale real-world databases:

  • Sepsis Treatment: Utilizing the MIMIC-IV database (7,501 patients) to optimize IV fluid and vasopressor administration.
  • Mechanical Ventilation (MV): Utilizing the eICU-CRD database (2,168 patients) to optimize ventilator settings (PEEP, $FiO_2$, Tidal Volume).
  • Renal Replacement Therapy (RRT): Utilizing the AmsterdamUMCdb (857 patients) to optimize continuous dialysis dosing.

Key Insights and Ideas

  • LLMs as Logic Designers, Not Scorers: The authors found that LLMs are ill-suited to directly outputting scalar reward scores for trajectories (which often suffer from hindsight bias). However, they excel at acting as "logic designers"—translating clinical goals into structured, executable code.
  • Breaking Policy Invariance for Good: While standard reward shaping aims for policy invariance, medR intentionally breaks it by adding a non-telescoping action cost. This transforms the RL problem into a Lagrangian relaxation of a Constrained MDP, forcing the agent to maximize stability while minimizing "toxicity" or intervention harm.
  • Freshness Matters: In offline clinical data, a "normal" heart rate from 12 hours ago is not reliable. By explicitly building a "Confidence" drive that discounts rewards based on data staleness ($\Delta t$), the model accounts for epistemic uncertainty inherent in EHR data.

Key Results

Policies trained with medR-generated rewards consistently outperformed clinician baselines and standard reward models:

  • Performance Gains: medR achieved 77.3% (Sepsis), 66.7% (Ventilation), and 60.3% (RRT) higher Weighted Importance Sampling (WIS) scores compared to clinician baselines.
  • Mortality Correlation: The cumulative rewards generated by medR showed a strong monotonic decreasing trend with actual patient mortality, proving the reward signal is a highly reliable proxy for patient risk.
Figure 2: The relationship between cumulative reward and mortality.
  • Ablation Success: The study showed that the "potential difference" formulation was the most critical component; removing it led to a catastrophic collapse in performance, particularly in the ventilation task.

Limitations and Future Work

  • LLM Bias: The authors acknowledge that LLM-generated rewards may inherit biases present in their training data or be sensitive to prompt phrasing.
  • Prospective Validation: While the offline results are strong, the authors emphasize that rigorous prospective (real-world) clinical trials and human-in-the-loop oversight are essential before deployment.
  • Scaling: Future work could involve applying this framework to even more complex intervention spaces and broader sets of rare pathologies where manual reward design is currently impossible.

Summary updated

BibTeX
@misc{xu2026medr,
  author = {Qianyi Xu and Gousia Habib and Feng Wu and Yanrui Du and Zhihui Chen and Swapnil Mishra and Dilruk Perera and Mengling Feng},
  title = {{medR: Reward Engineering for Clinical Offline Reinforcement Learning via Tri-Drive Potential Functions}},
  year = {2026},
  eprint = {2602.03305},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2602.03305},
}
Figure