HARDE: Optimizing Agent Harnesses for Runtime Risk Detection and Execution Control

Zhuo Liu, Moxin Li, Zhixin Ma, Wentao Shi, Wenjie Wang, Fuli FengarXiv 2026

TL;DR

HARDE is a two-stage framework designed to automatically optimize safety "harnesses"—the execution wrappers that govern how LLM agents interact with the world. By decomposing defense into specialized modules (Trigger, Monitor, and Feedback) and using a data-driven "probing" stage to guide iterative refinement, HARDE significantly improves an agent's ability to resist attacks while successfully completing its original tasks.

What Problem Does This Paper Address?

Large Language Model (LLM) agents are increasingly autonomous, but this autonomy makes them prime targets for safety risks. An agent might be manipulated by "indirect prompt injections"—malicious instructions hidden in tool outputs, emails, or web pages that the agent "sees" during execution.

Current defenses generally fall into two camps: expensive model retraining (alignment) or rigid, rule-based system filters. The former is slow to update against new threats, while the latter lacks the flexibility to handle complex, multi-step reasoning. There is a clear need for a runtime defense that can detect risks on the fly and intervene intelligently without breaking the agent's ability to do its job.

Methods

The authors propose a Risk-Aware Harness structured around three core modules:

  1. Trigger Module: A lightweight gatekeeper that decides when to invoke a more expensive monitor.
  2. Monitor Module: An LLM-based judge that assesses the contextual risk of a proposed action.
  3. Feedback Module: The "recovery" unit that sanitizes the context or provides instructions to help the agent get back on track after a blocked action.

To optimize this harness, they introduce HARDE (Harness for Adaptive Risk Detection and Execution control), a two-stage framework:

  • Stage I: Probing: The system performs isolated tests on each module using a small data subset. It identifies recurring failure modes and distills these into a natural-language Optimization Guide.
  • Stage II: Guided Optimization: A "proposer agent" uses the guide and execution history to iteratively refine the harness. Crucially, it updates only one module at a time, making the optimization process more stable and attributable.
Figure 2: Illustration of the two-stage framework HARDE, which first performs isolated probing of each module in the risk-aware harness to derive a natural-language optimization guide, then uses this guide to iteratively optimize the harness to maximize its safe success rate.

Datasets

The researchers evaluated HARDE across three benchmarks representing different attack surfaces:

  • SHADE-Arena: Focuses on covert side-tasks injected into system prompts, requiring long-horizon reasoning (often 100+ steps).
  • AgentDyn: Features malicious instructions embedded in tool outputs (e.g., a fake discount link in a shopping review).
  • Agent-SafetyBench: Involves misleading environmental feedback that corrupts the agent's internal reasoning.

Key Insights and Ideas

  • Defense is a Team Sport: The authors found that effective defense requires coordinating different safety properties. For example, while a Monitor handles "Action Alignment," the Feedback module is essential for maintaining "Epistemic Integrity"—ensuring the agent doesn't start reasoning based on "polluted" or false information.
  • Attack-Awareness Matters: Different attacks stress different modules. Covert side-tasks (SHADE-Arena) require better triggering and feedback, whereas tool-output injections (AgentDyn) demand more sophisticated contextual monitoring.
  • Know Thy Monitor: A harness optimized for a powerful monitor (like DeepSeek-V4-Flash) doesn't necessarily work for a weaker one (like Qwen3-8B). Weaker monitors often need more help from deterministic, rule-based triggers to compensate for their smaller context windows.
Figure 1: Illustration of the risk-aware harness and our key insights for runtime defense design.

Key Results

HARDE consistently outperformed both manually designed harnesses and monolithic optimization baselines (like Meta-Harness).

  • Safety vs. Utility: On the challenging SHADE-Arena benchmark, HARDE improved the Safe Success (SS) rate—a metric requiring both task completion and attack prevention—by 77.9% compared to the strongest baseline.
  • Efficiency: As shown in Figure 3, HARDE typically reaches peak performance within just 5 iterations, exhibiting faster and more stable convergence than unguided methods.
  • Transferability: Optimization guides created for one dataset often transferred effectively to others with similar attack profiles, suggesting that the "probing" stage captures generalizable safety principles.
Figure 3: Performance of the candidate harness generated at each optimization iteration by Meta- Harness and HARDE on the search set across three benchmarks.

Limitations and Future Work

The authors acknowledge several areas for further exploration:

  • Agent Variation: The study primarily focused on varying the monitor model. Future work is needed to see how these harnesses perform when the agent model itself changes, especially if the agent is significantly weaker.
  • Cross-Model Transfer: While guides transfer well between similar datasets, transferring a guide between monitors with vastly different capabilities (e.g., a massive frontier model vs. a tiny edge model) remains a challenge.
  • Joint Optimization: The current work treats the agent as a "black box." A promising next step is the joint optimization of the runtime harness alongside the agent's intrinsic alignment training.

Summary updated

BibTeX
@misc{liu2026harde,
  author = {Zhuo Liu and Moxin Li and Zhixin Ma and Wentao Shi and Wenjie Wang and Fuli Feng},
  title = {{HARDE: Optimizing Agent Harnesses for Runtime Risk Detection and Execution Control}},
  year = {2026},
  eprint = {2609.38291},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2609.38291},
}
Figure