Function Calling as a Flexible LLM Defense Add-On: Capability and Application Exploration

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.

Link
https://www.semanticscholar.org/paper/1be75c0087adad56d2d5c8e636f13aa74793908b
Found by
Semantic Scholar
Authors
Zhenlan Ji, Dao-Yuan Wu, Wen-Xuan Wang, Pingchuan Ma, Shuai Wang, Lei Ma, Juergen Rahmel
Categories
evaluation, dataset
Published
2026-10-01
Last seen by the radar
2026-10-03
Citations
0
Influential citations
0
Radar score
35.50 / 100 (how it is scored)
Why it scored so
Matched: dataset, evaluat; Primary record: Semantic Scholar
Related links
https://doi.org/10.1145/3832209
Is this record right? If you made this work and something here is wrong or missing, tell us what to fix.

More records found by Semantic Scholar