From LLMs to Agents: A Comparative Evaluation of LLMs and LLM-based Agents in Security Patch Detection

Junxiao Han, Zheng Yu, Lingfeng Bao, Jiakun Liu, Yao Wan, Jianwei Yin, Shuiguang Deng, Song HanarXiv 2025 · DOI

Abstract

This paper presents a systematic evaluation of Large Language Models (LLMs) and agentic workflows for identifying security patches in open-source software. By comparing baseline LLMs, data-augmented models, and autonomous agents using the ReAct framework, the study identifies critical trade-offs between detection accuracy and false positive rates. Findings indicate that while data augmentation maximizes overall performance, agentic workflows are superior at minimizing false positives, offering a potential solution to alert fatigue in security operations.

Introduction

Open-source software (OSS) security is frequently compromised by "silent patches"—vulnerability fixes committed without public disclosure, often hidden among routine updates. Manually auditing these commits is labor-intensive, and traditional automated tools often suffer from high False Positive Rates (FPR), leading to developer alert fatigue. This research investigates the potential of LLMs and autonomous agents to accurately distinguish security patches from non-security code changes by reasoning through code diffs and metadata.

Methodology

The researchers evaluated three distinct architectural approaches across several state-of-the-art models, including GPT-4o, DeepSeek-R1, Llama-3.1, and Gemma-3.

System architecture overview showing dataset preparation, input types, models, and the three evaluated workflows: Plain LLM, Data-Aug LLM, and ReAct Agent.
  1. Plain LLM: A baseline where the model receives only the raw code diff and a standard system prompt.
  2. Data-Aug LLM: Enhances the input with additional context, including commit messages, CVE identifiers, and CWE categories.
  3. ReAct Agent: An agentic workflow utilizing a "Thought-Action-Observation" loop. The agent can invoke tools like get_diff_analysis and get_diff_message to iteratively gather information before reaching a conclusion.
The ReAct Agent prompt template, illustrating the Thought-Action-Observation loop and available tools.

The study utilized PatchDB, a large-scale dataset containing 12,000 real-world security patches and 23,000 non-security samples, covering diverse vulnerability types such as Input Validation (CWE-20) and Authorization Management (CWE-264).

Key Results and Insights

The evaluation revealed several critical findings regarding model performance and reasoning strategies:

  • Contextual Importance: The Data-Aug LLM method consistently outperformed the Plain baseline, achieving the highest average precision (81.67%) and F1 score (56.14%). This highlights that developer intent, captured in commit messages, is as vital as the code changes themselves.
  • Agentic Skepticism: The ReAct Agent achieved the lowest False Positive Rate (FPR), dropping as low as 9.6% in some configurations. By requiring iterative "thought" and "action," the agent acts as a rigorous filter, effectively reducing the FPR from over 45% (seen in traditional baselines like PatchFinder) to approximately 14%.
  • Prompting Strategies: Chain-of-Thought (CoT) prompting provided the most significant performance boost across most models compared to Few-Shot (FS) examples.
  • Model Capabilities: Commercial models (GPT-4o, DeepSeek-R1) demonstrated superior reasoning capabilities in security contexts compared to open-source models like Llama-3.1 and Gemma-3.

Discussion and Future Work

While promising, the study notes limitations, such as the focus on C/C++ patches and the challenges posed by real-world class imbalances. Future research should explore "Mixture of Experts" (MoE) architectures and the integration of structured code representations like Abstract Syntax Trees (ASTs) to capture deeper logic.

Conclusion

Transitioning from simple LLM prompts to agentic workflows significantly improves the reliability of security patch detection. By minimizing false positives, autonomous agents provide a viable path toward reducing alert fatigue and securing the open-source ecosystem.

Summary updated

BibTeX
@misc{han2025from,
  author = {Junxiao Han and Zheng Yu and Lingfeng Bao and Jiakun Liu and Yao Wan and Jianwei Yin and Shuiguang Deng and Song Han},
  title = {{From LLMs to Agents: A Comparative Evaluation of LLMs and LLM-based Agents in Security Patch Detection}},
  year = {2025},
  eprint = {2511.08060},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2511.08060},
}
Figure