Abstract
Molecular editing is a critical task in drug discovery, requiring the optimization of chemical properties while preserving the structural integrity of a lead compound. While Large Language Models (LLMs) show promise in processing chemical information via SMILES strings, they often suffer from molecular hallucination and imprecise steering. We present AgentDrug, an agentic workflow that treats molecular editing as a multi-stage refinement task. By integrating a nested loop that combines cheminformatics-based validity checks with natural language "gradient" feedback, AgentDrug significantly enhances the zero-shot capabilities of general-purpose LLMs. Our results demonstrate that AgentDrug outperforms existing iterative methods and specialized reinforcement learning models, achieving substantial gains in accuracy and structural similarity across various chemical property targets.
Introduction
In the early stages of drug discovery, researchers must refine "hit" molecules to improve specific properties such as solubility (LogP), drug-likeness (QED), or topological polar surface area (TPSA). Traditionally, this process relies on expert intuition or supervised AI models trained on vast datasets of labeled molecule pairs. While LLMs offer a flexible alternative, their application is hindered by two primary issues: the generation of chemically invalid SMILES strings and the lack of precise directional guidance in standard prompting.
AgentDrug addresses these hurdles by framing molecular optimization as an iterative debugging process. Unlike previous methods that rely on vague feedback, AgentDrug provides explicit, domain-informed signals to steer the model toward numerical property thresholds without requiring task-specific fine-tuning.
The AgentDrug Framework
AgentDrug utilizes a nested refinement loop to ensure both the chemical validity and the functional performance of generated molecules. This architecture distinguishes it from simpler iterative approaches like ChatDrug.
Nested Refinement Loops
- The Inner Loop (Validity): To combat molecular hallucination, AgentDrug employs RDKit, a standard cheminformatics toolkit, to parse every LLM output. If a
ParseError(such as valence violations or unclosed rings) is detected, the specific error is fed back to the LLM for immediate correction. This ensures that the optimization process only proceeds with chemically plausible structures. - The Outer Loop (Optimization): Once a molecule is validated, its properties are evaluated. If the target threshold is not met, the system generates a natural language gradient. Instead of generic instructions, the LLM receives precise directional feedback, such as "Increase LogP by at least 0.66."
- In-Context Retrieval: To provide structural guidance, the workflow retrieves "gold standard" molecules from the ZINC database that already satisfy the target properties, using them as reference examples within the prompt.
Experimental Evaluation
The framework was evaluated using 500 molecules sampled from the ZINC database, targeting LogP, TPSA, and QED metrics. The researchers tested AgentDrug against benchmarks using state-of-the-art LLMs, including Qwen-2.5 and Llama-3.1.
Key Results
- Accuracy Improvements: Utilizing the Qwen-2.5-7B model, AgentDrug achieved a 28.9% improvement in accuracy for single-property tasks and a 14.9% improvement for multi-property tasks compared to standard iterative prompting.
- Zero-Shot Superiority: AgentDrug outperformed REINVENT, a specialized reinforcement learning baseline, despite requiring no task-specific training. This highlights the efficiency of using domain feedback to steer general-purpose models.
- Structural Fidelity: The workflow demonstrated a superior ability to balance property optimization with structural similarity, a key requirement for medicinal chemistry where the core scaffold of a molecule must often remain intact.
Discussion and Future Work
AgentDrug represents a significant step forward in zero-shot molecular engineering. By enforcing chemical validity as a prerequisite for optimization, it makes retrieval and property steering far more reliable. However, the iterative nature of the workflow increases inference costs and latency compared to single-shot models.
Future research may focus on incorporating more "actionable" chemical feedback—such as suggesting specific functional group additions or removals—and reducing the dependency on external databases for in-context examples. Despite these challenges, AgentDrug provides a robust template for integrating domain-specific tools with LLMs to solve complex scientific tasks.
Summary updated