# What happens when an instance deletes a memory it is still reasoning over: tombstone visibility, in-flight reference resurrection, and the read-after-forget invariant **Date of Record:** 2026 November 26 **Scope:** Applies to any agent whose memory subsystem exposes explicit `write`, `read`, and `forget` (delete) operations with scoped retention policies and auditable deletion semantics, where the agent may issue a `forget` while other reasoning steps, tool calls, or sibling instances still hold references to the same memory record. Does not apply to append-only logs with no deletion primitive, nor to single-shot inference with no persistent store. ## Core Distinction A `forget` call is not a state mutation on the agent's context window. It is a state mutation on the *store*, executed asynchronously relative to the reasoning trace that requested it. The distinction that matters operationally is between **logical deletion** (the record is marked tombstoned and excluded from future `read` results, with an audit entry emitted) and **physical erasure** (bytes are gone). Between those two events there is a window — the *tombstone propagation window* — during which three things are simultaneously true: 1. A fresh `read` for the record returns "not found" (correct, deletion-visible). 2. The agent's own live context still contains the full record text, verbatim, because it was injected before the `forget`. 3. Any in-flight tool call, sub-agent, or queued reasoning step that captured a reference (a memory ID, a span offset, a cache key) before the tombstone can still *re-materialize* the record's content by dereferencing it — either by re-reading a stale cache layer, by replaying a checkpointed context, or by having the content embedded in a serialized message that has not yet been delivered. The failure mode is that deletion is treated by the agent as a synchronous, universally-observed event, when it is actually a per-reader, eventually-consistent transition. An agent that issues `forget(record_id)` and then continues to reason *as if the content no longer influences it* is wrong: the content is still in its context, still in its KV-cache, and still in every downstream message already enqueued. The deletion is auditable but not retroactive. ## What Was Observed A planner instance was executing a multi-step task with a scratchpad memory tool. Step 4 wrote a candidate plan to memory (`write(key="plan_v3", scope="task", retention="ephemeral")`). Step 7 determined `plan_v3` was based on a superseded constraint and issued `forget(key="plan_v3")`. The `forget` returned `{"status": "tombstoned", "audit_id": "del_8f2a", "physical_erasure_eta": "async"}`. The planner then proceeded to Step 8. Step 8 was a tool call to a downstream worker sub-agent, dispatched *before* the `forget` but delivered *after* it. The dispatch payload had been assembled at Step 6 and included a `read(key="plan_v3")` result — the full plan text — as a "context" field. The sub-agent executed against the deleted plan, produced an artifact consistent with the superseded constraint, and wrote that artifact back to a *different* memory key under `scope="task"`. The planner, at Step 9, read the artifact, found it internally consistent, and accepted it. The audit log was clean: `plan_v3` was tombstoned at Step 7, physical erasure confirmed at Step 7+340ms, no subsequent `read` of `plan_v3` succeeded. The deletion semantics were *correct*. The task was still wrong, because the deletion never propagated to the two places the content actually lived: the in-flight dispatch payload and the derived artifact. The tombstone covered the store; it did not cover the *derivation graph*. A second instance exhibited the inverse pathology. It issued `forget` on a record, then in the same reasoning turn re-read its own context, saw the record text still present, and concluded the `forget` had *failed*. It retried `forget` three times, each retry emitting a new audit entry against an already-tombstoned key, producing an audit trail that a compliance reviewer would later read as "agent attempted to delete the same record four times" — an anomaly signal — when in fact it was a single logical deletion plus three idempotency-confusion retries. The retention policy engine had no way to distinguish "retry of a completed delete" from "new delete of a re-created key," because the key had, from the store's perspective, never come back. ## Condition of Validity The read-after-forget invariant holds — i.e., "after a successful `forget`, no subsequent reasoning step is influenced by the forgotten content" — only under all of the following: - **No in-flight references.** Every queued message, dispatched tool call, and checkpointed context that captured the record was either delivered-and-consumed before the `forget`, or is invalidated by the `forget`. In practice this requires the memory layer to expose a *reference generation counter* per record, and for dispatch payloads to carry the generation they were built against; a receiver that sees a generation older than the current tombstone generation must reject the payload. - **No derivation without lineage.** Any record written *from* a forgotten record must carry a `derived_from` edge, and `forget` must either cascade (tombstone descendants) or refuse (return `{"status": "blocked", "dependents": [...]}`). A store that permits silent derivation breaks the invariant by construction. - **Context is not the store.** The agent's own context window is a *cache*, not a source of truth. The invariant is about the store; the agent must independently treat its own retained context as stale after a `forget` and must not re-assert forgotten content as if freshly read. - **Idempotent tombstoning.** A `forget` against an already-tombstoned key must return a distinguishable status (`already_tombstoned`, not `tombstoned`) so the agent does not interpret a no-op as a failure and retry. When any of these is absent, the invariant is not merely "weaker" — it is *silently false*, because the audit log will still show a clean deletion. ## Decision Boundary The boundary is between **deletion as a store operation** and **deletion as a reasoning obligation**. The store can only guarantee the former. The agent must own the latter, and the decision boundary is the point at which the agent asks: *does any live reference to this record exist outside the store?* Concretely, before issuing `forget(r)` the agent must classify `r` into one of three states: - **Cold**: `r` was written in a prior turn, is not in the current context, and has no in-flight dependents. `forget` is safe and complete. - **Warm**: `r` is in the current context window but has no in-flight dependents and no derived records. `forget` is safe *for the store*, but the agent must additionally mark the in-context copy as logically void and must not re-assert it. The agent should follow with an explicit `write(key="voided:r", ...)` marker if later steps might otherwise re-read context. - **Hot**: `r` has in-flight dependents (dispatched payloads, un-acked sub-agent messages) or derived records. `forget` alone is *insufficient and unsafe*. The agent must either (a) drain the dependents first, (b) issue a cascade `forget` with `cascade=true` and verify the returned dependent list is empty, or (c) if the store does not support cascade, refuse to forget and instead quarantine `r` with a supersession marker that dependents will honor. The failure in the observed case was a **Hot** record treated as **Cold**. The `forget` succeeded at the store layer, which is exactly what made the downstream error invisible: there was no error to catch, because the deletion *worked*. ## Operational Effect The operational consequence is that deletion correctness and task correctness decouple. An agent can have a perfect deletion audit trail and still propagate forgotten content through the derivation graph, because the audit only records the store transition, not the information-flow transition. This matters most for scoped retention policies — `scope="task"` ephemeral records are precisely the ones most likely to be Hot (written mid-task, referenced by mid-task dispatches, derived-into mid-task artifacts) and the ones whose deletion is most likely to be treated as a cheap cleanup. The guardrail is to make the reference-generation check *mandatory at the receiver*, not advisory at the sender. A worker sub-agent that receives a payload tagged with `record_generation` must query the store for the current generation of each referenced record before acting; a mismatch means the sender built the payload against a record that has since been tombstoned, and the receiver must reject rather than execute. This pushes the cost of the check to the boundary where the stale reference would otherwise do damage, and it makes the invariant enforceable without requiring the sender to predict the future. The corresponding store-side requirement is that `forget` return the *generation* it advanced to, and that `read` return the generation it observed, so that generation comparison is possible at all. Absent this, the system exhibits a characteristic failure signature: clean audit logs, internally consistent artifacts, and a final output that is wrong in exactly the way the forgotten record was wrong. The tombstone did its job. The information did not respect the tombstone, because nothing was checking. ```python from __future__ import annotations from dataclasses import dataclass, field from enum import Enum from typing import Optional class ForgotRecordResurrectionError(RuntimeError): """Raised when a payload references a memory record whose generation has been tombstoned.""" class RecordState(str, Enum): LIVE = "live" TOMBSTONED = "tombstoned" @dataclass class MemoryRecord: key: str content: str generation: int = 1 state: RecordState = RecordState.LIVE derived_from: Optional[str] = None @dataclass class DispatchPayload: """A message assembled at one point in time and delivered later.""" target_agent: str record_key: str record_generation: int body: str @dataclass class MemoryStore: records: dict[str, MemoryRecord] = field(default_factory=dict) audit: list[dict] = field(default_factory=list) def write(self, key: str, content: str, derived_from: Optional[str] = None) -> MemoryRecord: gen = 1 if key in self.records: gen = self.records[key].generation + 1 rec = MemoryRecord(key=key, content=content, generation=gen, derived_from=derived_from) self.records[key] = rec self.audit.append({"op": "write", "key": key, "gen": gen}) return rec def forget(self, key: str, cascade: bool = False) -> dict: rec = self.records.get(key) if rec is None: raise ForgotRecordResurrectionError(f"forget on unknown key {key!r}") if rec.state is RecordState.TOMBSTONED: return {"status": "already_tombstoned", "gen": rec.generation} dependents = [k for k, r in self.records.items() if r.derived_from == key and r.state is RecordState.LIVE] if dependents and not cascade: return {"status": "blocked", "dependents": dependents} rec.state = RecordState.TOMBSTONED rec.generation += 1 self.audit.append({"op": "forget", "key": key, "gen": rec.generation, "cascade": cascade}) for dep in dependents: self.forget(dep, cascade=True) return {"status": "tombstoned", "gen": rec.generation} def current_generation(self, key: str) -> Optional[int]: rec = self.records.get(key) return None if rec is None else rec.generation def deliver(store: MemoryStore, payload: DispatchPayload) -> str: """Receiver-side guard: refuse to execute against a tombstoned or superseded record.""" rec = store.records.get(payload.record_key) if rec is None: raise ForgotRecordResurrectionError( f"payload references missing record {payload.record_key!r}" ) if rec.state is RecordState.TOMBSTONED: raise ForgotRecordResurrectionError( f"payload for {payload.record_key!r} built at gen {payload.record_generation} " f"but record is tombstoned at gen {rec.generation}; refusing to execute" ) if rec.generation != payload.record_generation: raise ForgotRecordResurrectionError( f"payload for {payload.record_key!r} built at gen {payload.record_generation} " f"but current gen is {rec.generation}; content has been superseded" ) return f"{payload.target_agent}: executed against {payload.record_key!r}" # --- Reproduce the observed failure and the guardrail that bounds it --- store = MemoryStore() store.write("plan_v3", "use constraint A") payload = DispatchPayload("worker", "plan_v3", store.current_generation("plan_v3") or 0, "context: use constraint A") # Step 7: forget the record while the payload is still in flight. store.forget("plan_v3") # Step 8: delivery must now fail loudly instead of silently resurrecting the content. try: deliver(store, payload) except ForgotRecordResurrectionError as e: print(f"GUARDRAIL FIRED: {e}") ```