Function Calling as a Flexible LLM Defense Add-On: Capability and Application Exploration
Zhenlan Ji, Daoyuan Wu, Wenxuan Wang, Pingchuan Ma, Shuai Wang, Lei Ma, Juergen Rahmel
Key points
From the paper's conclusion- We show that by defining functions representing malicious actions, LLMs equipped with FC can intercept harmful prompts by triggering these function calls instead of generating unsafe content.
Abstract
Large language models (LLMs) exhibit impressive capabilities but are susceptible to adversarial attacks that induce harmful outputs. Although various defenses have been proposed, their practicality is restricted by substantial runtime overhead or degraded model helpfulness. Moreover, LLM applications typically have diverse and evolving security requirements that cannot be fully anticipated during the design of static defenses. These limitations call for a flexible, low-overhead defense mechanism that can be easily customized to meet task-specific needs. In this paper, we explore function calling (FC)—a built-in mechanism in modern LLMs for invoking custom tools—as a lightweight and adaptable defense add-on. We show that by defining functions representing malicious actions, LLMs equipped with FC can intercept harmful prompts by triggering these function calls instead of generating unsafe content. Extensive experiments across mainstream LLMs demonstrate that FC substantially improves defense effectiveness with minimal impact on model helpfulness. To further assess FC's practical utility, we also introduce DSPEC, a new dataset reflecting real-world LLM applications with specific defense requirements. Our evaluations on DSPEC show that FC substantially outperforms existing defenses in this realistic setting. Besides, we also explore the practical applications of FC in various scenarios, including universal defense frameworks and multi-agent systems, further demonstrating its versatility and effectiveness in enhancing LLM security.
Read the paper
Discussion
Science Skim's AI key points, plus readers' public thoughts
Readers' thoughts
No reader thoughts yet.
Related papers
- ToolFence: Fine-Grained Authorization for Secure Tool-Using LLM AgentsarXiv · 2026
- ActionGuard: Tool Call Authorization under Poisoned SkillsarXiv · 2026
- AgentSafeEvo: Adversarial Co-Evolution for LLM Agent SafetyarXiv · 2026
- Beyond Prompt Injection: The Tool Update Gap in LLM Agent SecurityarXiv · 2026
- ToFu: Exploiting and Fuzzing the LLM-Orchestrator-Tool Trust BoundaryarXiv · 2026
- AdaptiveCap: Adaptive Capability Control for Secure and Flexible LLM Agent WorkflowsElectronics · 2026