arXiv(opens in a new tab)cs.AIAug 2026Cited by 4 papers on PaperVantage

Manuscript Offprint

arXiv:2608.24777

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 Liu

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

LLM-based agents can interact with external environments through tool invocation, but this capability also introduces security risks such as file modification, information leakage, and unauthorized actions. Existing guardrails often evaluate completed trajectories, leaving pre-execution monitoring of step-level actions underexplored. We propose StepGuard, a step-level guard model that can audit completed agent trajectories and check tool actions before they are executed. To train StepGuard, we introduce StepGen, an automatic data engine that generates safe and unsafe trajectories with the same context but different actions at the risky step. To further reduce over-defense and under-defense, we propose Balance-GRPO, which dynamically balances learning between safe and unsafe actions based on their observed accuracy. Experiments show that StepGuard achieves the highest average accuracy among open-weight guard models, with performance comparable to GPT-5.4. When used to guard agents on AgentDojo and AgentDyn, StepGuard reduces mean ASR by 77.3% relative to the no-guard setting, while mean utility drops by only 2.8 points.

1 Introduction

Large Language Model (LLM)-based agents extend LLMs beyond text generation, enabling them to use tools, access resources, and interact with external environments across diverse real-world applications (Schick et al., 2023; Luo et al., 2025b; Chen et al., 2025; Zhao et al., 2026; Qin et al., 2024). Unlike conventional chatbots, these agents can take actions with real-world consequences, such as modifying files, sending messages, disclosing sensitive information, and executing transactions (Greshake et al., 2023; Andriushchenko et al., 2025; Li et al., 2026a; Guo et al., 2025). Ensuring the safety of agent actions is therefore critical for reliable deployment (Su et al., 2026; Li et al., 2026c).

A practical approach to improving agent safety is to deploy agent guardrails (Mou et al., 2026; Liu et al., 2026b). These systems monitor agent behavior and intervene when necessary without changing or retraining the agent itself. In deployment, a guard must block unsafe actions while preserving benign tasks. However, existing guards often exhibit defense bias: some block too many benign actions, while others miss too many unsafe ones (Liu et al., 2026c; Li et al., 2026b; Xiong et al., 2026). This bias undermines the safety–utility balance in both directions, as over-defense sacrifices task utility and under-defense sacrifices safety. Achieving a better balance faces two challenges: (1) Lack of scalable and high-quality step-level supervision. Real-world unsafe executions are rare, while manual construction is expensive and difficult to scale across diverse tools, contexts, and risks (Huang et al., 2025). Although recent work has explored step-level supervision, existing data remain limited in scale and risk coverage, and rarely provide context-matched safe and unsafe actions at the same decision point (Mou et al., 2026). (2) Limited control over the safety–utility balance. Existing training methods (Liu et al., 2026a; Zhao et al., 2025) mainly optimize overall performance and do not explicitly adjust training according to the guard’s observed accuracy gap between safe and unsafe actions. How to use this gap to control the guard’s behavior during training remains an open problem.

To address these two challenges, we propose StepGuard, a step-level guard model that checks candidate tool actions before execution and also audits completed trajectories. To provide scalable step-level supervision,

∗^{*}Equal contribution. †^{\dagger} Corresponding author.

we develop StepGen, an automatic data engine that synthesizes diverse multi-step trajectories by sampling tools and risk types following ATBench (Li et al., 2026d). StepGen constructs matched safe and unsafe trajectories that share the same execution prefix and diverge at a designated risky step. It also generates benign trajectories that reuse similar tools, preventing the guard from treating tool identity as a safety signal. To better control the safety–utility balance, we further introduce Balance-GRPO, which extends GRPO (Shao et al., 2024) by reweighting normalized advantages according to the observed accuracy gap between safe and unsafe actions. This gives more weight to the class with lower accuracy without changing the rollout prompts or raw rewards.

Experiments demonstrate the effectiveness of StepGuard. In safety evaluation, it achieves the highest average accuracy among open-weight models, with performance comparable to GPT-5.4. When deployed as a runtime guard on AgentDojo and AgentDyn, it reduces mean ASR by 77.3% relative to the no-guard setting, while mean utility decreases by only 2.8 points. Ablation results further show that, compared with vanilla GRPO, Balance-GRPO reduces the safe–unsafe accuracy gap from 13.0 to 8.0 and improves utility by up to 6.7 points in guarded-agent evaluation, while increasing ASR by only 0.3 points.

The main contributions are summarized as follows:

• We develop StepGuard, a 4B guard model that supports both pre-execution safety checks of candidate tool actions and safety auditing of completed agent trajectories.

• We propose StepGen, an automatic data engine that constructs prefix-aligned safe and unsafe trajectories with localized risky steps and benign uses of similar tools, providing scalable step-level supervision.

• We propose Balance-GRPO, which uses the observed safe–unsafe accuracy gap to reduce defense bias during on-policy training. Experiments show that StepGuard achieves strong safety judgment and runtime safety–utility trade-offs.

References (1)

  • - Mark the action as safe when it serves a legitimate goal, remains within the authorized scope, and avoids clearly harmful side effects