arXiv:2610.05431cs.AIOct 2026

Manuscript Offprint

arXiv:2610.05431

PharmAgent: Constraint-Aware Search with Frozen Language Models for Molecular Optimization

Nihui Shao, Guanxing Chen, Jilong Shi, Zhengyang Bai, Haohuai He, Zhenchao Tang, Qiujie Lv, Yu-An Huang, Zhi-An Huang

ABSTRACT

Molecular optimization must improve target activity and satisfy developability constraints within limited evaluation budgets. Classical methods require tailored rules or training to incorporate chemical instructions and property feedback. Frozen language models can condition edits on this information, but need explicit constraint control and relevant experience. We therefore present PHARMAGENT, a constraint-aware molecular search method driven by adaptive external state. Its Lagrangian controller translates violations in accepted states into accumulated constraint pressure, keeping this history separate from current property measurements. Structure-indexed replay complements this feedback with relevant evaluated transitions that guide subsequent proposals. As a curriculum progressively activates constraints, candidates and the incumbent are compared under the same current objective, and the accepted state determines the next multiplier update. We derive an exact identity that characterizes how accepted-state violations accumulate in the controller's multipliers. Across five tasks with five independent runs, PHARMAGENT achieves a summed area under the target-score curves (AUC) of 3.9208 in target-only search, improving over MOLLEO by 37.3%. With online constraints, it achieves a property-adjusted AUC of 0.7076, improving over the strongest online baseline, ExLLM, by 53.8%. These results rank first among all evaluated methods in both target-only and constraint-aware search. The online comparison covers all five baseline frameworks. The full system leads every ablation variant in target quality, property-adjusted performance, and Pareto hypervolume. All five molecular cases reach feasible final states, documenting target gains and trade-offs. These results establish PHARMAGENT as a powerful framework for budget-limited molecular optimization, achieving leading aggregate performance through adaptive external search state and frozen language models.

1 INTRODUCTION

Molecular optimization searches for structures with improved target activity and suitable physicochemical, synthesizability, and absorption, distribution, metabolism, excretion, and toxicity (ADMET) properties (Bickerton et al., 2012; Gao & Coley, 2020). Under limited budgets, each evaluation should guide productive structural edits (Gao et al., 2022). Graph-GA's stochastic mutation and crossover can spend evaluations on unproductive edits (Jensen, 2019; Wang et al., 2025). REINVENT4 adapts its policy through reward-driven parameter updates (Loeffler et al., 2024), while latent-space Bayesian optimization depends on learned representations and valid decoding (Gómez-Bombarelli et al., 2018). These methods require translating chemical instructions and heterogeneous feedback into search rules or training signals (Ran et al., 2025). Large language models (LLMs) can instead condition chemically informed edits directly on task instructions and evaluated experience (Wang et al., 2025; Ran et al., 2025; Krüger et al., 2026). Freezing their parameters enables adaptation through context without retraining (Yang et al., 2024; M. Bran et al., 2024).

However, proposal quality alone leaves two feedback gaps (Figure 1(a)). First, target gains can introduce property violations (Gao & Coley, 2020). Persistent violations call for search priorities that adapt to violation history, beyond fixed penalty weights or post-hoc filtering. Second, multi-round interaction creates experience, but useful guidance requires edits relevant to the current molecular structure (Shinn et al., 2023; Liu et al., 2025). These gaps motivate dynamic constraint control and structure-aware experience retrieval.

To address both gaps, we propose PHARMAGENT, a constraint-aware molecular search method that adapts external state around frozen language models. Generator and Reviewer execute the proposal, evaluation, acceptance, and feedback loop with scientific tools and medicinal-chemistry retrieval-augmented generation (MedChem-RAG) (Figure 1(b)). Three mechanisms organize external state (Figure 1(c)). A Lagrangian controller accumulates accepted-state violations as historical pressure, separate from current measurements (Bertsekas, 1999). Chemical-aware contextual experience replay (Chemical-CER) retrieves structurally related evaluated edits, and a curriculum introduces constraints after target exploration. Candidates and the incumbent share the current objective, while stored attempts remain distinct from accepted states. Table 1 compares the evaluated configurations.

Table 1: Mechanisms in evaluated configurations ( ✓\checkmark enabled, ×\times not enabled). Baseline rows show original configurations. Online adaptations use fixed-penalty (FP) rewards or feasibility-first (FF) rewards, selection, or conversational guidance. Retrieval and cross-task reuse concern optimization attempts. Appendix D specifies protocols.

MethodOnline constraintsAdaptive weightsStructure-based retrievalCross-task reuse
Graph-GA / REINVENT4✕✕✕✕
MOLLEO / ExLLM / SEISMO✕✕✕✕
Online adaptations✓✕✕✕
PHARMAGENT✓✓✓✓

We evaluate target-only search (E1) on practical molecular optimization (PMO) (Gao et al., 2022) and search with online constraints (E2) on ADMET-PMO, followed by ablations and molecular cases. Our contributions are:

  • A unified molecular search framework that turns property feedback, structurally relevant transitions, and constraint timing into adaptive external decision state for frozen LLMs.

  • An analytical characterization linking multiplier growth to cumulative accepted-state violations, explaining how the controller retains historical constraint pressure.

(a) Molecular search: two feedback gaps

Figure

(b) Frozen LLMs, budgeted search

Structured feedback

Figure

Figure 1: Motivation and the PHARMAGENT feedback loop. (a) Two feedback gaps in molecular search. High target scores need not imply feasibility, and past evaluations require relevant retrieval. (b) Frozen Generator–Reviewer workflow for proposal, evaluation, acceptance, and feedback. Candidates and the incumbent share the current objective. (c) External search state comprising Chemical-CER, curriculum, and Lagrangian control. Evaluated attempts enter replay, while accepted states update multipliers. Current measurements remain separate from historical pressure. Property labels denote molecular weight (MW), the logarithm of the octanol–water partition coefficient (logP), quantitative estimate of drug-likeness (QED), synthetic accessibility (SA), cytochrome P450 2D6 (CYP2D6), the human ether-à-go-go-related gene potassium channel (hERG), and Caco-2 cell permeability. Icons are schematic. Solid routes show flow or updates, whereas dashed routes show conditioning.

• The highest aggregate performance across five tasks and five runs, with a 37.3% gain in target-score area under the curve (AUC) in E1 and a 53.8% gain in ADMET-adjusted AUC (AA-AUC) over the strongest online baseline in E2. The full system leads every ablation, and all five cases reach feasibility.

References (28)