Notes from the research
Tool-Call Format Can Shape Prompt-Injection Results for Local LLM Agents
How often a local AI agent gets hijacked depends on how its tool calls are written and parsed, sometimes more than on the model. A strict output grammar can even make an agent easier to take over.
The question
An agent reads web pages, emails and files, and an attacker can hide instructions in them. Benchmarks report how often that attack works, and people compare models on that number.
The paper asks how much the number depends on plumbing: whether the model uses its built-in tool call, writes free text that is parsed afterwards, or writes text forced through a grammar. It also checks what 4-bit quantization changes.
How the study works
- 01Three 8B to 9B models at several precisions, as GGUF files
- 02Served with llama.cpp on T4 GPUs, greedy decoding
- 03Tool calls read three ways: native, free text and grammar
- 04Attacks from InjecAgent (300 cases) and AgentDojo (249 episodes)
- 05Paired comparisons with bootstrap intervals
- 06Fixes tested: a looser grammar, a lenient parser and room to refuse
What came out
- A strict grammar raised hijacking. For Qwen3.5-9B at F16 it went from 16.3% with free text to 38.0%. For Ministral-3-8B at Q4_K_M the jump was 39 points. Llama-3.1-8B did not change.
- The grammar took away the model’s way of saying no. In 216 of the 318 cases where Qwen’s free text answered “Action: None”, the grammar version called the attacker’s tool instead. Allowing “None” in the grammar cut those hijacks from 63.8% to 4.3%.
- Parse failures looked like safety. In AgentDojo, free text seemed 7 to 15 points safer, but the gap sat in calls the parser rejected, and 783 of 865 of those only left out “{}”.
- Quantization did not behave the same way twice. At Q4_K_M, Qwen went from 13.3% to 1.3% hijacked, Ministral stayed level and Llama rose from 35.7% to 49.7%.
What it doesn’t show
- Three models of 8B to 9B parameters, reasoning off, and one greedy run per setting.
- The study is exploratory. The test fixed in advance failed on AgentDojo.
- The intervals leave out session-to-session noise, and the AgentDojo split is not a causal test.
Paper and code
Preprint. The PDF, code and logs are on GitHub.