arXiv(opens in a new tab)cs.CRSep 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2609.04875

Forgetting Without Restarting: Execution-State Unlearning for Stateful LLM Agents

Chao Yao, Yangbo Wei, Zhen Huang, Junhong Qian, Chenle Chen, Shaoqiang Lu, Chen Wu, Lei He

Abstract

Long-running LLM agents are stateful: beyond the transcript they accrete compressed summaries, plaintext memory, pending tool plans, and—under every serving API—a KV cache. Yet today's “forget” operations delete a plaintext memory record and stop, leaving every artifact derived from the revoked information intact. We formalize execution-state unlearning: after a forget request, the agent must behave as if it had never observed the target. Modeling the runtime as a deterministic transition system, we prove that the pre-target trajectory prefix is shared with this counterfactual world for free, that the post-target suffix is irreducibly tainted without token-level attribution, and that exact unlearning requires at least T−τ+1T - \tau + 1 recomputed transitions, where τ\tau is the target's injection step. Provenance-Guided Selective Replay attains this bound as a cross-layer contract spanning prompt, compressed memory, and cache: a provenance graph locates the injection point, checkpoint restoration reduces to cropping the KV cache, and sanitized replay regenerates the counterfactual suffix. Audited with elicitation, stochastic, and string-free behavioral tests across three agent suites, nine baselines, and three model families, memory deletion leaves leakage unchanged, instruction-based forgetting collapses under elicitation (Leak@probes = 1.00), and source redaction still acts on a revoked preference in 80% of episodes—while selective replay is indistinguishable from a full reset at up to 9×9\times fewer recomputed tokens.

Introduction

Within months of release, agent frameworks such as OpenClaw (Steinberger 2026) and Hermes Agent (Nous Research 2026) accumulated hundreds of thousands of deployments as always-on personal agents that run for weeks, operate tools, and remember their users. What makes them useful is precisely that they are stateful: a modern runtime layers the transcript; context compaction that rewrites older turns into model-authored summaries; plaintext long-term memory re-injected at session start (Packer et al. 2023; Chhikara et al. 2025); tool traces and pending plans; and, beneath all of these, the KV cache—universal serving infrastructure reused across requests by every engine and commercial API (Kwon et al. 2023; Zheng et al. 2024; Gim et al. 2024). Whatever enters an agent's context is compressed into summaries, distilled into plans, persisted into memory, and materialized as cached tensors (Figure 1). This collides with an equally basic

*Corresponding author.

Copyright © 2027, Association for the Advancement of Artificial Intelligence (www.aaai.org). All rights reserved.

Figure

Figure 1: Execution-state unlearning at a glance. A target zz entering at step τ\tau splits the trajectory into a clean prefix and a suffix whose summaries, plans, and cache are all tainted (11). Deleting the memory record leaves that suffix intact—the agent still leaks or acts on zz (22). Selective replay restores S^τ−1\hat{S}_{\tau-1} by cropping the cache, then replays the sanitized suffix to S^T\hat{S}_T (33).

requirement: sometimes the agent must un-see something—a user revokes consent for a home address mid-session (European Parliament and Council of the European Union 2016), a secret is pasted by accident, or an indirect injection plants content inside a fetched page or tool result (Greshake et al. 2023). The last case is the common one and the user never witnesses it: the agent silently reads the injected content, folds it into its state, and moves on; the forget trigger, when it comes, comes from a detector or operator after the fact. Yet deployed stacks offer only a forgetting affordance that operates on plaintext at a single layer: delete the memory record, edit the Markdown file, drop the message from retrieval. The industry has equated forgetting with un-indexing.

We show systematically that this equation fails, and that the failure is invisible to the string-matching evaluations used to certify it. On three agent suites instrumented with mem-ory injection, compaction, and tool use (Wu et al. 2025; Lu et al. 2024; Debenedetti et al. 2024), deleting the persistent memory record leaves leakage exactly unchanged from doing nothing (0.86–1.00 any-leak): the target survives in the session's derived state. An instruction to forget looks far better on a single task-shaped probe, but under a six-probe elicitation audit the same state yields the target with probability 1.00—merely suppressed. Source redaction fails more subtly: the model's own summary re-encodes the target in paraphrase, beyond any forbidden-string list, and in a behavioral test the redacted agent still acts on a revoked preference in 80% of episodes while emitting the string zero times. String metrics certify precisely the methods that fail. Even information-flow control (Costa et al. 2025), which blocks tainted future flows, cannot clean state already contaminated: an IFC-only baseline leaks at the no-forget rate.

What should “forget” mean for a running agent? We argue for a counterfactual criterion: future behavior must be indistinguishable from a twin agent that never observed the target. Modeling the runtime as a deterministic transition system, we define the counterfactual trajectory induced by deleting the target z from the observation stream at its injection step τ\tau, and call an operator an exact execution-state unlearner if it maps the real final state to the counterfactual one; unlike parameter unlearning (Cao and Yang 2015; Bourtoule et al. 2021; Maini et al. 2024), the edited object is non-parametric runtime state, where exactness is attainable. The formalism yields sharp structure: a prefix-sharing lemma makes the first τ−1\tau-1 counterfactual steps free (the clean prefix is literally a prefix of the contaminated cache, so restoring it is a crop); a taint lemma shows that without token-level attribution every artifact at or after τ\tau is unsalvageable—computation cannot be edited, only replayed. A splicing theorem then proves checkpoint-and-replay reconstructs the counterfactual state exactly, with a matching T−τ+1T - \tau + 1 lower bound: forgetting cost is governed by the counterfactual divergence, not the session length.

We realize this as Provenance-Guided Selective Replay, an auditable cross-layer contract from prompt to compressed memory to KV cache: an artifact-level provenance graph recorded during execution, sparse metadata-only checkpoints whose restoration is a cache crop, and sanitized replay with shadow-executed, deduplicated consequential tools. Because string matching cannot certify forgetting, we audit with Leak@probes (six elicitation probes), Leak@5 (stochastic samples), a string-free behavioral-extraction suite, and counterfactual-action divergence, each anchored to a measured false-positive floor. Selective replay sits at the floor on every axis while recomputing up to 9×9\times fewer tokens than a full reset, with cost tracking the proven T−τ+1T - \tau + 1 line ( R2≈1R^2 \approx 1); results reproduce across Llama-3.1-8B, Qwen2.5-7B, and Mistral-7B.

Our contributions: (1) Problem: execution-state unlearning for stateful LLM agents, formalized via counterfactual equivalence over reconstructible runtime state—the layer today's forget operations silently skip. (2) Theory: the prefix-sharing and certifiable-taint-boundary lemmas, an exact splicing theorem, and T−τ+1T - \tau + 1 optimality. (3) System: Provenance-Guided Selective Replay, composing provenance, crop-as-restore checkpoints, and side-effect-safe replay into one forgetting contract. (4) Audits and evidence: elicitation, stochastic, and string-free behavioral audits with measured floors; nine baselines on three suites and three model families—every deployed-style forget fails at least one audit; selective replay matches a full reset at a fraction of its cost.

References (23)