MulVul: Retrieval-augmented Multi-Agent Code Vulnerability Detection via Cross-Model Prompt Evolution

Zihan Wu, Jie Xu, Yun Peng, Chun Yong Chong, Xiaohua Jia · 2026

Read MulVul: Retrieval-augmented Multi-Agent Code Vulnerability Detection via Cross-Model Prompt Evolution by Zihan Wu, Jie Xu, Yun Peng, Chun Yong Chong, Xiaohua Jia (2026) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2601-18847.txt.

Introduction

Zihan Wu and four colleagues build MulVul, a team of smart agents that hunt flaws in code. A lone model is a poor fit for the hunt. Flaw kinds are too many and too un-like: what marks one kind is noise for the next. To set a lone model for each kind by hand would take a huge store of prompt craft. The team split the hunt by kind, with one agent per group of kinds.

Each agent's prompt grows by a kind of paired growth: two models trade drafts till the prompt sharpens. A search step pulls past code that fits the kind at hand, to ground each call. A wide, sharp hunt could catch flaws that a lone tool drops. It could also scale to new flaw kinds with less hand work.

Catalog record

CREATORZihan Wu, Jie Xu, Yun Peng, Chun Yong Chong, Xiaohua Jia
YEAR2026
COLLECTIONPAPERS
FORMATTXT
FILE SIZE39 KB
VERSION1.0
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2601-18847

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

MulVul: Retrieval-augmented Multi-Agent Code Vulnerability Detection via Cross-Model Prompt Evolution Zihan Wu, Jie Xu, Yun Peng, Chun Yong Chong, Xiaohua Jia Abstract Large Language Models (LLMs) struggle to automate real-world vulnerability detection due to two key limitations: the heterogeneity of vulnerability patterns undermines the effectiveness of a single unified model, and manual prompt engineering for massive weakness categories is unscalable. To address these challenges, we propose MulVul , a retrieval-augmented multi-agent framework designed for precise and broad-coverage vulnerability detection. MulVul adopts a coarse-to-fine strategy: a Router agent first predicts the top- k k coarse categories and then forwards the input to specialized Detector agents, which identify the exact vulnerability types. Both agents are equipped with retrieval tools to actively source evidence from vulnerability knowledge bases to mitigate hallucinations. Crucially, to automate the generation of specialized prompts, we design Cross-Model Prompt Evolution , a prompt optimization mechanism where a generator LLM iteratively refines candidate prompts while a distinct executor LLM validates their effectiveness. This decoupling mitigates the self-correction bias inherent in single-model optimization. Evaluated on 130 CWE types, MulVul achieves 34.79% Macro-F1, outperforming the best baseline by 41.5%. Ablation studies validate cross-model prompt evolution, which boosts performance by 51.6% over manual prompts by effectively handling diverse vulnerability patterns. 1 Introduction Code vulnerabilities pose a fundamental threat to software reliability and security, leading to software crashes and service interruptions 18 . As modern software systems grow in complexity, manual code auditing has become increasingly expensive, time-consuming, and error-prone, motivating the need for automated vulnerability detection 5 . Recent advances in large language models (LLMs) have sparked interest in their application to vulnerability detection 19 ; 25 . Previous efforts primarily focused on single-model approaches, where a unified model is fine-tuned or prompted to identify all vulnerability types simultaneously 4 ; 14 . However, vulnerability patterns are highly heterogeneous 1 . For example, buffer overflows require reasoning about pointer arithmetic and memory bounds, while injection attacks require tracking how untrusted inputs flow into sensitive operations. As a result, a single unified detector struggles to capture these diverse, type-specific patterns within a shared latent space, leading to missed vulnerabilities or high false alarm rates. Figure 1: Comparison between MulVul and existing LLM-based vulnerability detection methods. (a) Existing methods rely on fixed prompts and lack external grounding. (b) MulVul adopts a coarse-to-fine, retrieval-augmented multi-agent framework for multi-type vulnerability detection. Inspired by the success of multi-agent systems that decompose complex tasks into specialized components 23 , a question arises: Can a multi-agent architecture enhance multi-class vulnerability detection by routing inputs to specialized experts? It is challenging to apply a multi-agent architecture for broad-coverage vulnerability detection. First, it is computationally prohibitive to invoke a specialized agent for every vulnerability type. Real-world systems involve hundreds of Common Weakness Enumeration (CWE) entries 17 . To ensure comprehensive coverage, querying every corresponding agent for each input creates an impractical inference burden. Second, manual prompt engineering becomes unscalable in multi-agent architectures. Unlike unified models, each specialized agent requires a unique instruction to capture distinct, fine-grained patterns of vulnerability. Manually optimizing prompts for such a vast number of agents is not feasible. Third, multi-agent LLM systems can amplify hallucinations. Evidence of vulnerabilities is often dispersed across complex control flows, causing agents to reason under uncertainty. If an individual agent hallucinates a flaw, this error can cascade through inter-agent communication, distorting the final consensus 9 . To address these challenges, we propose MulVul , a retrieval-augmented multi-agent framework equipped with cross-model prompt evolution for vulnerability detection. Figure 1 contrasts prior methods with MulVul. MulVul adopts a coarse-to-fine Router-Detector architecture aligned with the hierarchical structure of CWE 17 . A Router agent first predicts the Top- k coarse categories, and only the corresponding category-specific Detector agents are invoked to identify fine-grained vulnerability types in that category. This selective activation drastically reduces inference costs while maintaining high recall. Crucially, to solve the scalability bottleneck of prompt engineering, MulVul employs a Cross-Model Prompt Evolution mechanism for prompt optimization. A generator LLM (e.g., Claude) iteratively proposes prompt candidates, while an executor LLM (e.g., GPT-4o) evaluates their fitness. By decoupling prompt generation from evaluation across different LLMs, MulVul mitigates the self-correction bias inherent in single-model optimization, yielding robust and highly specialized prompts. To further mitigate hallucinations, agents actively query evidence from a SCALE-structured vulnerability knowledge base 22 to ground their reasoning. Detectors operate in isolation to prevent error amplification across agents. Experiments on the PrimeVul benchmark establish MulVul as the new state-of-the-art. Evaluated across 130 CWE types, MulVul achieves a Macro-F1 of 34.79%, surpassing the best baseline by 41.5%. With cross-model prompt evolution, MulVul significantly reduces false positives, ensuring detection accuracy. The contributions are summarized as follows: • We propose MulVul, a novel retrieval-augmented multi-agent framework for multi-class vulnerability detection. By enabling specialized agents with tool-augmented reasoning, MulVul effectively handles vulnerability heterogeneity while balancing computational efficiency with detection coverage. • We design a Cross-Model Prompt Evolution mechanism that automatically optimizes the prompts of specialized agents. By separating generation from execution, this approach mitigates self-correction bias and solves the scalability challenge of manual prompt engineering. • Comprehensive experiments show that MulVul significantly outperforms baselines with a 34.79% Macro-F1. Ablation studies confirm that our evolutionary mechanism boosts performance by 51.6% over manual prompts, demonstrating its critical role in handling diverse vulnerability patterns. 2 Related Work Learning-based vulnerability detection. Learning-based vulnerability detection has progressed from early deep learning frameworks (e.g., VulDeePecker 13 ) to neural network models that learn code representations with sequence and graph encoders 26 ; 12 ; 1 , and more recently to pre-trained code models such as GraphCodeBERT 7 and UniXcoder 6 . Recently, LLMs have dominated the field due to their strong code understanding capabilities 25 . However, existing single-model approaches face a critical challenge: a unified detector often struggles to simultaneously capture the diverse and fine-grained patterns of varying vulnerability types 14 ; 20 . While general-purpose multi-agent frameworks (e.g., AutoGen 23 , MetaGPT 9 ) show promise in task decomposition, they have not been tailored to multi-class vulnerability detection under tight cost and reliability constraints. MulVul addresses this challenge by proposing a coarse-to-fine strategy that first performs coarse-grained routing and then type-specialized identification. Prompt engineering and optimization for LLMs. To reduce the reliance on manual prompt engineering 21 , automatic optimization strategies have emerged, treating prompt generation as a search or optimization problem, such as APE 27 , EvoPrompt 8 , and OPRO 24 . A major limitation of these methods is their reliance on a single backbone for both generation and evaluation, which risks overfitting to model-specific biases and limits transferability across LLMs. We address this by proposing Cross-Model Prompt Evolution, which decouples the generator and executor. This separation provides unbiased feedback, facilitating the discovery of robust instructions that generalize more effectively across vulnerability types. Retrieval-augmented generation and hallucination mitigation. Retrieval-augmented generation (RAG) effectively grounds LLMs to mitigate hallucinations 11 , with applications extending to code completion and repair 15 . However, standard code retrieval often focuses on syntactic similarity, which is insufficient for distinguishing subtle security flaws. MulVul advances this by leveraging SCALE-based structured semantic representations 22 and implementing a contrastive retrieval strategy. The Router utilizes broad evidence to identify categories, while

Read the complete text