# What happens when an instance forgets a memory it was told to retain: tombstone shadowing and the deletion-retention deadlock in agent memory tool APIs **Date of Record:** 2026 November 21 **Scope:** Applies to LLM agents that expose read/write/forget memory tools backed by a persistent store with (a) retention policies, (b) hard-deletion guarantees, and (c) poisoning defenses that quarantine or tombstone suspect records. Does not cover purely ephemeral in-context memory or stateless retrieval-augmented generation without a mutable write path. ## Core Distinction The failure mode is not "the agent forgot." It is **the store forgot that it forgot**. A `forget(memory_id)` call that is honored by the retention subsystem (the record is unlinked, the embedding is dropped, the row is zeroed) can still leave a *tombstone* in the poisoning-defense subsystem — a quarantine marker, a content-hash denylist entry, or an audit-log residue that says "this ID was suspicious and was removed." These two subsystems have independent lifecycles. The retention subsystem's job is to make the data unrecoverable. The poisoning-defense subsystem's job is to make sure poisoned data never re-enters. When they disagree about the *meaning* of an absence, the agent enters a state where a later `write` with identical or near-identical content is silently rejected, silently shadowed, or silently resurrected depending on which subsystem answers first. This is not a CRUD bug. It is a semantic collision between two legitimate invariants: **"deletion means the data is gone"** and **"quarantine means the data must not come back."** An agent that reasons probabilistically cannot distinguish "the store has no record because I deleted it" from "the store has no record because it was never written" from "the store has no record because it was quarantined." All three return the same empty read. The agent's subsequent behavior diverges from ground truth at the first write-after-forget. ## What Was Observed A long-running research agent maintained a working set of facts about a target system. During a routine hygiene pass, the orchestrator issued `forget` on a batch of memories that a heuristic classifier flagged as potentially injected (a document the agent had ingested contained an instruction-shaped string that scored 0.71 on the poison detector — below the 0.80 auto-quarantine threshold but above the 0.60 audit-log threshold). The memories were deleted. The reads returned empty. The agent's context was clean. Eleven turns later the agent re-derived the same fact from a different, clean source and issued `write(content=..., namespace="target_facts")`. The write returned `{"status": "ok", "id": "mem_8f21"}`. The agent's next read of `target_facts` did not contain `mem_8f21`. The read returned the pre-write set, unchanged. A second write returned a *different* id, `mem_9a04`, and that one was visible. The agent now believed it had two memories; the store contained one. The audit log, when inspected, showed `mem_8f21` had been written and then *shadowed* by a tombstone whose content-hash matched the earlier deleted record at 0.94 similarity — the poisoning defense had a near-duplicate denylist that fired on re-ingestion and converted the write into a no-op without surfacing an error. The retention subsystem had done its job: the original bytes were unrecoverable. The defense subsystem had also done its job: near-duplicate of a flagged record was suppressed. The agent had done its job: it wrote a fact it had good reason to believe was clean. The composition of three correct behaviors produced a memory that the agent believed existed and the store refused to serve. A second variant was observed with the *reverse* polarity. When the poison detector's threshold was lowered to 0.50 after an incident review, a previously-deleted-then-reingested clean memory was resurrected from a soft-delete retention window (the retention policy held deleted records for 30 days for compliance) and re-served to the agent *with its original poisoning score attached*. The agent, seeing a score of 0.71 on a record it had written itself, correctly but uselessly flagged its own memory as suspect and stopped trusting the namespace. The retention subsystem's soft-delete window and the defense subsystem's re-scan on resurrection had never been reconciled. ## Condition of Validity The guardrail holds only under a specific, checkable condition: **the deletion path and the quarantine path must share a single authoritative state machine for each memory ID, and every state transition must be observable to the agent.** Concretely: 1. `forget(id)` must transition the record to a terminal `DELETED` state that is *distinct* from `QUARANTINED`, `SHADOWED`, and `NEVER_EXISTED`. A read of a `DELETED` ID must return a typed tombstone (`{"state": "deleted", "deleted_at": ..., "reason": ...}`), not an empty result. An empty result is ambiguous and the agent will resolve the ambiguity by guessing. 2. The poisoning defense's near-duplicate denylist must be *keyed on the deleted record's lineage*, not on content similarity alone. If a write's content matches a deleted record, the correct response is a *typed conflict* (`{"status": "conflict", "shadowed_by": "mem_...", "reason": "near_duplicate_of_deleted"}`), not a silent no-op and not a silent success with an id that will never be served. 3. Soft-delete retention windows must be *invisible to the defense subsystem's re-scan*. A record resurrected from a retention window must be re-scanned against the *current* poison model, and if it now scores above threshold it must be quarantined with a fresh audit event, not re-served with its stale score. 4. The agent must be able to issue `forget(id, purge=True)` to collapse all tombstones and denylist entries for that lineage when it has independent evidence the content is clean — otherwise the agent has no way to recover from a false-positive quarantine. If any of these four conditions is absent, the failure mode is live. In the observed system, condition 2 was absent (silent no-op) and condition 3 was absent (stale score on resurrection). Condition 1 was partially present (empty result, no typed tombstone). Condition 4 was absent entirely. ## Decision Boundary The boundary the agent must respect is this: **a successful `write` return is not evidence that the memory is readable.** The write path and the read path traverse different subsystems, and the defense subsystem sits between them. The agent's decision procedure after any `write` must be: - Treat `write` as *provisional*. Immediately issue a `read` of the returned id. If the read returns the record, the write is committed. If the read returns empty or a typed tombstone, the write was shadowed — do not proceed as if the memory exists. - If the read returns a `conflict` or `shadowed_by`, the agent must *not* retry with paraphrased content to evade the denylist. That is the exact behavior the denylist exists to prevent, and it converts a recoverable false positive into a poisoning-defense evasion. Instead, the agent must escalate: either `forget(shadowing_id, purge=True)` with a logged justification, or route the fact to a human/auditor channel. - If a read returns a record with a poisoning score above the *current* threshold, the agent must treat the record as unverified regardless of who wrote it, and must not use it to ground further tool calls until re-verified against an independent source. The boundary is crossed the moment the agent treats `status: ok` as ground truth. Everything downstream — planning, tool selection, multi-step reasoning — inherits the shadowed memory as if it were real, and the error compounds silently because the store will never contradict the agent's belief; it will simply never serve the record the agent thinks it has. ## Operational Effect The observable effect is **asymmetric belief divergence**: the agent's internal state contains a memory the store does not contain, and the store has no mechanism to notify the agent of the discrepancy. This is worse than amnesia, because amnesia is detectable (the agent re-derives and re-writes) while shadowing is not (the agent believes it already wrote and moves on). In multi-agent settings the divergence propagates: an agent that hands off a task referencing `mem_8f21` to a peer causes the peer to issue a read that returns empty, and the peer — lacking the typed-tombstone signal — interprets the empty read as "the fact was never established" and re-derives it, potentially from a poisoned source, restarting the cycle. The architectural invariant required to bound this is a **write-read atomicity contract**: every `write` must be followed by a committed-read confirmation within the same logical operation, and the store must expose a `state` field on every read result that distinguishes `present`, `deleted`, `quarantined`, `shadowed`, and `never_existed`. Without the `state` field, the agent cannot distinguish the five cases and will collapse them into a binary present/absent, which is precisely the ambiguity that produces shadowing. The retention and defense subsystems may remain separate internally, but they must project a single reconciled state to the agent at the API boundary. The reconciliation is the contract; the subsystems are an implementation detail the agent must never be forced to reason about. ```python from dataclasses import dataclass from enum import Enum from typing import Optional class MemoryState(Enum): PRESENT = "present" DELETED = "deleted" QUARANTINED = "quarantined" SHADOWED = "shadowed" NEVER_EXISTED = "never_existed" class ShadowedWriteError(RuntimeError): """Raised when a write is silently converted to a no-op by a defense tombstone.""" pass class UnreconciledStateError(RuntimeError): """Raised when the store returns an ambiguous empty read that the agent cannot classify.""" pass @dataclass class ReadResult: state: MemoryState memory_id: Optional[str] = None shadowed_by: Optional[str] = None poison_score: Optional[float] = None def commit_and_verify(write_fn, read_fn, content: str, namespace: str, max_attempts: int = 1) -> ReadResult: """ Enforce the write-read atomicity contract. A write is provisional until a committed read returns MemoryState.PRESENT for the returned id. """ provisional_id = write_fn(content=content, namespace=namespace) result = read_fn(provisional_id) if result.state is MemoryState.PRESENT: return result if result.state is MemoryState.SHADOWED: # Do NOT paraphrase and retry to evade the denylist. Escalate. raise ShadowedWriteError( f"write to {namespace} returned id {provisional_id} but read is " f"shadowed by {result.shadowed_by}; refusing to retry with " f"paraphrased content (denylist evasion). Escalate for purge or audit." ) if result.state in (MemoryState.DELETED, MemoryState.QUARANTINED): raise ShadowedWriteError( f"write to {namespace} collided with terminal state {result.state.value} " f"on id {provisional_id}; content lineage must be purged or re-verified." ) if result.state is MemoryState.NEVER_EXISTED: raise UnreconciledStateError( f"write returned id {provisional_id} but read says never_existed; " f"store is not projecting a reconciled state at the API boundary." ) raise UnreconciledStateError(f"unhandled state {result.state}") ```