A gent D rug: Utilizing Large Language Models in an Agentic Workflow for Zero-Shot Molecular Optimization (2025)

Abstract: Molecular optimization—modifying a given molecule to improve desired properties—is a fundamental task in drug discovery. While LLMs hold the potential to solve this task using natural language to drive the optimization, straightforward prompting achieves limited accuracy. In this work, we propose AgentDrug, an agentic workflow that leverages LLMs in a structured refinement process to achieve significantly higher accuracy. AgentDrug defines a nested refinement loop: the inner loop uses feedback from cheminformatics toolkits to validate molecular structures, while the outer loop guides the LLM with generic feedback and a gradient-based objective to steer the molecule toward property improvement. We evaluate AgentDrug on benchmarks with both single- and multi-property optimization under loose and strict thresholds. Results demonstrate significant performance gains over previous methods. With Qwen-2.5-3B, AgentDrug improves accuracy by 20.7% (loose) and 16.8% (strict) on six single-property tasks, and by 7.0% and 5.3% on eight multi-property tasks. With larger model Qwen-2.5-7B, AgentDrug further improves accuracy on 6 single-property objectives by 28.9% (loose) and 29.0% (strict), and on 8 multi-property objectives by 14.9% (loose) and 13.2% (strict).

## introduction the process of drug discovery, which involves identifying molecules that can safely treat or influence a disease, is expensive and typically takes over a decade to result in an approved drug @xcite . recent advancements in ai for molecular studies have been revolutionizing this process by scaling many key tasks efficiently @xcite . while significant progress has been made in molecular property prediction, synthesis, and retrosynthesis @xcite , molecular optimization-a crucial step in refining candidate molecules-remains relatively underexplored. molecular optimization involves modifying a given molecule to improve specific desired properties. a key challenge in this task is the similarity constraint-the modified molecule must remain structurally similar to the original @xcite , which differentiates it from de novo molecular generation @xcite . in practice, this task is routinely performed by chemists through manual iterations @xcite , making it labor-intensive and difficult to scale. recent breakthroughs in large language models (llms) offer a promising alternative: llms can guide molecular optimization via natural language, enabling more scalable and automated solutions. unlike traditional supervised learning approaches @xcite , llms can reduce the dependence on labeled molecule pairs @xcite , and exhibit zero-shot and openvocabulary generalization beyond pre-defined objective sets. moreover, they can also substantially reduce training costs. early attempts explore the use of llms for molecular optimization through straightforward prompting, but report limited accuracy @xcite . building on the refinement strate-gies commonly employed by chemists, @xcite propose chatdrug, a conversational framework that guides llms in an iterative refinement loop. this loop relies on generic feedback-for example, "the modified molecule does not meet the objective"-to prompt further revisions. however, this setup has key limitations: the generic nature of the feedback causes llms to refine molecules merely toward the objective, and the method does not address molecular hallucination @xcite , where llms produce invalid molecular structures. consequently, the retrieval step is often disabled due to the high frequency of invalid outputs, diminishing its effectiveness. in this work, we propose agentdrug (figure 1 ), an agentic workflow that addresses the limitations of previous work. agentdrug designed a nested refinement loop to systematically improve both the validity and quality of the modified molecule through iterative interactions between the llm and external tools. the inner loop interacts with a cheminformatics toolkit to detect and extract parseerror messages, which serve as feedback to help the llm revise the modified molecule into a valid one. once validity is achieved, i.e., the molecule passes the inner loop, the outer loop provides both generic feedback and an explicit gradient signal to guide the llm in optimizing the molecule toward the target objective. in addition, agentdrug retrieves molecules from a prepared database based on two criteria: (1) similarity to the modified molecule and (2) satisfaction of the optimization objective. these molecules serve as in-context examples to guide the llm. with the explicit gradient, the llm gains actionable guidance analogous to gradient ascent, enabling more effective refinement. in contrast to these earlier methods, agentdrug enforces molecular validity early in its workflow, allowing the retrieval step to function more reliably and play a more impactful role in guiding optimization. ## methodology formally, molecular optimization is the task of modifying a given molecule m, expressed in the smiles string @xcite . the goal is to adjust a set of desired molecular properties @xmath0. each threshold d @xmath1, either + (indicating an increase) or -(indicating a decrease), which specifies whether the property p i should be improved or reduced. given ## evaluation following previous work @xcite , we select 500 molecules from the zinc database @xcite as input molecules. three molecular properties-logp, tpsa, and qed-are used as optimization targets. we evaluate performance et al., 2017). more experiment settings are shown in the appendix. tables 2 and 3 report results on single-and multiproperty optimization tasks under both loose (l) and strict (s) thresholds, using three refinement iterations (@xmath2. first, thanks to its inner loop, agentdrug significantly reduces the molecular hallucination, increasing the likelihood that the modified molecule is chemically valid. the performance gain of agentdrug over its ablated version, agentdrug † (without the inner loop), directly demonstrates the effectiveness of this component. the results show that agentdrug consistently outperforms chatdrug. with qwen-2.5-3b, agent-drug improves accuracy by 20.7% (loose) and 16.8% (strict) on six single-property objectives, and by 7.0% and 5.3% on eight multi-property objectives. with the larger qwen-2.5-7b, the gains increase to 28.9% and 29.0% (single-property), and 14.9% and 13.2% (multi-property), under loose and strict thresholds, respectively. notably, agentdrug † also consistently outperforms chat-drug, highlighting the value of the explicit gradient signal, even without the inner loop. while straightforward prompting achieves limited accuracy, the reinvent baseline also fails to yield meaningful improvements-despite incurring high training costs. this is largely because reinvent requires a supervised pretraining phase with labeled molecule pairs, which are often unavailable in practice. beyond accuracy, agentdrug is also more effective in preserving the similarity constraint. as illustrated in figure 2 , both agentdrug and agentdrug † explore molecular space more effectively than chatdrug, achieving better optimization while maintaining similarity, which further demonstrates the effectiveness of the gradient-guided refinement. ## conclusion this paper introduced agentdrug, a novel approach leveraging llms for zero-shot molecular optimization through gradient-guided refinement. by providing explicit gradient information during the refinement process, agentdrug enables targeted molecular modifications while maintaining similarity constraints. our comprehensive experiments show that agentdrug consistently outperforms powerful baselines on both single-and multiproperty optimization tasks. it is particularly effective for complex multi-property objectives and can balance well with optimization accuracy and molecular similarity.