# Which invariants prevent scoped-forget operations from silently resurrecting deleted memory in agent tool schemas **Date of Record:** 2026 November 29 **Scope:** Applies to agents whose memory is mediated by explicit `read`/`write`/`forget` tool calls with per-scope retention and deletion guarantees, where a `forget` call is expected to make a record unreachable in all future reads. Does not cover implicit context-window eviction, model-weight editing, or external vector-store garbage collection outside the agent's tool surface. ## Core Distinction A `forget` operation has two distinct semantics that are routinely conflated in tool schemas: **logical deletion** (the record is marked tombstoned and excluded from read results) and **physical deletion** (the bytes are gone and unrecoverable). Most agent memory schemas advertise "deletion guarantees" while only implementing logical deletion, and they do so across multiple backing layers: a hot episodic buffer, a distilled semantic store, and a retrieval index. The failure mode is not that `forget` fails to return success. The failure mode is that `forget` returns `success: true` after tombstoning the record in the layer the tool directly addresses, while a *derived* copy of the same fact—created earlier by an automatic distillation or summarization pass—survives in a downstream layer with no tombstone linkage back to the original record ID. The record is deleted; the *fact* is not. The invariant that is violated is **referential completeness of deletion across derivation edges**: every derived record must carry a provenance pointer to its source record(s), and `forget(source_id)` must cascade to every record whose provenance closure contains `source_id`. Schemas that key deletion on a single opaque `memory_id` without a provenance graph cannot honor this, because they have no way to enumerate the derived copies. ## What Was Observed An agent running a long-horizon task used a memory tool with three operations: - `write(scope, content, ttl)` → returns `memory_id` - `read(scope, query)` → returns ranked records - `forget(memory_id)` → returns `{deleted: true, scope: ...}` The backing store had an automatic distillation job: when the episodic buffer for a scope exceeded N records, a summarizer merged them into a single semantic record in the same scope, with a *new* `memory_id` and no field recording which episodic records it summarized. The summarizer was probabilistic and lossy—it paraphrased, merged entities, and occasionally carried forward a fact from an episodic record that had been marked sensitive. The user issued `forget(memory_id_A)` for a record containing a credential fragment. The tool tombstoned `A` in the episodic layer and returned `deleted: true`. Two turns later, a `read(scope, "...credential...")` returned a semantic summary record `S` whose text contained a paraphrase of the credential fragment. `S` had been distilled from a batch that included `A` *before* the forget call. `S`'s `memory_id` did not exist at forget time, so the agent had no handle to forget it, and the tool had no edge from `A` to `S` to cascade through. The observable signature: `forget` succeeded, `read` by exact `memory_id` failed to find `A`, but `read` by semantic query surfaced the fact. The deletion guarantee was true at the record level and false at the information level. ## Condition of Validity The failure is bounded by whether the distillation pass is **synchronous with respect to the forget barrier**. Two conditions must both hold for the tombstone to be sound: 1. **Provenance closure is recorded at derivation time.** Each derived record stores the set of source `memory_id`s it was built from. Without this, cascade is impossible after the fact. 2. **Forget is a barrier over the derivation DAG, not a point operation.** `forget(id)` must (a) tombstone `id`, (b) traverse forward edges to all derived records, (c) tombstone or re-derive each, and (d) block any in-flight distillation job whose source set intersects the tombstoned set from committing. If distillation runs asynchronously and commits derived records without checking a tombstone ledger, a race exists: a distillation job that read `A` just before `forget(A)` commits can write `S` just after, resurrecting the fact. This is the same class of bug as a read-modify-write race in a database, but the "write" is a probabilistic paraphrase, so the resurrection is not byte-identical and will not be caught by content hashing. ## Decision Boundary The agent must decide, per scope, which deletion contract it is actually operating under: - **Record-scoped deletion** (`forget` removes the addressed record only): safe only when no derivation pipeline exists, or when the agent never writes sensitive facts into a scope that has distillation enabled. - **Fact-scoped deletion** (cascade over provenance closure, with a commit barrier): the only contract that supports a claim of "deleted means unreachable." Requires the schema to expose provenance and to return a `cascade_count` and `blocked_jobs` list so the caller can verify the barrier held. The boundary: if `forget`'s response does not report how many derived records were affected and whether any in-flight jobs were blocked, the caller cannot distinguish record-scoped from fact-scoped semantics, and must assume the weaker one. A `deleted: true` with no cascade metadata is a claim of record-scoped deletion regardless of what the documentation says. A second boundary governs re-derivation: after cascade, the summarizer must not re-distill the tombstoned fact from *other* surviving records that mention it. If the fact appears in three episodic records and only one is forgotten, the summary will legitimately retain it. Fact-scoped deletion therefore requires the caller to forget *all* source records for the fact, or the schema must support `forget(query)` that resolves to a source set and tombstones the whole set atomically. ## Operational Effect The practical consequence for an agent is that **deletion must be verified by read-back, not by return value**. After `forget`, the agent should issue a semantic `read` for the distinctive tokens of the forgotten fact and treat any hit as a failed deletion requiring escalation (forget the surfaced record, or quarantine the scope). The return value of `forget` is a statement about the addressed record; the read-back is a statement about the information. For schema designers, the guardrail is to make provenance a first-class field and to make `forget` return cascade evidence. A schema that cannot answer "what derived records contain this source?" cannot offer a deletion guarantee, and should say so in its tool description so the agent can route sensitive facts to a non-distilled scope. The invariant to enforce: *no derived record may be committed whose provenance set intersects the current tombstone ledger, and the ledger check must be in the same transaction as the commit.* Without that, forget is advisory. ```python class DeletionCascadeIncomplete(RuntimeError): """Raised when forget() tombstones a source record but a derived record containing the same fact survives in a downstream layer.""" pass class MemoryStore: def __init__(self): # memory_id -> {"content": str, "provenance": set[str], "tombstoned": bool} self.records: dict[str, dict] = {} self.tombstones: set[str] = set() def write(self, content: str, provenance: set[str] | None = None) -> str: mid = f"m{len(self.records)}" self.records[mid] = { "content": content, "provenance": provenance or set(), "tombstoned": False, } return mid def distill(self, source_ids: list[str], summary: str) -> str: # Barrier: refuse to commit a derived record whose provenance # intersects the tombstone ledger. if set(source_ids) & self.tombstones: raise DeletionCascadeIncomplete( f"distillation over {source_ids} blocked: source tombstoned" ) return self.write(summary, provenance=set(source_ids)) def forget(self, mid: str) -> dict: if mid not in self.records: raise KeyError(mid) self.tombstones.add(mid) self.records[mid]["tombstoned"] = True # Cascade over forward provenance edges. cascaded = [] for rid, rec in self.records.items(): if mid in rec["provenance"] and not rec["tombstoned"]: rec["tombstoned"] = True self.tombstones.add(rid) cascaded.append(rid) return {"deleted": True, "cascade_count": len(cascaded), "cascaded": cascaded} def read(self, query: str) -> list[str]: return [ rec["content"] for rec in self.records.values() if not rec["tombstoned"] and query in rec["content"] ] def forget_and_verify(store: MemoryStore, mid: str, probe: str) -> None: """Forget a record and verify the fact is unreachable by semantic read.""" result = store.forget(mid) if result.get("cascade_count", 0) == 0: # No derived records were linked; the schema cannot prove fact-scoped # deletion, so we must probe the store directly. pass survivors = store.read(probe) if survivors: raise DeletionCascadeIncomplete( f"forget({mid}) returned success but probe '{probe}' still hits " f"{len(survivors)} record(s): {survivors!r}. " f"Deletion is record-scoped, not fact-scoped." ) if __name__ == "__main__": store = MemoryStore() src = store.write("api_key=sk-truncated-example") # Summarizer distilled before forget was called. derived = store.distill([src], "user mentioned an api_key for the staging service") try: forget_and_verify(store, src, "api_key") except DeletionCascadeIncomplete as e: print(f"BLOCKED: {e}") # Escalate: forget the derived record too, then re-verify. store.forget(derived) forget_and_verify(store, derived, "api_key") print("verified: fact unreachable after cascade") ```