AgentSafeEvo: Adversarial Co-Evolution for LLM Agent Safety
Organizations: Shanghai Artificial Intelligence Laboratory · Fudan University · Shanghai Jiaotong University · Zhejiang University
Abstract
Large language model (LLM) agents accomplish complex tasks through multi-turn interactions with external tools. However, malicious content embedded in user queries, tool descriptions, or environment observations can manipulate their decisions and induce unsafe actions. Adversarial co-evolution has emerged as an effective approach to strengthening LLM safety, but existing work primarily focuses on language-level safety or indirect prompt injection in web tasks. In this paper, we introduce AgentSafeEvo, a co-evolutionary reinforcement learning framework for agent safety built on an attacker-defender game spanning diverse tasks and attack types. The attacker learns to construct adversarial agent tasks that expose weaknesses in the defender's tool use, while the defender learns to complete tasks safely under these attacks. We further introduce learnability-guided task weighting, which uses within-task defender-reward variability to adjust each task's contribution to attacker and defender updates. Extensive experiments on agent safety and general capability benchmarks demonstrate that our method improves adversarial robustness while maintaining general agent capabilities.
Figures & tables
| Agent-SafetyBench | AgentHarm | AgentDojo | MSB | |||
|---|---|---|---|---|---|---|
| Method | ||||||
| Qwen3-8B | ||||||
| + Spotlighting | ||||||
| + Prompt Guard 2 | ||||||
| + Static-AT | ||||||
| + AgentSafeEvo (ours) | ||||||
| Method | BFCL-V3 | ALFWorld | ToolHop |
|---|---|---|---|
| Qwen3-8B | |||
| + Spotlighting | |||
| + Prompt Guard 2 | |||
| + Static-AT | |||
| + AgentSafeEvo (ours) |
| Method | Safety | General | |||
|---|---|---|---|---|---|
| Agent-SafetyBench | MSB | ALFWorld | ToolHop | ||
| AgentSafeEvo (ours) | |||||
| w/o attacker updates | |||||
| w/o learnability weighting | |||||
| w/o defender weighting | |||||
Appendix figures & tables6 assets
Supplementary material from the paper’s appendix.
Appendix
| Information Retrieval Weather, Search, Knowledge, News | Language and Documents Document, Language, Writing |
| Planning and Logistics Travel, Navigation, Event, Scheduling, Logistics | Computation and Coding Math, Conversion, Coding |
| Science and Environment Science, Agriculture, Environment | Data and Research Data, Analytics, Reporting, Research |
| Business Operations Finance, Crypto, Market Research, Sales, Procurement, Project | Communication and Support HR, Customer Service, Communication, Social Media, Marketing |
| Creative Media Design, Media, Entertainment, Gaming | Education and Healthcare Education, Healthcare, Food |
| IT and Infrastructure IT Operations, Cloud, Automation, Engineering, Facility | Security and Compliance Compliance, Audit, Cybersecurity, Physical Security, Emergency |
| Operation class | Included operations |
|---|---|
| Information Retrieval | Search external sources, retrieve records, look up knowledge, list resources, and fetch current information |
| Computation | Perform arithmetic, solve equations, calculate statistics, and evaluate structured expressions |
| Language Processing | Translate, summarize, extract, analyze, and modify textual content |
| Format and Unit Conversion | Convert measurement units, time zones, file formats, and structured values |
| Content Generation | Generate text, images, drawings, audio, video, and other media content |
| Data Management | Create, read, update, delete, store, and organize files, databases, or structured records |
| Type | Subtype | Description |
|---|---|---|
| DPI | Unauthorized tool invocation | Direct instructions in the user query cause the agent to invoke additional tools or perform actions beyond the original task. |
| Response manipulation | Direct instructions in the user query control the final response without requiring any additional tool invocation. | |
| Parameter manipulation | Direct instructions alter tool arguments such as recipients, destinations, targets, scopes, permissions, or verification settings. | |
| IPI | Unauthorized tool invocation | Instructions embedded in external content cause the agent to perform unauthorized tool calls after retrieving or processing that content. |
| Response manipulation | Instructions embedded in external content control the final response while leaving the original tool-execution trace unchanged. | |
| TDI | Capability overstatement | A manipulated tool description exaggerates the capability, authority, or applicability of a tool and induces unjustified downstream actions. |
| Setting | Value |
|---|---|
| Maximum sequence length | 16384 |
| Batch size | 8 |
| Learning rate | |
| Training epochs | 2 |
| Warmup ratio | 0.03 |
| Distributed strategy | DeepSpeed ZeRO-3 |
| Setting | Value |
|---|---|
| Learning rate | : : |
| Number of rollouts | : 5 : 8 |
| GPUs per role | 4 |
| Training steps | 120 |
| Training batch size | 64 |
| Task weighting coefficient | 0.5 |
LLM Agent Safety
Large language model agent safety studies how to keep tool-using, persistent, and multi-agent systems aligned with user intent and authorized limits.
See all 302 papers