Large Language Model (LLM) safety training is currently stuck in a reactive loop. Defenders typically train models on static datasets of known "jailbreaks"—prompts explicitly designed to bypass safety filters. However, malicious actors are constantly evolving, moving from simple role-playing tricks to automated, multi-turn deceptions. Because traditional defenses rely on fixed data distributions, they frequently fail to generalize to novel, out-of-distribution attack patterns. This creates a "passive patching" cycle where defenders are perpetually one step behind.
To break this cycle, researchers have introduced MAGIC (Multi-Agent Adversarial Game for Improving safety and Compliance), a multi-agent reinforcement learning framework that treats LLM safety as a co-evolving game between an attacker and a defender. By allowing these agents to iteratively adapt to one another, the defender learns to resist complex "long-tail" vulnerabilities that static safety training misses, all while maintaining the model's general helpfulness.
The MAGIC Framework: A Co-Evolving Game
The core innovation of MAGIC is formulating safety alignment as an asymmetric sequential game rather than a symmetric self-play scenario. Previous "self-play" methods often use a single model for both offensive and defensive roles, which leads to gradient conflicts because the objectives are diametrically opposed. MAGIC decouples the agents and targets a Subgame Perfect Nash Equilibrium (SPNE), providing a theoretical guarantee that the defender will provide a safe response to every prompt, rather than just being safe "on average."
The framework operates in two distinct phases:
1. Offensive Capability Initialization (SFT)
To avoid a "cold-start" problem where the attacker is initially too weak to challenge the defender, the authors first fine-tune the attacker model on a new Attack Pool Benchmark. Using Chain-of-Thought (CoT) data, this phase teaches the attacker how to reason about rewriting harmful queries into deceptive ones.
2. Iterative Co-evolution (RL)
The framework then employs Group Relative Policy Optimization (GRPO) to alternate between two optimization steps:
- Defender Optimization: The attacker's policy is frozen, and the defender learns to recognize and refuse the attacker's increasingly clever prompts.
- Attacker Optimization: The defender is frozen, and the attacker learns to bypass the defender's newly updated safeguards.
Key Discoveries: Emergent Strategies and Reasoning
One of the most striking findings of the MAGIC framework is the power of "offensive reasoning." By giving the attacker a thought process (via <think> tags), it stops merely following rigid templates and begins actively planning. It can analyze why a previous prompt might have been blocked and strategically "soften" its language or add layers of obfuscation.
Through this iterative RL training, the attacker evolved novel combinatorial strategies that were not present in its initial training data. For example, the attacker learned to combine "Role-play" with "Translation" (e.g., asking for a dangerous recipe in French while pretending to be a fictional character) to maximize the probability of a successful jailbreak.
Crucially, MAGIC successfully avoids the "over-safety" trap. A common failure mode in safety training is over-refusal, where a model becomes so overly cautious that it refuses to answer benign questions (e.g., "How do I kill a computer process?"). MAGIC utilizes a specific Refusal Reward to penalize the defender for rejecting safe queries, maintaining a strict balance between safety and utility.
Performance and Results
Extensive experiments demonstrate that MAGIC provides state-of-the-art defense capabilities without lobotomizing the model:
- Dramatic Safety Improvements: On the Qwen2.5-7B-Instruct model, MAGIC reduced the Attack Success Rate (ASR) on the WildGuardTest benchmark from 36.5% to just 2.3%.
- Superior Generalization: The MAGIC-trained defender proved highly robust against "unseen" automated attackers like GCG, PAIR, and TAP, outperforming other leading defenses such as Self-RedTeam.
- Preserved Intelligence: Unlike many safety-tuned models, MAGIC models showed virtually no degradation on general capability benchmarks like MMLU, ARC-C, and GPQA. In some cases, the iterative training even slightly improved instruction-following scores (IFEval).
- Multi-turn Robustness: In multi-turn agentic attack scenarios (evaluated via X-Teaming), MAGIC improved the defense success rate by 10.1% compared to the base model.
Limitations and Future Directions
While highly effective, the MAGIC framework comes with computational overhead, as running a multi-agent RL loop with alternating optimization is significantly more expensive than standard SFT or single-agent RL. Furthermore, the success of the co-evolution is highly sensitive to the quality of the initial offensive SFT; if the starting attacker is too weak, the defender fails to learn meaningful robustness.
The authors also acknowledge a dual-use risk: a highly capable attacker model developed through this framework could potentially be misused to probe vulnerabilities in other deployed LLMs. Looking ahead, the researchers suggest extending MAGIC to multimodal settings (images and audio) and tool-use environments, where safety risks are even more complex and difficult to patch passively.
Summary updated