Abstract
Prompt injection attacks pose a significant security challenge for large language models (LLMs), enabling malicious instructions to override or manipulate prompt output. In this context, using structured prompts is a reliable defense mechanism. As such, mechanisms that separate data from instructions make it more difficult to carry out attacks that rely on introducing new information. This paper proposes a defense mechanism based on tools. We implemented a reference approach and tested it in different injection scenarios. We evaluated the effectiveness and token costs of different defense approaches against prompt injection attacks across multiple language models from the GPT-4.1, GPT-5, and Llama families. The experiments analyze the ability of models to prevent malicious instructions from overriding the original system behavior and measure prompt, completion, and total token usage for each configuration. The results show that attack outcomes vary considerably across models and scenarios. Tool-based approaches produced different defense behaviors and generally higher token consumption than reference scenarios. The study highlights the relationship between defense behavior and computational cost in prompt injection mitigation strategies for LLM applications.