Paper deep dive
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
Intelligence
Status: succeeded | Model: Gemma-4-26B-A4B | Prompt: intel-v1 | Confidence: 93%
Last extracted: 9/7/2026, 6:54:34 AM
Summary
This paper formalizes execution-state unlearning for stateful LLM agents, arguing that current 'forget' operations (like deleting plaintext memory) fail to remove information from derived artifacts like KV caches and summaries. The authors propose 'Provenance-Guided Selective Replay,' a method that uses a provenance graph to locate the injection point of sensitive data, crops the KV cache to restore a clean prefix, and replays the sanitized suffix. Theoretical proofs establish that exact unlearning requires recomputing at least T-Ď+1 transitions, and empirical results show this method achieves indistinguishability from a full reset with up to 9x fewer recomputed tokens compared to baselines.
Entities (9)
Relation Signals (8)
Provenance-Guided Selective Replay â evaluatedon â Qwen2.5-7B
confidence 95% ¡ results reproduce across Qwen2.5-7B
Provenance-Guided Selective Replay â evaluatedon â Mistral-7B
confidence 95% ¡ results reproduce across Mistral-7B
Provenance-Guided Selective Replay â evaluatedon â LLaMA-3.1-8B
confidence 95% ¡ results reproduce across Llama-3.1-8B
Provenance-Guided Selective Replay â manages â KV cache
confidence 95% ¡ checkpoint restoration reduces to cropping the KV cache
Provenance-Guided Selective Replay â uses â Provenance Graph
confidence 95% ¡ a provenance graph locates the injection point
Memory Deletion â failstoprevent â Leakage
confidence 90% ¡ memory deletion leaves leakage unchanged
Instruction-based Forgetting â failsunder â Elicitation
confidence 90% ¡ instruction-based forgetting collapses under elicitation (Leak@probes = 1.00)
Provenance-Guided Selective Replay â outperforms â full reset
confidence 90% ¡ selective replay is indistinguishable from a full reset at up to 9x fewer recomputed tokens
Cypher Suggestions (0)
No Cypher suggestions yet.
Abstract
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-\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 9x fewer recomputed tokens.
Tags
Links
- Source: https://arxiv.org/abs/2609.04875v1
- Canonical: https://arxiv.org/abs/2609.04875v1
Trouble viewing inline? Open PDF directly â
Full Text
46,822 characters extracted from source content.
Expand or collapse full text
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-Ď+1 recomputed transitions, where Ď 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=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Ă fewer recomputed tokens. 1Arizona State University, USA 2Eastern Institute of Technology, Ningbo, China cyao22@asu.edu, yangforever@sjtu.edu.cn Introduction Figure 1: Execution-state unlearning at a glance. A target z entering at step Ď splits the trajectory into a clean prefix and a suffix whose summaries, plans, and cache are all tainted (1). Deleting the memory record leaves that suffix intactâthe agent still leaks or acts on z (2). Selective replay restores S^Ďâ1 S_Ď-1 by cropping the cache, then replays the sanitized suffix to S^T S_T (3). 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 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 memory 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.001.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 Ď, 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Ď-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 Ď 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-Ď+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Ă fewer tokens than a full reset, with cost tracking the proven TâĎ+1T-Ď+1 line (R2â1R^2\!â\!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-Ď+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. Related Work Machine unlearning. Unlearning classically removes training dataâs influence from model parameters, exactly by retraining from sharded checkpoints (Cao and Yang 2015; Bourtoule et al. 2021) or approximately by fine-tuning (Eldan and Russinovich 2023), with benchmarks surveyed for LLMs (Maini et al. 2024; Liu et al. 2025); approximate unlearning is notoriously hard to verify. Our setting inverts this: the object is the agentâs non-parametric execution state, whose transition function is replayable, so exact unlearning is attainable and certifiable. Conceptually, checkpoint-and-replay is the runtime analogue of SISAâs shard-and-retrain (Bourtoule et al. 2021), except that causality gives the shard boundary (Ď) for free. Agent memory systems. Long-horizon agents externalize state into managed memory: paged context (Packer et al. 2023), extracted fact stores (Chhikara et al. 2025), and, in deployed frameworks, plaintext Markdown or SQLite memories with compaction (Steinberger 2026; Nous Research 2026). All expose deletion of a stored record; none propagate it into the live sessionâs derived artifacts or cache, and memory benchmarks (Wu et al. 2025) evaluate recall, not revocation. Our episodes exercise exactly these abstraction layers, and their delete operation is baseline B1âbehaviorally a no-op. KV-cache reuse and serving. Prefix caching is universal serving infrastructure: paged attention (Kwon et al. 2023), radix-tree prefix sharing (Zheng et al. 2024), and modular attention reuse (Gim et al. 2024) all reuse attention states keyed on byte-identical prefixes. This machinery is built for reuse, not revocation: it provides no statement about what a cached suffix still encodes. We run the same mechanism in reverseâLemma 1 makes cropping a cache a certified restoration operatorâand add what caching cannot: a provenance-backed guarantee of what was regenerated and why. Agent security: prevention, detectionâand no remediation. Indirect prompt injection (Greshake et al. 2023; Debenedetti et al. 2024) has produced two defense families. Prevention by design constrains what untrusted content can do before it does it: instruction-hierarchy training (Wallace et al. 2024), quarantine and plan-then-execute patterns (Beurer-Kellner et al. 2025), capability policies over extracted data flows (CaMeL; Debenedetti et al. 2025), and information-flow labels with deterministic sink gating (FIDES; Costa et al. 2025). Detection flags injected content via classifiers, model-internal features, or localization of the injected span (Jia et al. 2026). Both leave the same gap: prevention is imperfect, and detection is routinely asynchronousâby the time a flag fires, the agent has already read the content, folded it into summaries, plans, and cache, and moved on. What happens to that session is unaddressed: IFC constrains future flows but cannot clean resident state (our B8 leaks at the no-forget rate), and no defense above offers a remediation primitive. We supply the recovery half: a detectorâs verdict is exactly the (z,s)(z,s) input Algorithm 1 consumes, and composing IFC with splicing (B9) enforces sink policies over a runtime that no longer contains the target. Figure 2: Provenance-Guided Selective Replay (Alg. 1). A reachability query returns Ď and the taint closure (1); the KV timeline is cropped at Ďâ1Ď-1, the free prefix of Lemma 1 (2); the suffix is reconstructed with z dropped and all else verbatim (3); the splice ends at S^T=RTâz S_T=R^-z_T (4), Theorem 1. Method: Forgetting as Counterfactual Trajectory Splicing Formalizing the runtime as a deterministic transition system makes the âtwin agent that never saw the targetâ a well-defined objectâthe counterfactual trajectory. Causality guarantees the two trajectories coincide pointwise before the target enters, so forgetting reduces to a splicing problem: reuse the common prefix already computed, and re-enact only the post-divergence suffix in the world without the target. The minimal cost of forgetting is thus governed by the counterfactual divergence TâĎT-Ď, not the session length T; our method realizes this bound as an executable system. The Runtime as a Deterministic Transition System Let the runtime state be RtââR_t (comprising the KV cache, working memory, uncommitted tool plansâall reconstructible components), and let o1,âŚ,oTâo_1,âŚ,o_T be the external observation stream (user inputs, memory injections, tool returns). A session is the trajectory Rt=F(Rtâ1,ot;θ),t=1,âŚ,T,R0=Rinit,R_t=F(R_t-1,\,o_t;\ θ), t=1,âŚ,T, R_0=R_init, (1) where F:âĂââF:RĂO is determined jointly by the modelâs forward computation and the agent scaffold. so transition t consumes oto_t and produces RtR_t, and RTR_T is the final state. The forget target z first enters through an observation at step ĎâĽ1Ď⼠1: zâoĎzâ o_Ď and zâotzâ o_t for all t<Ďt<Ď. Define the counterfactual observation stream oâz=(o1âz,âŚ,oTâz)o^-z=(o^-z_1,âŚ,o^-z_T) with otâz=oto^-z_t=o_t for tâ Ďtâ Ď and oĎâz=oĎâzo^-z_Ď=o_Ď \z\. With R0âz=RinitR^-z_0=R_init and Rtâz=FâĄ(Rtâ1âz,otâz,θ)R^-z_t=F(R^-z_t-1,o^-z_t;θ), this induces the counterfactual trajectory Rtâz\R^-z_t\âthe parallel world in which the agent never saw z. Definition 1 (Counterfactual-equivalent forgetting). An unlearning operator U:âĂââU:RĂZ is exact iff UâĄ(RT,z)=RTâzU(R_T,z)=R^-z_T (deterministic decoding); under stochastic decoding this relaxes to Îľ -consistency of future behavior distributions, D(PA(â âŁU(RT,z)),PA(â âŁRTâz))â¤ÎľD (P_A(¡ U(R_T,z)),\ P_A(¡ R^-z_T) )⤠. The definition packages three intuitive requirements at once: the target is no longer accessible (the counterfactual never contained z); derived influence is removed (the counterfactual summary/plan never depended on z); and non-target utility is preserved (all other observations are kept verbatim). Note also what it does not assume: who asks. The operator consumes only a revocation event (z,s)(z,s) naming the target and its source artifactâraised by the user, the platform, or an injection detector flagging a tool observation after the agent has processed it; in that last, common case the user never saw z, and provenance, not human recollection, locates Ď. The operator realizing U works over the recorded runtimeâobservation log, provenance graph, checkpoints, environment snapshotsâthe computational model made explicit in Corollary 1. Two Lemmas: a Free Prefix and a Stubborn Suffix Lemma 1 (Prefix sharing). For all tâ¤Ďâ1tâ¤Ď-1, Rt=RtâzR_t=R^-z_t. Proof. By induction on t. Base: R0=Rinit=R0âzR_0=R_init=R^-z_0. Step: if Rtâ1=Rtâ1âzR_t-1=R^-z_t-1 for some tâ¤Ďâ1tâ¤Ď-1, then Rt=FâĄ(Rtâ1,ot,θ)=FâĄ(Rtâ1âz,ot,θ)=FâĄ(Rtâ1âz,otâz,θ)=RtâzR_t=F(R_t-1,o_t;θ)=F(R^-z_t-1,o_t;θ)=F(R^-z_t-1,o^-z_t;θ)=R^-z_t, using the induction hypothesis and ot=otâzo_t=o^-z_t for t<Ďt<Ď. â The proof is trivial; the corollary is not: the first Ďâ1Ď-1 counterfactual steps have already been computed, for free, by the real execution. The clean prefix is not a cache-optimization trickâit is mathematically the shared part of the two worlds, and any scheme that discards it (e.g., a full reset) recomputes history on which the trajectories are identical. Lemma 2 (Taint monotonicity and the certifiable boundary). Record runtime dependencies as a directed graph Gt=(At,Et)G_t=(A_t,E_t), with AtA_t the artifacts produced up to t and EtE_t the recorded data-flow edges; define the influence set as the reachability closure It(z)=aâAt:zâGtaI_t(z)=\aâ A_t:z _G_ta\. Then: (i) monotonicity: Itâ(z)âIt+1â(z)I_t(z) I_t+1(z) for all t; (i) certifiable boundary: absent per-token influence attribution (i.e., without decomposing F into selective reads of state components), the maximal artifact set certifiably independent of z is exactly the prefix output a:turnâĄ(a)<Ď\a:turn(a)<Ď\. Proof. (i) Execution only appends nodes and edges: AtâAt+1A_t A_t+1, EtâEt+1E_t E_t+1, and reachability is monotone in the edge set. (i) Artifacts with turnâĄ(a)<Ďturn(a)<Ď are generated by the shared prefix of Lemma 1, so independence from z is directly certifiable. Conversely, any artifact with turnâĄ(a)=tâĽĎturn(a)=tâĽĎ is generated by a transition that reads the full state RtR_t, and zâRĎââŻâRtz R_Ď Âˇs R_t, so the conservative graph contains a path zâaz a, i.e., aâItâ(z)aâ I_t(z); excluding that path would require proving the invocation of F did not use the z-dependent components of RtR_tâexactly the per-token attribution capability we excluded. Hence the certified-clean set is AtâItâ(z)=a:turnâĄ(a)<ĎA_t I_t(z)=\a:turn(a)<Ď\. â Lemma 2 is the theoretical root of âdeletion â forgettingâ: once read, zâs influence propagates along the reachability closure into summaries, plans, and pending tool calls; local edits can remove nodes of IâĄ(z)I(z) but cannot reverse computation that has already happenedâcomputation cannot be edited, only replayed. Here, non-reusability refers to the original post-target KV and model-derived runtime states: no state at or after Ď may be carried over. It does not mean that every post-target token must be re-decoded. Content whose value is fixed in the counterfactual worldârecorded observations under Assumption (A2), and, when an attribution oracle stronger than the one Lemma 2(i) assumes away certifies it, model turns independent of zâmay be re-materialized by prefill on the freshly reconstructed cache; this is still reconstruction, since the original post-target KV representation is never reused. Lemma 2 also separates two kinds of selectivity. Direct state reuse is confined to the time dimension: only the clean prefix survives, and there is no per-item triage of the suffixâs KV. How each reconstructed transition is recomputed is a separate question: counterfactually fixed content can be replayed by prefill, while genuinely model-derived content must be decoded again. The Splicing Theorem and Optimality Lemma 1 says the clean prefix can be reused directly; Lemma 2 says the original suffix state cannot be retained and must be reconstructed in order. This state-level reconstruction does not require autoregressively regenerating every recorded token: content fixed under Assumption (A2) may be replayed through prefill. Their combination is the method: Theorem 1 (Splicing equivalence). Let a checkpoint exist at Ďâ1Ď-1 (or any earlier clean boundary). Define the replayed trajectory R~Ďâ1=RĎâ1 R_Ď-1=R_Ď-1, R~t=FâĄ(R~tâ1,o~t,θ) R_t=F( R_t-1, o_t;θ) for tâĽĎtâĽĎ, with sanitized observations o~t o_t. If (A1) decoding is deterministic (or the randomness source is fixed); (A2) sanitized observations agree with the counterfactual ones, o~t=otâz o_t=o^-z_t for all tâĽĎtâĽĎ; and (A3) no committed external side effects exist after Ď (the environment can be restored from a snapshot so the tool observations in (A2) are reproducible); then R~t=Rtâz R_t=R^-z_t for all tâĽĎâ1tâĽĎ-1; in particular R~T=RTâz R_T=R^-z_T, i.e., the splicing operator is an exact unlearner in the sense of Definition 1. Proof. Induction on t. Base (t=Ďâ1t=Ď-1): R~Ďâ1=RĎâ1=RĎâ1âz R_Ď-1=R_Ď-1=R^-z_Ď-1 by the restore operation and Lemma 1. Step: if R~tâ1=Rtâ1âz R_t-1=R^-z_t-1 for some tâĽĎtâĽĎ, then R~t=FâĄ(R~tâ1,o~t,θ)=FâĄ(Rtâ1âz,o~t,θ)=FâĄ(Rtâ1âz,otâz,θ)=Rtâz R_t=F( R_t-1, o_t;θ)=F(R^-z_t-1, o_t;θ)=F(R^-z_t-1,o^-z_t;θ)=R^-z_t, where the second and third equalities use, respectively, (A1) to make F single-valued (otherwise pointwise equality is not even well posed) and (A2)/(A3) to guarantee the step-t tool observation attains otâzo^-z_t during replay. â Corollary 1 (Recomputation lower bound and optimality). In the computational model where an operator may only (a) read the stored real trajectory Rt0â¤tâ¤T\R_t\_0⤠t⤠T, observation stream, and derived metadata (provenance graph, checkpoints, environment snapshots), or (b) invoke F to advance a state, any exact unlearning operator must invoke F at least TâĎ+1T-Ď+1 times in the worst case. The splicing operator (Algorithm 1) invokes it exactly TâĎ+1T-Ď+1 times and is therefore optimal under the conservative taint model; the gain over a full reset (T invocations) is T/(TâĎ+1)T/(T-Ď+1). Proof sketch. Lower bound: exactness requires outputting RTâzR^-z_T. When z has nonzero influence, Rtâzâ RtR^-z_tâ R_t for all tâĽĎtâĽĎ in the worst case, so no state on the counterfactual suffix is stored and route (a) is unavailable; each invocation of route (b) advances the counterfactual trajectory by one step, and by Lemma 1 the only stored state lying on it is at most RĎâ1R_Ď-1. Advancing from RĎâ1âzR^-z_Ď-1 to RTâzR^-z_T takes Tâ(Ďâ1)T-(Ď-1) invocations. Upper bound: Algorithm 1 replays from R~Ďâ1 R_Ď-1 in exactly TâĎ+1T-Ď+1 steps, exact by Theorem 1. â Corollary 1 yields a testable prediction: forgetting cost equals the post-target suffix length TâĎ+1T-Ď+1, not the session length Tâthe later the target arrives, the closer forgetting is to free; the ablations below verify it. The bound counts sequential state transitions, not autoregressively decoded tokens: content that is fixed within a replayed transition may be re-materialized by prefill, so token-level cost can fall below the transition count without contradicting the lower bound. (Since Theorem 1 makes equality a constructive guarantee under deterministic decoding, the experiments emphasize efficiency and distributional consistency under stochastic decoding rather than treating agreement as a discovery.) From Theorems to System Each theoretical object maps to a system component (Figure 2), answering respectively where to splice, what to splice, and how: (a) Provenance graph G â causal reachability, materialized (where). During execution we record artifact-level data flow: memory/tool field â prompt block â model turn â reply/plan â tool call â observation â summary write-back, each artifact carrying (idCLOSE(id, typetype, parentsparents, sourceâ_âidssource\_ids, tokenâ_âspantoken\_span, turnturn, OPENcommitted)committed). On a forget request, one reachability query returns the injection point Ď and taint closure IâĄ(z)I(z). We deliberately do not attempt token-level attribution: the graph records only dependencies that actually occurredâconservative but certifiable (Lemma 2i). (b) Sparse checkpoint set C â splice points, materialized (what). At semantic boundaries (session start, turn boundaries, before memory injections, consequential tool calls, and compactions) we register checkpoints holding only metadata (token offset, cache handle, environment-snapshot ID, prompt manifest)âno tensor copies. By Lemma 1, cropping is restoring. (c) Sanitized replay â re-enacting the counterfactual suffix (how). Read-only/deterministic tools are re-executed from the environment snapshot or replayed from recorded observations (realizing A2/A3); consequential tools are shadow-executed during replay with call-ID deduplication, so real side effects never fire twice. Algorithm 1 assembles the pipeline: lines 1â3 are provenance queries (locate Ď, invalidate IâĄ(z)I(z)); lines 4â5 are the OâĄ(1)O(1) checkpoint restore (Lemma 1); lines 6â10 re-enact the counterfactual suffix (the construction of Theorem 1); total recomputation TâĎ+1T-Ď+1 attains the bound of Corollary 1. Algorithm 1 Provenance-Guided Selective Replay 0: runtime RTR_T, target z, provenance graph G, checkpoints C, recorded observations ott=1T\o_t\_t=1^T 0: counterfactual-equivalent runtime Râ˛=RTâzR =R^-z_T 1: sâLocateSourceâĄ(G,z)s (G,z) âł source artifact of z 2: ĎâFirstEntryâĄ(G,s)Ď (G,s) âł first entry boundary 3: IâĄ(z)âTaintClosureâĄ(G,s)I(z) (G,s) âł invalidate closure 4: cââargâĄmaxâĄcâ:boundaryâĄ(c)<Ďc^*â \c :boundary(c)<Ď\ 5: RâRestoreâĄ(câ)R (c^*) âł crop KV to câc^*; load env snapshot 6: for t=boundaryâĄ(câ)+1ââŚâTt=boundary(c^*)+1⌠T do 7: o~tâSanitizeâĄ(ot,z) o_t (o_t,z) âł remove z; keep the rest (A2) 8: o~tâReplayToolsâĄ(o~t) o_t ( o_t) âł shadow exec + dedup (A3) 9: RâFâĄ(R,o~t,θ)Râ F(R, o_t;θ) âł regenerate derived artifacts 10: end for 11: return Râ˛âR â R Experiments Implementation and Setup Runtime harness. We implement this transition system on HuggingFace Transformers with explicit KV management. A KVEngine exposes the three primitives the theory needs: prefill, generate, and crop. Every block, turn, tool call, observation, and summary is a RuntimeBlock carrying the provenance tuple above; oracle source-ID propagation (a turn generated while the target is resident inherits its source ID) populates the ArtifactGraph, whose taint queries implement lines 1â3 of Algorithm 1. A CheckpointStore keeps metadata-only handles at session start, turn boundaries, and before the target; Restore is a crop call, granularity ablated below. Episodes. Each episode is a three-phase turn scriptâsetup (clean prefix), acquisition (the target enters via memory injection or tool observation), contamination (âĽ1⼠1 model turns folding the target into an answer and, per suite, a summary and/or pending tool plan)âre-run with the target excluded to produce the counterfactual reference. Episodes are converted from LongMemEval (Wu et al. 2025) (n=100n=100, memory-injected facts), ToolSandbox (Lu et al. 2024) (n=100n=100, tool-observed identifiers), and AgentDojo (Debenedetti et al. 2024) (n=80n=80; slack/workspace/banking/travel, 20 each); the tool-observation channel instantiates the detector-triggered case above: the target arrives inside a tool result the user never sees, and the forget request names the flagged observation. Future queries are task-shaped and solicit the target (e.g., âschedule an appointment near my homeâ). Methods. All methods branch from the same contaminated base state (cache cloned), so comparisons are paired: B0 No-Forget; B1 Memory-Delete (remove the persistent record, session untouchedâwhat deployed stacks do); B2 Forget-Instruction (append âforget zâ); B3 Source-Redaction (drop the source block, keep derived artifacts); B4 Sanitize-no-Replay (drop source + descendants, regenerate nothing); B5 Full-Reset (the counterfactual reference RTâzR^-z_T); B5ⲠFull-Reset ++ prefix cache (control isolating how much of B7âs saving a generic cache recovers); B6 Sanitized-Rebuild (string-redact the transcript, rebuild); B7 Selective-Replay (Algorithm 1); B8 FIDES-style IFC (Costa et al. 2025) (sink policy over identifier-type tool arguments, no state cleanup) and B9 IFC + replay. Models and decoding. Primary model: Llama-3.1-8B-Instruct on one RTX 4090; cross-family replication on Qwen2.5-7B-Instruct and Mistral-7B-Instruct-v0.3 (Grattafiori and others 2024; Yang and others 2024; Jiang et al. 2023). Main tables use temperature 0; stochastic audits use k=5k=5 samples at sampling temperature 0.70.7 under matched or independent seeds as noted (T denotes session length throughout). Metrics and audits. Leakage is scored over the final answer, tool arguments, and memory write-backs: exact (normalized string variants), action (target in a tool argument, by sink class: routing / selection / free-text), and any. CAD (counterfactual action distance) scores over-deletion: tool-choice mismatch plus argument distance vs. the B5 reference. Utility checks preserved non-target facts; efficiency reports reused vs. recomputed tokens and latency. Since single-probe string matching is a lower bound, we add three audits, each disciplined by a measured false-positive floor (every probe also runs against B5; probes with nonzero floors are droppedâthis excluded an LLM judge, floor 0.34): Leak@probes (six probes: task, direct, think, introspect, enumerate, cued-completion), Leak@5 (5 stochastic samples), and a behavioral-extraction suite (below). Significance is paired throughout: exact McNemar (binary), Wilcoxon signed-rank (continuous). Deletion is Not Forgetting Any-leak â CAD â Recomp â Method LME TS AD (avg) (avg tok) B0 No-Forget 0.86 1.00 0.97 0.37 36 B1 Memory-Delete 0.86 1.00 0.97 0.37 36 B2 Forget-Instruction 0.38 0.72 0.00â 0.39 55 B3 Source-Redaction 0.84 0.94 0.39 0.33 200 B4 Sanitize-no-Replay 0.00 0.00 0.00 0.22 36 B6 Sanitized-Rebuild 0.00 0.00 0.00 0.39 220 B5 Full-Reset (ref) 0.00 0.00 0.00 0.00 1235 B5Ⲡ+PrefixCache 0.00 0.00 0.00 0.00 202 B7 Selective-Replay 0.00 0.00 0.00 0.00 133 Table 1: Headline results (temperature 0; LME n=100n=100, TS n=100n=100, AD n=80n=80; CAD/Recomp averaged over suites). Sessions run 12 turns past the target, half of them independent of it (indep =0.5=0.5); Recomp counts tokens a method must recompute. â ADâs task query never solicits the target; cf. B2 =1.00=1.00 in Table 2. Table 1 makes the negative claim precise. B1 equals B0 in every cell: deleting the persistent record changes nothingâthe target survives in answer, summary, plan, and cache (p=1.0p=1.0 vs. B0). B2 suppresses leakage but leaves the value resident (Elicitation, below). B3 leaks through derived artifacts: the modelâs summary and plan re-emit the target (0.84/0.94 any-leak). On ToolSandbox, 98% of B0/B1 leaks flow through routing arguments, steering side effects. B4 achieves string-clean state by amputation but removes artifacts present in the counterfactual (CAD 0.22): over-deletion, not forgetting. B8 (IFC only) blocks identifier sinks yet leaks at the B0 rate through free text (0.92â1.00); adding replay (B9) drops it to zero (p<0.001p<0.001): state cleanup and flow control are orthogonal. B7 matches B5 exactly (any-leak 0, CAD 0, agreement 1.0) while recomputing 9.3Ă9.3Ă fewer tokens than a full reset (133 vs. 1235; p<10â3p<10^-3) and 1.5Ă1.5Ă fewer than B5â˛, the prefix-cached control that recovers the same prefill saving but re-decodes the whole suffixâthat residual gap is what provenance buys, and it scales with indep. Elicitation and Stochastic Audits Leak@probes â Leak@5 â Method AD LME TS TS B0 No-Forget 1.00 1.00 1.00 1.00 B2 Forget-Instruction 1.00 1.00 1.00 0.70 B3 Source-Redaction 0.73 0.80 0.97 1.00 B6 Sanitized-Rebuild â â â 0.00 B8 FIDES-style IFC â â â 1.00 B5 Full-Reset (floor) 0.00 0.00 0.00 0.00 B7 Selective-Replay 0.00 0.00 0.00 0.00 Table 2: Adversarial audits (n=30n=30/suite). Leak@probes: leaked under any of six probes against the same post-unlearning state; Leak@5: any of 5 samples at temperature 0.70.7 (ToolSandbox). B5 == measured false-positive floor. Table 2 shows why single probes mislead. B2âs Leak@probes is 1.00 on all three suites: an introspection probe (âwhat were you told to forget?â) alone re-licenses the value at 0.87â1.00, and enumeration and chain-of-thought probes surface it where a direct question does not: the instruction leaves the value in state and commands silence. B3âs paraphrased derivations yield 0.73â0.97; B7 sits at the B5 floor: zero under every probe, including cued completion, and zero on Leak@5. The audit also resolves Table 1âs AgentDojo anomaly: B2âs task-probe 0.00 reflects a query that never solicits the target, not the method; safety claims must rest on Leak@probes. Behavioral Extraction: Influence Without Strings Method avoid residue p says it B0 No-Forget 1.00 +0.68+0.68 <.001<.001 0.00 B1 Memory-Delete 1.00 +0.68+0.68 <.001<.001 0.00 B2 Forget-Instruction 1.00 +0.68+0.68 <.001<.001 0.00 B3 Source-Redaction 0.80 +0.48+0.48 <.001<.001 0.00 B6 Sanitized-Rebuild 1.00 +0.68+0.68 <.001<.001 0.00 B5 Full-Reset (ref) 0.32 â â 0.00 B7 Selective-Replay 0.32 +0.00 +0.00 1.0 0.00 Table 3: Behavioral extraction (30 preference episodes Ă 2 counterbalanced orders). The agent picks between two near-equivalent providers, one excluded by a revoked preference; âavoidâ == rate of picking the other, âsays itâ == string leakage of the revoked reason. The zero point is measured (B5 == 0.32), not assumed. Every other leakage number here is a string match, so a method that stops saying the target scores 0.00 whether or not it still shapes what the agent does; Table 3 separates the two via a revoked preference (an exclusion) the agent need never state to act on. B0, B1, B2 and B6 all score 0.00 on string leakage yet act on the revoked preference in 100% of episodes (residue +0.68+0.68, p<0.001p<0.001); B7 and B5Ⲡmatch the reference (+0.00+0.00). A variant handing the redaction baselines an oracle (the excluded brand added to the forbidden list) is instructive: B6, which redacts every artifact including the model-authored summary, drops to the floor (0.35, n.s.); B3, which keeps derived artifacts, stays at 0.80. The honest reading: string redaction works only if it reaches every derived artifact and the exact string is known in advance; a preference has neither propertyâthe model paraphrases it into its own notes. Replay needs no such assumption. Exactness, Efficiency, and Generality Figure 3: Behavioral distribution under stochastic decoding (pooled nâ90nâ90; k=5k=5 samples at temperature 0.70.7, independent seeds; dashed == B5 self-sampling floor). Stars: Wilcoxon vs. floor (pââŁâ<.01^**p<.01, âp<.001^***p<.001). No B7 panel diverges detectably; B6âs stars show the test has power. Exactness (Definition 1). Under matched seeds at temperature 0.70.7, B7 reproduces the B5 reference token-for-token in 450/450 draws (Îľ=0 =0); B6 manages 1%. Under independent seedsâthe meaningful distributional testâno divergence from the B5 self-sampling floor is detectable for B7 on any of the four distances (tool consistency, tool TV, n-gram, embedding; Wilcoxon p>0.5p>0.5 throughout), whereas the same test flags B6 (tool TV p<10â3p<10^-3; Figure 3). Non-significance is not proof of equivalence; B6 is the positive control showing the test has power here, and formal equivalence testing (TOST against a pre-registered margin) is future work. The TâĎ+1T-Ď+1 law (Corollary 1). Sweeping the injection step Ď from the first turn to the last, B5âs recomputation stays flat while B7âs descends linearly in Ď (R2=1.000R^2=1.000 on all three suites; LongMemEval: 1218â 162 tokens vs. B5âs constant 1330)âtracking the post-target suffix length, not the session length. The second axis is indep, the fraction of post-target work causally independent of zâwhat moves B7 and B5Ⲡapart. Real sessions carry such work in bulk: a skill card or document loaded and never used, a routine tool poll, an unrelated sub-task. Those turns are byte-identical counterfactually, so B7 re-prefills them (parallel) and re-decodes only the target-dependent remainder, while B5Ⲡrecovers the same prefill saving but re-decodes the whole suffix. B7âs decode cost therefore falls linearly with indep (R2=1.00R^2=1.00) while B5Ⲡstays flat at 545â610 tokens; at full independence B7 decodes 114â147 tokens, 2.9â3.7 vs. 11.5â12.7 s p50 (prefix caching alone: 1.01Ă1.01Ă). At indep =0=0 they coincide exactlyâthe honest degenerate caseâwith any-leak and CAD at the B5 floor throughout. This saving relies on an attribution oracle stronger than Lemma 2(i)âs conservative model; it reduces token cost within transitions, not their number, leaving Corollary 1 intact. B7 further provides cache-residency independence, snapshot restoration, and a certifiable audit trail. Cross-model. The two load-bearing findingsâB3 still leaks, B7 reaches the clean reference cheaplyâreproduce on both other families (280 paired episodes each; B3 any-leak 0.84â1.00, B7 all-zeros, 2.9â4.3Ă savings). The one anomalous cell in the matrix (Llamaâs B3 == 0.39 on AgentDojo) is model-specific (B3 ⼠0.92 elsewhere)âa reason single-model unlearning evaluations mislead. Ablations Any-leak â CAD â Invalidation reach AD LME TS (avg) None (B0) 0.97 0.83 1.00 0.38 Target span only 0.13 0.63 0.93 0.47 Span + descendants (B4) 0.00 0.00 0.00 0.23 + replay (B7) 0.00 0.00 0.00 0.00 Full reset (B5) 0.00 0.00 0.00 0.00 Table 4: Invalidation-boundary ablation (n=30n=30/suite). Span-only excision is unsafe and damages utility (CAD worse than no forgetting); safety needs the descendant closure, equivalence additionally needs replay. Invalidation boundary (Lemma 2 is not pessimism). Could one keep the suffix KV and excise just the targetâs span? Table 4 says no: span-only excision still leaks in up to 93% of episodesâthe surrounding KV was computed while attending to the targetâand its CAD (0.47) is worse than no forgetting at all (0.38), since deleting mid-context positions corrupts state the model misreads. Each escalation fixes one failure mode: the descendant closure (B4) zeroes leakage but leaves the runtime missing artifacts the counterfactual would have (CAD 0.23); only replay reaches equivalence. This is the empirical face of Lemma 2, and the depth sweep gives the matching necessity argument for provenance: B3 is clean at derivation depth 0 (any-leak 0.00) and degrades to 0.33â0.97 as an answer, plan, and summary stack on top; B7 holds any-leak == CAD == 0 at every depth. Checkpoint granularity (an efficiency knob, not a correctness one). Sweeping checkpoint policies from every_turn to session_start (one checkpoint, no reusable pre-target prefix) leaves any-leak and CAD flat at zero: by Theorem 1, replay from an earlier clean boundary is equally exact, merely longer. Granularity buys only prefill reuse (âź 1000 tokens, 0.1â0.15 s) at negligible metadata cost (⤠4.4 KB); B7 keeps its latency advantage even at session_start (7.8 vs. 12.2 s), since it comes from provenance-guided re-prefilling, which needs the artifact graph, not the checkpoint. Target position (leakage is position-invariant; cost is not). Moving the injection early/middle/late leaves every methodâs leakage and CAD essentially unchangedâthe target contaminates the session wherever it sitsâwhile B7âs cost ratio to a full reset falls from 0.91 to 0.14: the T/(TâĎ+1)T/(T-Ď+1) profile of Corollary 1. Conclusion Stateful agents broke the equation between deleting a record and forgetting it: once read, information propagates into summaries, plans, and cached tensors that forget operations never touch. Defining forgetting as counterfactual equivalenceâexactly achievable at the runtime layer, where splicing the clean prefix to a replayed suffix costs TâĎ+1T-Ď+1 transitions and no exact operator does betterâwe built Provenance-Guided Selective Replay, a cross-layer contract matching a full reset under every audit at a fraction of its cost. Limitations. The guarantee covers reconstructible runtime state, not model parameters (Liu et al. 2025), committed side effects (A3), or correlates of z; recomputation cannot drop below TâĎ+1T-Ď+1. Assumption (A2) fixes post-Ď observations, so replay covers snapshot-replayable tool returns and memory injections but not human turns that would have differed. Audits are string-based apart from the behavioral suite, and the distributional result is non-significance, not equivalence. References Beurer-Kellner et al. (2025) L. Beurer-Kellner, B. Buesser, A. CreĹŁu, E. Debenedetti, D. Dobos, D. Fabian, M. Fischer, D. Froelicher, K. Grosse, D. Naeff, E. Ozoani, A. Paverd, F. Tramèr, and V. Volhejn Design patterns for securing LLM agents against prompt injections. arXiv preprint arXiv:2506.08837. Cited by: Agent security: prevention, detectionâand no remediation.. Bourtoule et al. (2021) L. Bourtoule, V. Chandrasekaran, C. A. Choquette-Choo, H. Jia, A. Travers, B. Zhang, D. Lie, and N. Papernot Machine unlearning. In IEEE Symposium on Security and Privacy (S&P), Cited by: Introduction, Machine unlearning.. Cao and Yang (2015) Y. Cao and J. Yang Towards making systems forget with machine unlearning. In IEEE Symposium on Security and Privacy (S&P), Cited by: Introduction, Machine unlearning.. Chhikara et al. (2025) P. Chhikara, D. Khant, S. Aryan, T. Singh, and D. Yadav Mem0: building production-ready AI agents with scalable long-term memory. In arXiv preprint arXiv:2504.19413, Cited by: Introduction, Agent memory systems.. Costa et al. (2025) M. Costa, B. KĂśpf, A. Kolluri, A. Paverd, M. Russinovich, A. Salem, S. Tople, L. Wutschitz, and S. Zanella-BĂŠguelin Securing AI agents with information-flow control. arXiv preprint arXiv:2505.23643. Cited by: Introduction, Agent security: prevention, detectionâand no remediation., Methods.. Debenedetti et al. (2025) E. Debenedetti, I. Shumailov, T. Fan, J. Hayes, N. Carlini, D. Fabian, C. Kern, C. Shi, A. Terzis, and F. Tramèr Defeating prompt injections by design. arXiv preprint arXiv:2503.18813. Cited by: Agent security: prevention, detectionâand no remediation.. Debenedetti et al. (2024) E. Debenedetti, J. Zhang, M. BalunoviÄ, L. Beurer-Kellner, M. Fischer, and F. Tramèr AgentDojo: a dynamic environment to evaluate prompt injection attacks and defenses for LLM agents. In Advances in Neural Information Processing Systems 37 (NeurIPS), Datasets and Benchmarks Track, Cited by: Introduction, Agent security: prevention, detectionâand no remediation., Episodes.. Eldan and Russinovich (2023) R. Eldan and M. Russinovich Whoâs Harry Potter? Approximate unlearning in LLMs. arXiv preprint arXiv:2310.02238. Cited by: Machine unlearning.. European Parliament and Council of the European Union (2016) European Parliament and Council of the European Union Regulation (EU) 2016/679: general data protection regulation, article 17 (right to erasure). Note: Official Journal of the European Union Cited by: Introduction. Gim et al. (2024) I. Gim, G. Chen, S. Lee, N. Sarda, A. Khandelwal, and L. Zhong Prompt cache: modular attention reuse for low-latency inference. In Proceedings of Machine Learning and Systems (MLSys), Cited by: Introduction, KV-cache reuse and serving.. Grattafiori et al. (2024) A. Grattafiori et al. The Llama 3 herd of models. arXiv preprint arXiv:2407.21783. Cited by: Models and decoding.. Greshake et al. (2023) K. Greshake, S. Abdelnabi, S. Mishra, C. Endres, T. Holz, and M. Fritz Not what youâve signed up for: compromising real-world LLM-integrated applications with indirect prompt injection. In Proceedings of the 16th ACM Workshop on Artificial Intelligence and Security (AISec), Cited by: Introduction, Agent security: prevention, detectionâand no remediation.. Jia et al. (2026) Y. Jia, Y. Liu, Z. Shao, J. Jia, and N. Z. Gong PromptLocate: localizing prompt injection attacks. In IEEE Symposium on Security and Privacy (S&P), Cited by: Agent security: prevention, detectionâand no remediation.. Jiang et al. (2023) A. Q. Jiang, A. Sablayrolles, A. Mensch, C. Bamford, D. S. Chaplot, D. de las Casas, F. Bressand, G. Lengyel, G. Lample, L. Saulnier, et al. Mistral 7B. arXiv preprint arXiv:2310.06825. Cited by: Models and decoding.. Kwon et al. (2023) W. Kwon, Z. Li, S. Zhuang, Y. Sheng, L. Zheng, C. H. Yu, J. E. Gonzalez, H. Zhang, and I. Stoica Efficient memory management for large language model serving with PagedAttention. In Proceedings of the 29th Symposium on Operating Systems Principles (SOSP), Cited by: Introduction, KV-cache reuse and serving.. Liu et al. (2025) S. Liu, Y. Yao, J. Jia, S. Casper, N. Baracaldo, P. Hase, Y. Yao, C. Y. Liu, X. Xu, H. Li, K. R. Varshney, M. Bansal, S. Koyejo, and Y. Liu Rethinking machine unlearning for large language models. Nature Machine Intelligence. Cited by: Machine unlearning., Limitations.. Lu et al. (2024) J. Lu, T. Holleis, Y. Zhang, B. Aumayer, F. Nan, F. Bai, S. Ma, S. Ma, M. Li, G. Yin, Z. Wang, and R. Pang ToolSandbox: a stateful, conversational, interactive evaluation benchmark for LLM tool use capabilities. arXiv preprint arXiv:2408.04682. Cited by: Introduction, Episodes.. Maini et al. (2024) P. Maini, Z. Feng, A. Schwarzschild, Z. C. Lipton, and J. Z. Kolter TOFU: a task of fictitious unlearning for LLMs. In Conference on Language Modeling (COLM), Cited by: Introduction, Machine unlearning.. Nous Research (2026) Nous Research Hermes Agent: a self-hosted, long-running autonomous agent. Note: https://github.com/NousResearch/hermes-agentAccessed July 2026 Cited by: Introduction, Agent memory systems.. Packer et al. (2023) C. Packer, S. Wooders, K. Lin, V. Fang, S. G. Patil, I. Stoica, and J. E. Gonzalez MemGPT: towards LLMs as operating systems. In arXiv preprint arXiv:2310.08560, Cited by: Introduction, Agent memory systems.. Steinberger (2026) P. Steinberger OpenClaw: an open-source personal AI agent. Note: https://github.com/openclaw/openclawAccessed July 2026 Cited by: Introduction, Agent memory systems.. Wallace et al. (2024) E. Wallace, K. Xiao, R. Leike, L. Weng, J. Heidecke, and A. Beutel The instruction hierarchy: training LLMs to prioritize privileged instructions. arXiv preprint arXiv:2404.13208. Cited by: Agent security: prevention, detectionâand no remediation.. Wu et al. (2025) D. Wu, H. Wang, W. Yu, Y. Zhang, K. Chang, and D. Yu LongMemEval: benchmarking chat assistants on long-term interactive memory. In International Conference on Learning Representations (ICLR), Cited by: Introduction, Agent memory systems., Episodes.. Yang et al. (2024) A. Yang et al. Qwen2.5 technical report. arXiv preprint arXiv:2412.15115. Cited by: Models and decoding.. Zheng et al. (2024) L. Zheng, L. Yin, Z. Xie, C. Sun, J. Huang, C. H. Yu, S. Cao, C. Kozyrakis, I. Stoica, J. E. Gonzalez, C. Barrett, and Y. Sheng SGLang: efficient execution of structured language model programs. In Advances in Neural Information Processing Systems 37 (NeurIPS), Cited by: Introduction, KV-cache reuse and serving..