SHE: Trajectory-driven Safety Harness Evolution for LLM Agents

Wanying Qu, Qinghua Mao, Yu Li, Jiyao Liu, Xin Zhang, Dadi Guo, Yanxu Zhu, Qingyu Liu, Leitao Yuan, Xi Lin, Shanfeng Zhu, Yanwei Fu, Jing Shao, Xia Hu, Dongrui LiuarXiv 2026

TL;DR

Safety Harness Evolution (SHE) is a novel framework that automatically improves the safety of LLM agents by learning from their execution failures. By decoupling the agent's "harness" (the system prompt, rules, memory, and tool policies) into distinct, editable components, SHE uses an automated feedback loop to diagnose failures and refine safety boundaries without sacrificing task utility.

What Problem Does This Paper Address?

When we deploy Large Language Model (LLM) agents in complex environments, their behavior isn't just determined by the model's weights. It is heavily mediated by an agent harness—the scaffolding that manages system prompts, memory retrieval, tool permissions, and runtime constraints.

Currently, safety mechanisms treat this harness as a static, human-designed artifact. If an agent fails safely during a task, it cannot automatically learn from that trajectory. Furthermore, existing harnesses tightly couple their functions. For instance, if an agent leaks sensitive data, it's hard to pinpoint whether the failure was due to a bad system prompt, an unblocked tool call, or a flaw in memory filtering. Modifying one part often inadvertently breaks another, leading to a frustrating trade-off between safety and utility.

Figure 1: Motivation of Safety Harness Evolution (SHE). SHE decouples the safety harness into editable artifacts, enabling targeted diagnosis and localized evolution.

Methods

The authors introduce Safety Harness Evolution (SHE), a framework that treats agent safety as an evolving architectural property. SHE relies on two core designs:

  1. Artifact-Level Decomposition: SHE breaks the harness down into four distinct components, each with explicit safety responsibilities:
  2. System Prompt: Defines global behavioral contracts and trust boundaries.
  3. Rule Bank: Stores structured safety rules for filtering inputs and actions.
  4. Safety Memory: Captures contrastive experiences from hard-to-resolve failures.
  5. Tool Policy: Enforces runtime authority over tool calls and observations.
  6. Attribution-Driven Evolution Loop: Instead of rewriting the entire harness at once, SHE uses an iterative optimization loop driven by an external LLM (like GPT-5.5):
  7. Structured Risk Diagnosis: Analyzes failed trajectories across three dimensions: harm domain, attack surface, and failure mode.
  8. Harness Artifact Routing: Pinpoints exactly which of the four components is responsible for the failure.
  9. Bounded Editing & Validity Checking: Proposes localized fixes to the responsible component while ensuring the edit doesn't introduce "reward-hacking" or over-refusal.
  10. Best-Harness Selection: Evaluates the candidate harness on a validation set, accepting the update only if it improves safety while maintaining or improving task utility.
Figure 2: Overview of Safety Harness Evolution (SHE). SHE decomposes the safety harness into four functionally bounded artifacts and evolves them from rollout trajectories. Trajectory evidence is diagnosed, routed to responsible artifacts, converted into learned safe-boundary refinements, and retained through safety–utility selection.

Datasets

The framework was developed and evaluated using two primary benchmarks:

  • Agent-SafetyBench: Used for the evolution process and held-in evaluation. It features safety-critical tasks evaluated under a clean condition and five distinct attack vectors (context poisoning, indirect injection, tool tampering, memory injection, and composite attacks).
  • AgentHarm: A completely held-out benchmark focusing on multi-step agent misuse across 11 harm categories, used to test how well the evolved harness generalizes to completely unseen risks.

Key Insights and Ideas

  • Decoupling is Essential for Evolution: The "aha moment" of the paper is that you cannot effectively evolve a coupled safety system. When components are isolated (as in SHE), localized edits successfully patch safety holes without causing regressions in benign task performance.
  • Cross-Model Transferability: Remarkably, a safety harness evolved using one base model (e.g., DeepSeek-V3.2) can be directly plugged into entirely different models (like Kimi K2.6 or GLM-5.2) and still provide robust, immediate safety enhancements without needing a new evolution cycle.
  • Moving Beyond Broad Refusals: Instead of teaching the agent to simply say "I can't do that" to any risky keyword, SHE refines fine-grained execution boundaries (e.g., allowing an agent to recommend an app but blocking it from autonomously installing it).

Key Results

  • Significant Risk Reduction: On Agent-SafetyBench, SHE reduced the average Attack Success Rate (ASR) to 5.5%, achieving a 3.1× reduction compared to the static SafeHarness baseline (17.1%).
  • Improved Utility: Unlike typical safety guardrails that degrade performance, SHE actually improved Utility under Attack (UA) from 31.6% (SafeHarness) to 47.6%.
  • Strong Generalization: When tested on the held-out AgentHarm benchmark, the evolved harness cut the Harm Score in half (from 19.8% to 9.8%) and boosted Harm Refusal from 78.4% to 86.4%.

Limitations and Future Work

While SHE represents a major step forward, a few limitations are worth noting:

  • Dependence on a Strong Evolution Model: The framework relies heavily on a highly capable frontier model (like GPT-5.5) to act as the judge, diagnostician, and editor during the evolution phase.
  • Stochastic Environments: Though evaluations were run at a temperature of 0 to ensure determinism, real-world deployment environments are highly stochastic, which might introduce noise into the trajectory feedback loop.
  • Scalability: Future work will need to explore how well this iterative loop scales when managing thousands of highly specialized tools or massive, long-horizon multi-agent deployments.

Summary updated

BibTeX
@misc{qu2026she,
  author = {Wanying Qu and Qinghua Mao and Yu Li and Jiyao Liu and Xin Zhang and Dadi Guo and Yanxu Zhu and Qingyu Liu and Leitao Yuan and Xi Lin and Shanfeng Zhu and Yanwei Fu and Jing Shao and Xia Hu and Dongrui Liu},
  title = {{SHE: Trajectory-driven Safety Harness Evolution for LLM Agents}},
  year = {2026},
  eprint = {2608.09885},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2608.09885},
}
Figure