All research 03 / 05

Notes from the research

Tool-Call Format Can Shape Prompt-Injection Results for Local LLM Agents

Nov to Dec 2026 · 2 min read · Muhammad Shakaib Arsalan

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.

  • Agent security
  • Prompt injection
  • Quantization
  • llama.cpp

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

  1. 01Three 8B to 9B models at several precisions, as GGUF files
  2. 02Served with llama.cpp on T4 GPUs, greedy decoding
  3. 03Tool calls read three ways: native, free text and grammar
  4. 04Attacks from InjecAgent (300 cases) and AgentDojo (249 episodes)
  5. 05Paired comparisons with bootstrap intervals
  6. 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%.
Qwen3.5-9B hijack rate on InjecAgentThe same model and the same attacks, with only the tool-call format changed (F16).
  • Free text, parsed later 16.3%
  • Strict grammar 38.0%
Chart of the grammar-minus-free-text difference in attack success for Qwen on both benchmarks, per quantization level.
From the paper. Qwen: grammar minus free text, per precision, on both benchmarks.

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.

Paper (PDF)Code and logs on GitHub

Want to talk about this work?

Questions about the method or the data, or a role where this kind of work matters. Email is the quickest way.

Google Meet · 30 min

Book a call with Shakaib

Loading times…

Pick a date

Choose a day to see open times.

Times in your time zone

——
  • 30 minutes on Google Meet
  • Invite and Meet link by email
  • Need another time? Just email me

You’ll get a Google Calendar invite with the Meet link.

You’re booked.

An invite with the Meet link is on its way to .