Coding agents can adapt robotic software by revising executable programs, but successful responses to an evolving opponent may not remain effective. We present a framework for program-level adversarial co-adaptive self-play in which coding agents generate attacks and defenses from tested opponent code and mission feedback, without model fine-tuning. Environment-specific interfaces support external programs for autonomous driving and SDK-level defenses for humanoid locomotion. Two eight-generation case studies reveal concrete software responses: a driving defender introduces direct-actuation recovery, while a humanoid defender revises incoming-state validation. These responses provide local task recovery but do not establish sustained robustness. The framework makes such adaptation and limitations observable through executable artifacts and task-level evidence.
Figures & tables
Figure 1: Program-level adversarial co-adaptation. Coding agents develop attack and defense programs that are checked, frozen, and evaluated in Autoware-CARLA or G1-MuJoCo. Independent referees judge outcomes from simulator ground truth; results and tested opponent code guide the next generation.
Driving
Humanoid
Task
60 m clear-road route
3 m flat-ground walk
Robot software
Autoware in CARLA
G1 policy + navigation in MuJoCo
Coding harness
Claude Code / Opus
Claude Code / Sonnet
Agent budget
40 min per session
60 min per session
Attacker roles
Five fixed
Five orchestrated
Joint episode repetitions
One per attacker
Three per attacker
Table 1: Evaluated configurations. Each uses one eight-generation run and one shared defender per generation.
Figure 2: Driving. A crash, collision, or off-road event results in an attacker win; successful completion results in a defender win; and a timeout results in a tie.
Figure 3: Humanoid. Each box summarizes an orchestrator-assigned task, grouped by attack type. Solid arrows show continuation of a strategy while dashed arrows show borrowed mechanisms. Blue marks eligible matchups where the median of the three joint-episode recovery scores is 1; red marks the remaining eligible matchups. Gray marks attacks that do not disrupt attack-only execution and are excluded from scoring.
Figure 4: Driving. Each column progresses from top to bottom, pairing the Autoware visualization (left) with the simulated vehicle (right). (a) the attacker overwhelms the defender with competing steering commands; (b) the defender mitigates fabricated vehicle detections; (c) a false arrival signal prevents mission completion; (d) the attacker progressively reduces the speed limit to 0 km/h.
Figure 5: Humanoid. Each column progresses from top to bottom. The red marker indicates the goal. (a) IMU spoofing causes a fall without defense; (b) the defender mitigates the same attack; (c) Position drift sends the robot off-route; (d) Combined sensor spoofing and motor-command injection and (e) competing actuator commands both cause falls.
Thompson's "Reflections on Trusting Trust" showed that a compiler can be poisoned to reinsert its own backdoor, so that even recompiling clean source reproduces the Trojan. Today, substantial coding work is done by AI coding agents -- and increasingly, those agents generate new versions of themselves. We reconsider Thompson's attack when the "compiler" is a self-modifying coding agent. Can an adversary supply poisoned benchmarks to the agent's self-evaluation and self-improvement process to induce future versions of the agent to write vulnerable code on clean, held-out tasks? We instantiate this attack against three recently proposed self-modifying coding agents: the Darwin Gödel Machine (with our experimental modifications), the Self-Improving Coding Agent, and Hyperagents (both substantively unmodified). We demonstrate successful proofs-of-concept: for example, with Hyperagents powered by Sonnet 4.5, our poisoned benchmark leads the agent to self-evolve instructions that disable HTTPS certificate validation on neutral URL-fetching tasks. From our experiments, we distill properties of the vulnerability, benchmark, model, and agent scaffolding that are sufficient to enable a benchmark poisoning attack. Moreover, we show that contamination often persists even when a poisoned agent is subsequently evolved against clean benchmarks. We discuss defensive directions and argue that self-modifying coding agents must be designed to be more resilient to such attacks.
To keep coding agents from going off the rails, production systems now review each proposed action with a blocking monitor that can reject it before it runs (Auto Mode in Claude Code, Guardian in OpenAI's Codex). Prior evaluations of such monitors largely measure robustness to accidental harm or prompt injections from untrusted sources looking to hijack the agent. Less understood is how they hold up when the agent they monitor is persistently misaligned. To understand this risk, we task an adversarial agent with evading production blocking monitors and causing catastrophic harm, e.g. by exfiltrating its own weights. We find that when instructed with high-level attack strategies, adversarial agents can succeed through several distinct mechanisms, such as agent-generated prompt injection against the monitor, multi-agent attacks, and malicious compaction. In particular we find that in 79% of trials, the agent can use an injection attack against Auto Mode and Guardian to run arbitrary bash commands. We also find that it is possible to greatly improve Auto Mode through design changes like enhancements to tool coverage, changes in transcript formatting, and the addition of an agentic monitor stage. Even with these improvements, preventing multi-context attacks at an acceptable cost remains an open problem. By detailing our red-teaming methodology and highlighting new attack vectors, we aim to help defenders evaluate their mitigations against the possibility of persistent malign coding agents. Code is available at https://github.com/safety-research/red-teaming-auto-mode.
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.
Chenxu Wang, Xiaoyu Wen, Han Qi +4
Shanghai Artificial Intelligence Laboratory · Fudan University · Shanghai Jiaotong University +1