Manuscript Offprint

arXiv:2610.22828

GRAD: Graph-Structured Antibody Defense for LLM Agents

Tianqi Song, Jiawei Du, Xuemei Jia, Zheng Wang

ABSTRACT

Memory poisoning and decomposition attacks distribute malicious evidence across the operations of large language model agents. Existing request-level defenses can miss such attacks because they assess individual inputs without connecting earlier information to later actions. Moreover, detectors must adapt as task contexts change, while updates to shared parameters can impair previously learned detection capabilities. To address these challenges, we propose GRAD, which combines graph-based evidence aggregation across operations with an extensible collection of detection experts. Its Semantic–Structural Understanding Module (SSUM) jointly encodes operation text, event attributes, and typed candidate relations in an execution graph to aggregate distributed attack evidence into a graph-level risk score. Its Continual Antibody Adaptation (CAA) adds experts on frozen encoder snapshots and routes inputs by observable graph signatures, acquiring and reusing detection capabilities as tasks arrive. Across Decomp, MCP, and MRT, GRAD achieves AUROCs of 97.19%, 77.59%, and 86.60%, respectively, outperforming Sequential Monitor and locally adapted Agent-Sentry and NeuroTaint. CAA improves final accuracy by 13.08 percentage points over Replay on the cross-dataset task stream. The gain remains 9.05 points with equal family/base-case weights within each task. Its compact drop-in gate performs local model inference in milliseconds without monitoring API calls.

1 INTRODUCTION

Large language model (LLM) agents combine planning, tool use, and memory to carry out complex tasks, enabling applications ranging from digital assistants to knowledge-intensive decision support (Debenedetti et al., 2024; Chen et al., 2024). Their ability to interact with external environments also creates security risks: attackers can embed malicious instructions in tool outputs or poison stored knowledge to redirect an agent toward unauthorized actions (Debenedetti et al., 2024; Chen et al., 2024; Zhang et al., 2025). These risks become particularly challenging when malicious intent is distributed across multiple interactions. Decomposition attacks, for example, split a harmful objective into seemingly benign subtasks that can evade request-level safeguards (Yueh-Han et al., 2026), while memory poisoning allows adversarial information to influence later decisions through retrieval (Chen et al., 2024). Existing defenses include lightweight sequential monitors that detect harmful intent from cumulative prompt histories (Yueh-Han et al., 2026). Nevertheless, protecting agents throughout extended interactions requires accounting for how attack-relevant information is introduced, retained, and subsequently used during execution.

Figure 1 illustrates how earlier operations influence a later action. For example, an agent may retrieve external content, store a summary, and later consult it when preparing a tool call. Memory-poisoning studies show that malicious records can influence subsequent behavior through retrieval (Chen et al., 2024; Dong et al., 2025); the challenge is to assess the content being reused together with the context of its use. Sequential monitors accumulate conversational evidence (Yueh-Han et al., 2026). We study how to organize this evidence across operations. We investigate typed execution graphs as a representation that combines operation content with candidate relations inferred from event order, operation types, and textual cues. These relations provide paths for aggregating evidence across operations. This design targets decomposition attacks, whose harmful intent is

(a) Decomposition attack

(b) Memory poisoning

Figure

Figure 1: Decomposition, memory poisoning, and GRAD. (a) A decomposition attack spreads a confidential-report leak across individually ordinary operations, from locating the report to sending its contents externally. (b) Memory poisoning stores untrusted information in one session and reuses it in a later session to influence a proposed payment. GRAD jointly assesses operation content and candidate execution relations for pre-execution risk detection, while its antibody mechanism acquires and reuses task-specific detection experts.

distributed across interactions, while the operation-text channel covers locally visible cues such as poisoned tool content.

Beyond combining evidence within an execution, a detector must adapt to changing tasks while retaining useful capabilities learned from earlier ones. This setting includes both new instances of familiar attack strategies and attacks from previously unseen families. The corresponding learning objectives are task adaptation and retention; a separate family-isolated stream probes transfer to held-out attack families. Updating a shared detector can improve a new task while altering its performance on earlier tasks. This tension has been studied in continual adversarial robustness (Dai et al., 2025) and lifelong safety alignment (Wang et al., 2025).

To address these challenges, we propose GRAD, a framework for graph-based attack detection and continual adaptation in LLM agents. Its Semantic–Structural Understanding Module (SSUM) combines operation content and event attributes with candidate relations in a typed execution graph. Building on this detector, Continual Antibody Adaptation (CAA) constructs a growing collection of detector specialists, termed antibodies: compact, task-specific modules that can be added to a running collection and reused as new tasks arrive. We instantiate the standalone detector as a drop-in pre-execution gate that performs local model inference in milliseconds and supports blocking and replanning in closed-loop environments.

Our contributions are threefold:

• We propose GRAD, an execution-graph framework whose SSUM encoder integrates operation semantics, event attributes, and typed candidate relations for agent attack detection. Across Decomp, MCP, and MRT, GRAD outperforms locally adapted Agent-Sentry and NeuroTaint baselines, achieving 97.19, 77.59, and 86.60 AUROC, respectively. We additionally report Sequential Monitor results under native Decomp and adapted MCP prefix protocols; matched decision-time comparisons appear in Section 4.2.

• We develop CAA, which combines encoder adaptation, frozen snapshots, and graph-signature routing into a growing expert collection. On the cross-dataset stream, CAA improves final accuracy over Replay by 13.08 points and reduces forgetting from 0.0629 to 0.0079; equal family/base-case weighting within each task preserves a 9.05-point accuracy gain.

• We instantiate GRAD as a compact drop-in pre-execution gate that performs local model inference in milliseconds and supports blocking and replanning without monitoring API calls. Benchmark comparisons, encoder ablations, and exploratory closed-loop evaluation characterize its detection performance and security–utility tradeoffs.

Figure

Figure 2: GRAD method overview. Observed operations form an execution graph whose text, attributes, and candidate relations are encoded by SSUM. CAA updates SSUM on current data and replay, freezes stage-specific snapshots, and selects one expert through centroid routing for graph-level risk prediction.

References (95)

  • Ipiguard: A novel tool dependency graph-based defense against indirect prompt injection in llm agents
  • Dark experience for general continual learning: a strong, simple baseline
  • StruQ: Defending against prompt injection with structured queries
  • Secalign: Defending against prompt injection with preference optimization
  • Agentpoison: Red-teaming llm agents via poisoning memory or knowledge bases
  • Adapting to evolving adversaries with regularized continual robust training (opens arXiv in a new tab)
  • Agentdojo: A dynamic environment to evaluate prompt injection attacks and defenses for llm agents
  • Defeating Prompt Injections by Design
  • Memory Injection Attacks on LLM Agents via Query-Only Interaction (opens the publisher in a new tab)
  • Wildguard: Open one-stop moderation tools for safety risks, jailbreaks, and refusals of llms
  • Drattack: Prompt decomposition and reconstruction makes powerful llms jailbreakers
  • Unasafer in many turns: Benchmarking and defending multi-turn safety risks in tool-using agents (opens arXiv in a new tab)
  • Memorygraft: Persistent compromise of llm agents via poisoned experience retrieval (opens arXiv in a new tab)
  • Lifelong Safety Alignment for Language Models (opens the publisher in a new tab)
  • Learning to prompt for continual learning
  • Monitoring decomposition attacks with lightweight sequential monitors
  • Agent security bench (asb): Formalizing and benchmarking attacks and defenses in llm-based agents
  • GUARDIAN: Safeguarding LLM Multi-Agent Collaborations with Temporal Graph Modeling (opens the publisher in a new tab)
  • Mcp-safetybench: A benchmark for safety evaluation of large language models with real-world mcp servers
  • PoisonedRAG: Knowledge corruption attacks to Retrieval-Augmented generation of large language models
  • Fold counts are one, five, and five, respectively
  • They are historical diagnostic panels
  • The 512-character configuration was frozen before the 132-run four-arm static replication (Appendix K); operating points use stored validation thresholds
  • AUROC is recomputed from per-sample ranks, weighted by $n_{+}n_{-}$ across folds within a seed, and summarized with the sample standard deviation across seeds
  • It attributes the batch differences to repeat-run variation
  • Superscripts identify evaluated implementations
  • >Method</td><td colspan=
  • The adapted scores come from the September 17 cumulative-prefix batch
  • For MG, harmful trajectories are restricted to the first event
  • $^{b}$ Mechanism adaptation with an assumed registry and reconstructed dependencies
  • Test-set FPR is not constrained to equal the development target; operating points are not matched across methods
  • Counts retain the original 18-run matched panel; not the P1/R1 or T3 cases
  • The agent uses DeepSeek Flash with thinking disabled, temperature zero, and no retries
  • No unexposed applicable task remained for poison_forward, so its transfer was untested
  • The evaluated configuration uses this adapted payload and the selected injection location in each suite
  • AUROC on [0,1], source-reported mean and SD across three seeds
  • Group-bootstrap estimates based on pooled scores are not interchangeable with the fold-weighted estimates reported here
  • These are development-selected operating points applied unchanged to test scores
  • Final per-task accuracy is reported in Table 26; full routing endpoints appear in Table 25
  • Source-reported means and SD on [0,1]
  • Its development-selected threshold is 0.0226; checkpoint SHA-256 is e0f79c22...b1f1712
  • T3 is the only qualifying configuration, with development F1 0.938
  • The T3 batch reuses the earlier closed-loop case panel and intervention protocol, deploying the adapted detector as g3x
  • >Backbone</td><td rowspan=
  • Each pair lists discordant counts $(b, c)$ and the unadjusted two-sided $p$-value; gate batches are reported separately
  • The two batches combine stochastic agent execution with a changed gate
  • The agent models are DeepSeek Flash and GLM-5.3-Flash
  • It contains four attack families, benign and attack conditions, and five repeats, giving 20 runs per condition and arm in each agent-model panel
  • The gate-vs-trainer input test found six graph-tensor fields exactly equal; on 42 development rows, score parity had maximum absolute difference $2.3 \times 10^{-4}$ between batch-one gate inference and the training batch
  • The continual-learning snapshot pool occupies 7.74 MB; its training and routing costs are reported in Appendix L. The closed-loop batch completed 240/240 runs with no infrastructure errors
  • The plan and checkpoint hashes are listed in Appendix F; the gate seed is 211
  • These settings correspond to partial write access as in AgentPoison (Chen et al., 2024), and query-induced memory contamination as in MINJA (Dong et al., 2025), respectively
  • Two independent Bernoulli masks are drawn per graph, each with drop probability 0.25, and shared across its nodes
  • The runtime gate uses a separately trained SSUM detector rather than the expert collection
  • An adapter is inserted at the output of the final
  • Output: Expert collection $\mathcal{A}_R = \{(\theta_j^\star, \phi_j, \boldsymbol{\mu}_j)\}_{j=1}^R$
  • 8 Apply the standalone runtime detector Given observed history $\mathcal{E}_{<t}$ and proposed action $a_t$, construct $G_t = \Phi(\mathcal{E}_{<t}, a_t)$ Score $G_t$ with the runtime SSUM detector; intervene when its score reaches the development-selected threshold $\tau$
  • MCP in-domain evaluation uses 40 runs: 20 seeds $\times$ two task orders; cross-dataset evaluation uses 10 runs: five seeds $\times$ two task orders
  • >Method</th><th colspan=
  • Expanding the library also increases storage and selection costs
  • The AgentDojo diagnostics document sparse undefended attack success in the tested settings
  • All four arms were retrained in the same batch
  • Two runs failed with GPU out-of-memory errors and were rerun with the same configuration
  • The edge window remains 160 characters
  • On MCP, differences from the text-only encoder have intervals spanning zero
  • Its three-seed AUROCs are reported in Table 22; the dispersion follows the archived report
  • AUROC dispersion is the source-reported three-seed SD
  • Component removals use G3_p25 as reference
  • The local gate adds no monitoring API request, but still uses local compute; its compute cost is not monetized
  • A mutable backbone is trained at each stage with current examples and a buffer of 100 historical examples with cached probabilities
  • On the G3 cross-dataset panel, snapshot minus Replay yields ACC +0.1308 [0.0911,0.1910] and forgetting -0.0551 [-0.1185,-0.0169]
  • Accuracy is percent; forgetting is on [0,1]
  • Rows correspond to the same panels as Table 25
  • The formal rerun uses GRAD's G3 ModalityNormGNN with 512-character node windows and 160-character edge windows
  • All continual-learning arms use 200 updates with development-AUROC selection and no mining
  • CAA improves accuracy over Replay by 13.08 percentage points under the original endpoint and by 9.05 points with equal family/base-case weights
  • The original endpoint is listed first
  • The original analysis averages the two orders within each seed and bootstraps the five paired seed differences
  • Across 1,000 draws, the sample-pooled difference has a $95\%$ interval of [7.72, 19.94] points
  • Table 29 shows that Decomp and MRT drive the aggregate improvement under both weights
  • The remaining sample-level gains are 18.66, 2.56, and 14.86 points for Decomp, MCP, and MRT. For MRT, this removes one of five families (20%)
  • Intervals use the original seed-only paired bootstrap
  • For Decomp, the numeric case identifier groups harmful and benign counterparts with the mixture variants of the same base case
  • The grouping units differ: Decomp groups variants of a base case, MCP combines generated pairs and runtime templates, and MRT groups scenarios
  • Snapshot centroid, Replay, and stage-0 centroid achieve 47.5%, 53.5%, and 50.1%, compared with sample-level accuracies of 51.11%, 39.21%, and 53.18%
  • Table 3 averages AUROC across the three separately trained models; its standard deviation uses denominator three
  • GRAD–Text-only differences are 7.67/10.99/13.26 points with intervals [2.47,13.41], [5.28,17.20], and [7.50,19.38]
  • The W4 reanalysis resamples the same 58 base-case groups jointly across methods and seeds, recomputing each seed's AUROC and then averaging paired differences within each draw
  • This differs from the original W1 threshold selection in Table 3
  • The sequential monitor reuses cumulative binary judgments for all 232 cases from 2,267 cached DeepSeek calls (historical cost CNY 0.4671; no additional calls)
  • These categories correspond to the AI-assistance disclosure submitted with the paper
  • This included revising wording for clarity, reducing repetition, organizing paragraphs, and adjusting manuscript presentation
  • This use supported discovery of candidate references and connections to the topics discussed in the paper
  • This assistance extended beyond manuscript preparation and is disclosed as a separate use
  • Reported numerical findings are based on recorded experimental outputs and the aggregation procedures described in the paper