MAGIC: A Co-Evolving Attacker-Defender Adversarial Game for Robust LLM Safety

Xiaoyu Wen, Zhida He, Han Qi, Ziyu Wan, Zhongtian Ma +5 more
2/2/2026
cs.AIcs.CLcs.LG

No official code found. Best implementation: AI45Lab/MAGIC (57 stars, Apache-2.0, last commit 2026-03-24).

Abstract

Ensuring robust safety alignment is crucial for Large Language Models (LLMs), yet existing defenses often lag behind evolving adversarial attacks due to their \textbf{reliance on static, pre-collected data distributions}. In this paper, we introduce \textbf{MAGIC}, a novel multi-turn multi-agent reinforcement learning framework that formulates LLM safety alignment as an adversarial asymmetric game. Specifically, an attacker agent learns to iteratively rewrite original queries into deceptive prompts, while a defender agent simultaneously optimizes its policy to recognize and refuse such inputs. This dynamic process triggers a \textbf{co-evolution}, where the attacker's ever-changing strategies continuously uncover long-tail vulnerabilities, driving the defender to generalize to unseen attack patterns. Remarkably, we observe that the attacker, endowed with initial reasoning ability, evolves \textbf{novel, previously unseen combinatorial strategies} through iterative RL training, underscoring our method's substantial potential. Theoretically, we provide insights into a more robust game equilibrium and derive safety guarantees. Extensive experiments validate our framework's effectiveness, demonstrating superior defense success rates without compromising the helpfulness of the model. Our code is available at https://github.com/BattleWen/MAGIC.

View on arXivView PDF

Code Implementations(1)

AI45Lab/MAGICCommunity71%
Apache-2.0

Code for paper "MAGIC: A Co-Evolving Attacker-Defender Adversarial Game for Robust LLM safety"

574HTML, ShellJan 30, 20267 months agoApache-2.0

Similar Papers

Cite this paper

@article{wen2026magic,
  title  = {MAGIC: A Co-Evolving Attacker-Defender Adversarial Game for Robust LLM Safety},
  author = {Xiaoyu Wen and Zhida He and Han Qi and Ziyu Wan and Zhongtian Ma and Ying Wen and Tianhang Zheng and Xingcheng Xu and Chaochao Lu and Qiaosheng Zhang},
  year   = {2026},
  eprint = {2602.01539},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2602.01539v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2602.01539.svg)](https://codeofpaper.com/paper/2602.01539)

Discussion