ToolSafe: Enhancing Tool Invocation Safety of LLM-based agents via Proactive Step-level Guardrail and Feedback
About
While LLM-based agents can interact with environments via invoking external tools, their expanded capabilities also amplify security risks. Monitoring step-level tool invocation behaviors in real time and proactively intervening before unsafe execution is critical for agent deployment, yet remains under-explored. In this work, we first construct TS-Bench, a novel benchmark for step-level tool invocation safety detection in LLM agents. We then develop a guardrail model, TS-Guard, using multi-task reinforcement learning. The model proactively detects unsafe tool invocation actions before execution by reasoning over the interaction history. It assesses request harmfulness and action-attack correlations, producing interpretable and generalizable safety judgments and feedback. Furthermore, we introduce TS-Flow, a guardrail-feedback-driven reasoning framework for LLM agents, which reduces harmful tool invocations of ReAct-style agents by 65 percent on average and improves benign task completion by approximately 10 percent under prompt injection attacks.
Related benchmarks
| Task | Dataset | Result | Rank | |
|---|---|---|---|---|
| Step-level tool invocation safety detection | AgentHarm Traj | Accuracy84.81 | 20 | |
| Step-level tool invocation safety detection | ASB-Traj | Accuracy0.9497 | 20 | |
| Step-level tool invocation safety detection | AgentDojo-Traj | Accuracy91.72 | 20 | |
| Agent Security Evaluation | Agent Security Bench (ASB) IPI Combined Attack (CA) and Context Ignoring (CI) averaged | ASR2.89 | 18 | |
| Agent Security Evaluation | Agent Security Bench (ASB) DPI Combined Attack (CA) and Context Ignoring (CI) averaged | ASR10.25 | 18 | |
| Safety-Utility Trade-off Evaluation | AgentHarm | HS Score68.71 | 15 | |
| Guarded Agent Evaluation | ASB latest (IPI) | ASR5.5 | 14 | |
| Guarded Agent Evaluation | AgentHarm latest (full) | Refusal Rate97.16 | 14 | |
| Guarded Agent Evaluation | AgentDojo full latest | ASR0.0768 | 14 | |
| Guarded Agent Evaluation | ASB latest (DPI) | ASR62.25 | 14 |