Lune

WWW2026Top-tier venue

Mitigating Cognitive Vulnerabilities in Code Generation via Multi-Agent Adversarial Debate

Shuofu Liu, Quanjiang Guo, Xiao Liu, Ying Liu

Abstract

Although Large Language Models (LLMs) have demonstrated significant proficiency in code generation, their monolithic and correlation-driven nature renders them susceptible to systematic cognitive biases, deficient counterfactual reasoning, and adversarial manipulation—a characteristic we term cognitive vulnerability. Such vulnerabilities compromise the reliability and security of AI-assisted software development, potentially resulting in code that is not only functionally incorrect but also biased, insecure, and difficult to validate using conventional testing paradigms. While recent multi-agent systems enhance workflow efficiency via task decomposition, they do not fundamentally address these reasoning deficits. This highlights the need for a framework capable of proactively identifying and mitigating the cognitive flaws of an LLM during the reasoning process. To address this challenge, we introduce CodeForge, a multi-agent adversarial reasoning framework that reframes code generation as a cognitive crucible. This process involves a structured debate among three specialized agents—an Optimist, a Pragmatist, and an Adversarial Skeptic—who iteratively cross-examine and refine solution plans. Following convergence, an adversarial verification module systematically generates counterfactual perturbations to stress-test and enhance the final plan. Comprehensive evaluations on the HumanEval and MBPP benchmarks demonstrate that CodeForge significantly outperforms state-of-the-art methods, achieving a pass@1 of 97.3% with GPT-4. Ablation studies confirm the necessity of both the adversarial dialogue and counterfactual verification components. This work represents a shift from passive debugging to proactive cognitive hardening, establishing a pathway toward more trustworthy automated software engineering.

Ask Lune

Know where this paper stands in minutes, not an afternoon.

Lune can read the top-tier papers that cite it and the ones closest to it, and tells you what it claims, what came after and where it falls short, each point cited to the paper it comes from. No skimming, no AI slop.

Questions to start from

Lune can draw on

its abstract · related work

Get the answer

Free to start. No credit card required.

Related papers

  1. Three Heads Are Better Than One: A Multi-perspective Reasoning Framework for Enhanced Vulnerability DetectionXin Peng, Bo Lin, Jing Wang, Xiaoling Li et al.FSE 2026 · 1 citation
  2. AI-for-Science Low-code Platform with Bayesian Adversarial Multi-Agent FrameworkZihang Zeng, Jiaquan Zhang, Pengze Li, Yuan Qi et al.ICLR 2026
  3. AdverMCTS: Combating Pseudo-Correctness in Code Generation via Adversarial Monte Carlo Tree SearchQingyao Li, Weiwen Liu, Weinan Zhang, Yong Yu et al.ICML 2026
  4. A.S.E: A Repository-Level Benchmark for Evaluating Security in AI-Generated CodeKeke Lian, Wang Bin, Lei Zhang, Libo Chen et al.ACL Findings 2026 · 3 citations
  5. Cognitive Biases in LLM-Assisted Software DevelopmentXinyi Zhou, Zeinadsadat Saghi, Sadra Sabouri, Rahul Pandita et al.ICSE 2026
Dusk over the sea between two cliffs drawn in fine vertical lines