MAGE: Safeguarding LLM Agents against Long-Horizon Threats via Shadow Memory

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Wang, Yuhui, Jiang, Tanqiu, Liang, Jiacheng, Fleming, Charles, Wang, Ting
Format: Preprint
Published: 2026
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866914528668680192
author Wang, Yuhui
Jiang, Tanqiu
Liang, Jiacheng
Fleming, Charles
Wang, Ting
author_facet Wang, Yuhui
Jiang, Tanqiu
Liang, Jiacheng
Fleming, Charles
Wang, Ting
contents As large language model (LLM)-powered agents are increasingly deployed to perform complex, real-world tasks, they face a growing class of attacks that exploit extended user-agent-environment interactions to pursue malicious objectives improbable in single-turn settings. Such long-horizon threats pose significant risks to the safe deployment of LLM agents in critical domains. In this paper, we present MAGE (Memory As Guardrail Enforcement), a novel defensive framework designed to counter a wide range of long-horizon threats. Inspired by the "shadow stack" abstraction in systems security, MAGE maintains a dedicated, safety-focused agentic memory that distills and retains safety-critical context across the agent's full execution trajectory, leveraging this shadow memory to proactively assess the risk of pending actions prior to their execution. Extensive evaluation demonstrates that MAGE substantially outperforms existing defenses across diverse long-horizon threats in detection accuracy, achieves early-stage detection for the majority of attacks, and introduces only negligible overhead to agent utility. To our best knowledge, MAGE represents the first framework to detect and mitigate long-horizon threats using an agentic memory approach, establishing a new paradigm for this critical challenge and opening promising directions for future research.
format Preprint
id arxiv_https___arxiv_org_abs_2605_03228
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle MAGE: Safeguarding LLM Agents against Long-Horizon Threats via Shadow Memory
Wang, Yuhui
Jiang, Tanqiu
Liang, Jiacheng
Fleming, Charles
Wang, Ting
Cryptography and Security
Artificial Intelligence
Computation and Language
As large language model (LLM)-powered agents are increasingly deployed to perform complex, real-world tasks, they face a growing class of attacks that exploit extended user-agent-environment interactions to pursue malicious objectives improbable in single-turn settings. Such long-horizon threats pose significant risks to the safe deployment of LLM agents in critical domains. In this paper, we present MAGE (Memory As Guardrail Enforcement), a novel defensive framework designed to counter a wide range of long-horizon threats. Inspired by the "shadow stack" abstraction in systems security, MAGE maintains a dedicated, safety-focused agentic memory that distills and retains safety-critical context across the agent's full execution trajectory, leveraging this shadow memory to proactively assess the risk of pending actions prior to their execution. Extensive evaluation demonstrates that MAGE substantially outperforms existing defenses across diverse long-horizon threats in detection accuracy, achieves early-stage detection for the majority of attacks, and introduces only negligible overhead to agent utility. To our best knowledge, MAGE represents the first framework to detect and mitigate long-horizon threats using an agentic memory approach, establishing a new paradigm for this critical challenge and opening promising directions for future research.
title MAGE: Safeguarding LLM Agents against Long-Horizon Threats via Shadow Memory
topic Cryptography and Security
Artificial Intelligence
Computation and Language
url https://arxiv.org/abs/2605.03228