Co-Evolving Agents: Learning from Failures as Hard Negatives

Yeonsung Jung, Trilok Padhi, Sina Shaham, Dipika Khullar, Joonhyun Jeong, Ninareh Mehrabi, Eunho Yang

TL;DR

Self-improving LLM agents often overfit when learning from their own raw failure trajectories due to weak contrastive signals. This paper introduces a co-evolving framework where an auxiliary "failure agent" is trained specifically to generate high-reward, near-success "hard negatives." By training the target agent against these sophisticated failures, the framework establishes an implicit arms race that significantly sharpens decision boundaries and improves generalization across complex multi-turn tasks.

What Problem Does This Paper Address?

Building task-specialized LLM agents typically requires high-quality, human-curated training data, which is expensive and labor-intensive to scale. To bypass this bottleneck, recent approaches use self-improvement strategies like Direct Preference Optimization (DPO), pairing an agent's self-generated failures against scarce expert trajectories.

However, standard self-improvement methods rely on raw failure trajectories. In challenging, multi-turn environments, these raw failures are often "shallow"—the agent fails immediately, gets stuck in simple loops, or issues invalid actions. These low-quality failures offer weak contrast to expert behavior, causing the target model to overfit to a small set of successful demonstrations rather than developing a robust, fine-grained understanding of the task landscape.

Methods

The authors propose a co-evolving agents framework consisting of two models initialized from the same base policy via Supervised Fine-Tuning (SFT): a Target Agent and an Auxiliary Failure Agent.

Figure 1. Overview of our co-evolving agents framework. The failure agent learns from pairs of failure trajectories and produces hard negatives, i.e., high-reward failures that lie close to success. These hard negatives are then incorporated into the target agent’s preference optimization, providing more informative contrastive signals. Through this mutual interaction, the two agents co-evolve, enabling the target agent to learn sharper decision boundaries and achieve stronger generalization.
  • The Failure Agent: Instead of optimizing for success, this agent specializes in modeling the failure landscape. It is trained via DPO using a preference dataset composed entirely of failure trajectories from both agents. Crucially, within this dataset, a higher-reward failure (a near-miss) is preferred over a lower-reward failure (a total flop). This forces the failure agent to generate "hard negatives"—trajectories that execute complex sub-skills and get close to success but ultimately fail.
  • The Target Agent: The target agent is optimized using a weighted DPO objective combined with an auxiliary SFT loss on chosen trajectories to anchor the policy and stabilize training. Its preference dataset combines expert demonstrations with the informative hard negatives generated by the failure agent.
  • Co-evolutionary Loop: Training alternates between the two agents. This creates an implicit arms race: the failure agent continually generates harder, more deceptive negatives, while the target agent learns to overcome them, refining its preference landscape.

Datasets

The framework was evaluated on three complex, multi-turn benchmarks that provide continuous final rewards in $[0, 1]$, enabling fine-grained evaluation:

  1. WebShop: A web navigation and e-commerce environment where agents must find and purchase items matching specific natural language constraints (attributes, price, etc.).
  2. ScienceWorld: A text-based embodied environment for elementary science experiments (e.g., thermodynamics, growing plants) requiring long-horizon planning.
  3. InterCodeSQL: An interactive environment for translating natural language questions into executable SQL queries using execution feedback.
Overview of the benchmark statistics

Key Insights and Ideas

  • Failures are Not Created Equal: Raw failures often contain zero useful information (e.g., spinning in circles). By optimizing an auxiliary agent purely to explore the "near-miss" space, failures can be systematically transformed into structured, high-quality learning signals.
  • The Power of an Adversarial Arms Race: Alternating the optimization of a success-driven agent and a failure-driven agent prevents the target agent from collapsing into simple modes. The failure agent acts as a dynamic adversary that constantly probes and sharpens the target agent's decision boundaries.
  • Capturing Sub-Skills: Qualitative analysis shows that hard negatives often successfully execute 90% of a complex pipeline (like collecting soil, preparing pots, and regulating greenhouse doors) before failing on a minor final step. Learning from these "high-reward failures" teaches the target agent crucial intermediate sub-skills that standard failures completely miss.

Key Results

The co-evolving framework consistently outperformed strong baselines—including SFT, Rejection Fine-Tuning (RFT), PPO, and Exploration-Based Trajectory Optimization (ETO)—across multiple model architectures.

Statistics of generated trajectories
  • Performance Boosts: On Llama-2-7B-Chat, the proposed method achieved an average reward of 64.1, outperforming the strong DPO baseline (ETO) by +5.8%. The gains were particularly pronounced on unseen scenarios in ScienceWorld (+6.5%), demonstrating superior generalization.
  • Architecture Scaling: On Qwen3-4B-Instruct, the method boosted the average reward to 66.3 (a +6.8% improvement over ETO). It also showed consistent scaling benefits on Llama-2-13B.
  • Trajectory Quality & Diversity: Quantitative analysis confirmed that the failure agent produced significantly more high-reward hard negatives (e.g., a 14.1% hard negative rate in ScienceWorld vs. ETO's 5.4%). Embedding analysis showed these trajectories were substantially more diverse, exploring a broader failure space rather than collapsing to narrow modes.
Figure 2. Diversity analysis.

Limitations and Future Work

  • Computational Footprint: The method requires alternating training phases and generating rollouts from two separate agents, which increases the computational overhead during the self-improvement phase.
  • Single Rollout Exploration: Due to the high cost of long, multi-turn trajectories, the authors performed only a single rollout per instruction during exploration. Multi-sampling during the failure generation phase could potentially yield even richer data.
  • Dependence on Reward Functions: The framework relies on the environment providing a fine-grained or continuous reward signal to distinguish between higher- and lower-reward failures. Extending this to environments with purely binary or sparse rewards remains an open challenge.

Summary updated

BibTeX
@misc{jung2025co,
  author = {Yeonsung Jung and Trilok Padhi and Sina Shaham and Dipika Khullar and Joonhyun Jeong and Ninareh Mehrabi and Eunho Yang},
  title = {{Co-Evolving Agents: Learning from Failures as Hard Negatives}},
  year = {2025},
  eprint = {2511.22254},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2511.22254},
}
Figure