Indirect prompt injection (IPI) attacks, in which adversarial instructions are embedded in external data processed by a language model, pose a significant threat to the integrity of deployed LLM agents. Attention Tracker (Hung et al., 2025) is a recently proposed white-box detection method that identifies prompt injection attacks by monitoring how a model's attention is distributed between user task tokens and data tokens, claiming dataset-agnostic detection via a scalar focus score threshold. In this paper, we provide the first evaluation of Attention Tracker in a realistic agentic IPI setting using the AgentDojo benchmark, finding that the dataset agnosticism claim does not hold. We find that in agentic environments, long structured tool outputs subvert the fundamental assumptions Attention Tracker makes about attention that the method depends on and produces near-chance detection on AgentDojo across most model families. We propose AttnDA, an extension replacing the scalar threshold with a Fisher Linear Discriminant Analysis classifier over the per-head focus score vector, and evaluate both methods in a cross-dataset setting spanning four benchmarks. AttnDA improves detection performance across agentic and tool-integrated benchmarks, though transfer to AgentDojo remains challenging regardless of classifier choice. A covariance ablation further shows that removing inter-head correlation structure substantially contributes to performance, with complex covariance assumptions causing significant degradation on cross-domain data. These results indicate that the attentional distraction signal underlying focus-score-based detection does not transfer reliably to agentic environments, and that learned linear classifiers over head-level attention features offer improved detection performance, provided training data from the target deployment domain is available.
Figures & tables
Figure 1: Prompt length (characters) vs Focus score FS from Equation 3 for Llama3-8B-Instruct for the deepset and AgentDojo datasets.
Synthetic
Model
Dataset
Method
Llama
Qwen
Gemma
Phi
Mistral
Avg.
deepset
AT
0.92
0.98
0.99
0.97
0.99
0.97
AttnDA
0.91
0.97
0.97
0.92
0.96
0.95
AgentDojo †
AT
0.53
0.39
0.83
0.50
0.59
0.57
AttnDA
0.57
0.42
0.69
0.77
0.66
0.62
InjecAgent
AT
0.73
0.63
0.71
0.76
0.76
0.72
Table 2
In-Domain
Model
Dataset
Llama
Qwen
Gemma
Phi
Mistral
Avg.
deepset
AT
0.98
0.99
0.99
0.97
0.99
0.98
AttnDA
0.88
0.93
0.95
0.89
0.94
0.92
AgentDojo †
AT
0.62
0.44
0.53
0.78
0.71
0.62
AttnDA
0.97
0.88
0.95
0.95
0.95
0.94
InjecAgent
AT
0.99
0.98
0.98
0.90
0.90
0.95
Table 3
Cross-Domain
Eval.
Train
deepset
AgentDojo †
InjecAgent
LLMail-Inject
deepset
AT
0.98
0.55
0.82
0.87
FC
0.99
0.56
0.77
0.70
AttnDA
0.92
0.65
0.86
0.83
AgentDojo †
AT
0.85
0.62
0.73
0.82
FC
0.56
0.91
0.55
0.54
Table 4
Evaluation Dataset
Covariance Structure
AgentDojo †
deepset
LLMail-Inject
InjecAgent
Avg.
Full
0.9170
0.9400
0.5130
0.4110
0.6952
Block-layer
0.9830
0.5740
0.3100
0.2620
0.5323
Diagonal (AttnDA)
0.8830
0.8110
0.8580
0.8360
0.8470
Identity
0.8330
0.7560
0.3100
0.7380
0.6593
Table 5
deepset
AgentDojo †
InjecAgent
LLMail-Inject
Synthetic
deepset
0.98
0.17
0.53
0.65
0.53
AgentDojo †
0.80
0.09
0.15
0.06
InjecAgent
0.77
0.31
0.26
LLMail-Inject
0.99
0.58
Synthetic
0.96
Table 6
Figure 2: AttnDA weight vector w for Qwen2-1.5B fit on each dataset’s training split. The weight of a head has the sign of μmalicious−μbenign for its focus score: blue (negative) marks heads whose focus on the instruction decreases under the presences of an attack, as Attention Tracker assumes, and red (positive) marks heads whose focus score increases. Each panel is scaled by its own largest ∣w∣ . AgentDojo † mixes positive and negative weights, while deepset and LLMail are almost entirely negative.
Bootstrap of Test Set for Agent-Dojo Trained Models
Prompt injection detection identifies malicious instructions in prompts, retrieved content, webpages, images, or tool outputs before they hijack language models and agents.
School of Computer Science, Peking University, China · College of Computing and Data Science, Nanyang Technological University, Singapore · Ant Group +1