DriftGuard: Online Memory-Drift Detection via Causal Attribution for LLM Agents

Licheng Pan, Zhixuan Chu, Kui Ren and colleagues at Zhejiang University, Peking University and Alibaba Group present DriftGuard, which detects which retrieved memory would change an agent's actions, using causal labels computed offline and a risk model that runs online without counterfactual rollouts.
Ask this paper
Offline supervision. Paired counterfactual replays continue a trajectory with and without each single memory from the same pre-action state. Majority voting turns the outcomes into a memory drift score covering action change, attack removal, violation removal and task recovery.
Online model. A learned risk model predicts that score from pre-action information only, so serving needs no replays.
Detection results. With a Gemma-4-12B agent on MINJA, DriftGuard reaches 0.92 AUROC versus 0.73 for few-shot Claude Opus 5 as a memory judge. It leads on all three poisoning benchmarks and three agent backbones.
Defense results. On Mem2ActBench, attack success falls from 46.7% to 5.3% under direct override and from 77.4% to 3.3% under sleeper memories, while task success rises from 47.7% to 77.3%.
Abstract
Large language model (LLM) agents rely on persistent memory to plan tool calls and complete multi-step tasks, which exposes them to memory drift: an adversarial or misleading memory alters the execution path and final outcome. In this work, we investigate online memory-drift detection, which estimates each retrieved memory's causal contribution to potential drift at serving time. We identify two fundamental challenges. (1) Content-level features are insufficient for causal memory-drift attribution, as perplexity or retrieval relevance alone cannot determine which retrieved memory would change agent behavior if neutralized; (2) Counterfactual attribution is prohibitively expensive for online detection, as it requires replaying downstream agent and tool execution for each candidate memory, exceeding real-time serving budgets. To address these challenges, we propose DriftGuard, a two-stage framework that decouples offline causal supervision from online estimation. Specifically, DriftGuard first constructs causal supervision through repeated paired counterfactual replays, continuing the original and single-memory neutralized trajectory suffixes from a shared pre-action state. The resulting annotations are aggregated by component-wise majority voting into a memory drift score (MDS) that captures action change, attack removal, violation removal, and task recovery. Guided by this supervision, DriftGuard then learns an online risk model that estimates MDS from pre-action information and flags drift-inducing memories via its maximum component risk, without online counterfactual rollouts. Extensive experiments demonstrate that DriftGuard accurately identifies drift-inducing memories and enables efficient online defense. Code is available at https://anonymous.4open.science/r/DriftGuard-7F0B.