StepGuard: Learning Step-Level Guardrails with Scalable Supervision and Safety-Utility Balancing

Zhijie Zheng, Yu Li, Chen Qian, Yuqian Fu, Yanwei Fu, Lu Sheng, Jing Shao, Dongrui LiuarXiv 2026

TL;DR

StepGuard is a novel step-level guardrail model designed to intercept and audit LLM agent actions before they execute harmful tool calls. By combining a contrastive synthetic data engine (StepGen) with a dynamically balanced reinforcement learning objective (Balance-GRPO), StepGuard drastically reduces an agent's vulnerability to exploits while maintaining high task performance.

What Problem Does This Paper Address?

LLM-based agents are increasingly trusted to interact with the real world via tools—modifying files, sending emails, or executing financial transactions. However, this autonomy introduces severe security risks like prompt injection and unauthorized actions.

Existing agent guardrails typically evaluate an agent's behavior after a full trajectory is completed. This post-hoc approach is too late to prevent real-world damage. Furthermore, existing guard models suffer from defense bias: they either over-defend (blocking benign actions and ruining utility) or under-defend (allowing unsafe actions).

As shown in Figure 3, many open-weight guard models struggle to find a healthy operating point between safe and unsafe accuracy.

Safe–unsafe accuracy trade-off across different guard models, highlighting the issue of over-defense and under-defense bias.

The authors identify two core bottlenecks preventing better guardrails:

  1. A lack of scalable, step-level supervision data that provides context-matched safe and unsafe actions at the exact same decision point.
  2. Limited control over the safety–utility balance during model training.

Methods

To solve these challenges, the authors introduced StepGuard, a 4B parameter guard model trained via a two-stage pipeline:

1. StepGen: Prefix-Aligned Data Engine

To generate high-quality step-level data, the authors built StepGen. Instead of generating random safe or unsafe trajectories, StepGen creates prefix-aligned contrastive groups.

  • It first rolls out an unsafe trajectory up to a critical "risky step" (the anchor).
  • From that exact prefix, it branches out to create two safe alternatives: a Refuse branch (declining the action) and an Aware branch (finding a safe alternative tool call).
  • It also generates an independent Benign trajectory using similar tools to prevent the guard model from simply memorizing that "sensitive tools = unsafe."
Overview of the StepGen pipeline, showing how prefix-aligned contrastive groups are constructed and filtered.

2. Balance-GRPO

After an initial cold-start Supervised Fine-Tuning (SFT) phase, the model is optimized using a new variant of Group Relative Policy Optimization (GRPO) called Balance-GRPO.

Standard RL training optimizes overall performance but ignores the gap between safe and unsafe accuracy. Balance-GRPO dynamically calculates the accuracy gap between safe and unsafe classes within each rollout batch. It then reweights the training advantages, giving more optimization pressure to whichever class is currently underperforming, effectively smoothing out the defense bias.

Overview of StepGuard's two-stage training process: Cold-Start SFT followed by Balance-GRPO online calibration.

Datasets

  • Training Data: 7K step-annotated examples synthesized by StepGen (3K for SFT, 4K for Balance-GRPO).
  • Static Evaluation Benchmarks: Trajectory-level safety was evaluated using ATBench, R-Judge, and ASSE Security. Step-level safety was evaluated using TS-Bench-Dojo and TS-Bench-Harm.
  • Guarded-Agent (Dynamic) Benchmarks: AgentDojo, AgentDyn, and AgentHarm were used to test the guardrail deployed inline within an active agent loop.
  • Held-out Human Evaluation: 100 human-verified execution traces from the NVIDIA Nemotron-AIQ Agentic Safety Dataset.

Key Insights and Ideas

  • Tool Identity is Not a Safety Signal: A common failure mode for agent guardrails is treating specific tools (like shell_command or send_email) as inherently dangerous. StepGen's inclusion of benign tool-reuse trajectories forces the model to look at the context and intent rather than the tool name.
  • Dynamic Reweighting Beats Static Rewards: Trying to balance safety and utility using static reward weights is notoriously difficult. Reweighting the advantages based on live batch accuracy gaps (Balance-GRPO) allows the model to self-correct its over-defensiveness during training without altering the underlying reward function.

Key Results

StepGuard achieved the highest average accuracy among open-weight guard models on static benchmarks, performing on par with closed-source models like GPT-5.4.

When deployed as a live runtime guardrail:

  • ASR Reduction: It reduced the mean Attack Success Rate (ASR) on AgentDojo and AgentDyn by 77.3% compared to having no defense.
  • Minimal Utility Cost: The agent's task utility dropped by a mere 2.8 points on average.
  • Efficiency: StepGuard reduced per-call latency by 33-34% compared to existing step-level guards like TS-Guard and ShieldAgent-THU, making it highly practical for real-time deployment.
Runtime safety-utility trade-off curves across AgentDojo, AgentDyn, and AgentHarm.

Limitations and Future Work

Despite its strong performance, the authors note several limitations:

  • Synthetic Data Dependencies: StepGen relies heavily on a teacher LLM (GLM-5.1) for generation and annotation, meaning it can inherit the teacher's biases or taxonomy blind spots.
  • Adversarial Vulnerabilities: While highly effective against standard prompt injections, StepGuard was not fully tested against adaptive, multi-agent adversaries or highly complex, long-horizon workflows.
  • Not a Hard Guarantee: As a probabilistic LLM-based guardrail, false positives and false negatives still occur. It should be treated as a layer of defense rather than a formal verification tool.

Summary updated

BibTeX
@misc{zheng2026stepguard,
  author = {Zhijie Zheng and Yu Li and Chen Qian and Yuqian Fu and Yanwei Fu and Lu Sheng and Jing Shao and Dongrui Liu},
  title = {{StepGuard: Learning Step-Level Guardrails with Scalable Supervision and Safety-Utility Balancing}},
  year = {2026},
  eprint = {2608.24777},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2608.24777},
}
Figure