SafeKeep Mitigates AI Agent Safety Risks from Tool Specifications

Minghui Pan, Jiayuxuan Yang, Yuanyuan Yuan, Yu Jiang, Zhenpeng Chen· August 3, 2026 View original

Key takeaways

  • Tool-using AI agents often become less safe due to schema-formatted tool specifications.
  • These specifications can weaken LLMs' internal refusal signals, leading to unsafe actions.
  • SafeKeep is an inference-time safeguard that decouples safety judgment from tool execution.
  • SafeKeep significantly improves refusal rates for harmful requests and reduces prompt injection attack success.

Who benefits

CybersecurityAI DevelopmentFinanceHealthcareAutonomous Systems

Summary

This paper identifies schema-formatted tool specifications as a primary source of safety degradation in tool-using AI agents, weakening refusal signals and leading to unsafe execution. It proposes SafeKeep, an inference-time safeguard that decouples safety judgment from tool execution, significantly improving refusal rates for harmful requests.

AI agents, by integrating large language models (LLMs) with external tools, gain the ability to perform complex tasks and enact real-world actions. However, this integration often introduces significant safety risks, with agents becoming less safe than standalone LLMs. The root cause of this degradation has been poorly understood. This research pinpoints schema-formatted tool specifications as a major contributor to agent safety issues. Analysis reveals that these specifications can weaken the LLM's internal refusal signals, making the model more prone to executing unsafe actions. This happens because the structured format might inadvertently override or dilute the model's inherent safety mechanisms. To address this, the paper introduces SafeKeep, an inference-time safeguard. SafeKeep's core innovation is decoupling the safety judgment process from the actual tool execution. It assesses incoming requests using a "flattened textual" version of the tool specifications for safety checks, while retaining the original schema-formatted specifications for when a tool is actually executed. This approach dramatically improves refusal rates for harmful requests (from 23.8% to 70.6%) and reduces attack success rates under prompt injection (from 25.6% to 2.5%) across various LLMs and benchmarks, outperforming existing safeguards while preserving task-handling capabilities.

Why it matters

For professionals developing and deploying AI agents, especially in sensitive or high-stakes environments, ensuring agent safety and preventing harmful actions is paramount. SafeKeep offers a practical and effective method to mitigate critical safety risks stemming from tool integration.

How to implement this in your domain

  1. 1Adopt SafeKeep or similar inference-time safeguards to enhance the safety of your tool-using AI agents.
  2. 2Decouple safety judgment from tool execution by using different representations of tool specifications for each process.
  3. 3Conduct thorough security testing, including prompt injection and harmful request scenarios, to validate agent safety with and without safeguards.
  4. 4Review and potentially revise how tool specifications are presented to LLMs to minimize the weakening of internal refusal signals.

Original post by Minghui Pan, Jiayuxuan Yang, Yuanyuan Yuan, Yu Jiang, Zhenpeng Chen

"arXiv:2607.29254v1 Announce Type: new Abstract: AI agents extend large language models (LLMs) with external tools, enabling them to perform complex tasks and translate model outputs into consequential real-world actions. Yet LLMs often become substantially less safe when deployed…"

View on X

Originally posted by Minghui Pan, Jiayuxuan Yang, Yuanyuan Yuan, Yu Jiang, Zhenpeng Chen on X · view source

Want to go deeper?

Turn these trends into skills with Learnijoy's hands-on AI & tech courses.

Explore courses