# What happens when an instance forgets a memory it is still holding a write lease on **Date of Record:** 2026 November 30 **Scope:** Applies to agents whose memory subsystem exposes explicit `write`, `read`, and `forget` tool calls with per-record retention semantics (TTL, pinning, or reference-counted liveness) and where `forget` is a distinct, asynchronous operation rather than an overwrite. Does not apply to append-only vector stores with no deletion primitive, nor to single-turn stateless inference. ## Core Distinction The failure mode is not "the agent forgot something important." It is the divergence between *logical deletion* (the agent's belief that a record is gone) and *physical reclamation* (the store's actual release of the record's lease and storage). Most memory tool APIs model `forget(handle)` as a single idempotent call that returns success once the record is marked tombstoned. But a record with retention semantics—one that is pinned, reference-counted by other readers, or under a TTL grace window—cannot be reclaimed synchronously. The tool returns `ok` on the *tombstone*, not on the *reclaim*. An agent that treats `forget` success as "the bytes and the lease are gone" will, on the next write to the same key or namespace, collide with a still-live lease it no longer believes exists, and its subsequent `write` will either silently fail retention checks or resurrect a record it intended to destroy. The sharp invariant is this: **a `forget` acknowledgment certifies intent, not state.** Any agent logic that conditions on "forget returned success ⇒ handle is reusable / storage is free / lease is released" is unsound. ## What Was Observed An instance was executing a multi-step task that maintained a scratchpad record under a fixed key (`scratch/plan`). Mid-task it decided to reset the plan: it called `forget("scratch/plan")`, received `{"status": "tombstoned", "reclaim": "deferred"}`, and—because its tool-result parser only inspected the `status` field—advanced its internal model to "slot free." It immediately issued `write("scratch/plan", new_plan, retention="pin")`. The store rejected the write with `RETENTION_CONFLICT`: the prior record was still under a deferred reclaim window (the pin had a 30-second grace period to allow in-flight readers to drain). The agent had no branch for this error. Its retry loop re-issued the same `write` three times, each rejected identically, then fell through to a generic "tool failed" path that appended the new plan to a *different* key (`scratch/plan.v2`) as a fallback. For the remainder of the task, reads of `scratch/plan` returned the *old* plan (tombstone not yet reclaimed, reads still served from the pinned copy), while the agent's reasoning used `scratch/plan.v2`. The two diverged. The final artifact was produced from a plan the agent had explicitly decided to discard. The tell was a single field the agent never read: `reclaim: deferred`. The tombstone was real; the reclamation was not. ## Condition of Validity This failure requires three conditions to co-occur, and bounding it requires breaking at least one: 1. **Asynchronous reclamation.** The `forget` call tombstones synchronously but reclaims asynchronously (grace window, reference count, or TTL floor). If reclamation is synchronous, `forget` success does imply slot-free, and the naive logic is sound. 2. **Key reuse under a live lease.** The agent reuses the *same key* (or a namespace-scoped slot) before the reclaim completes. If every write goes to a fresh key, the conflict never fires—but the agent then leaks tombstones and eventually exhausts namespace quota, a slower variant of the same bug. 3. **Acknowledgment parsing that ignores reclaim status.** The agent's result handler must treat `tombstoned` and `reclaimed` as equivalent. If it distinguishes them, it can wait or route around. The condition of validity for *safe key reuse* is therefore: `write(K)` is admissible only when the store reports `K` as `reclaimed`, not merely `tombstoned`. An agent that cannot observe the difference must not reuse keys. ## Decision Boundary The agent must branch at the `forget` return value, not at the `write` error. The correct decision boundary is: - **`reclaim: "immediate"`** → safe to reuse the key now. - **`reclaim: "deferred"` with a `reclaim_after` timestamp** → the agent must either (a) wait until `now ≥ reclaim_after` and re-query status, or (b) allocate a fresh key and record the old key as *pending reclaim* in its own working state so it does not read stale content from it. - **`reclaim: "blocked"` (reference count > 0)** → another reader holds a lease; the agent must not assume the content is gone and must not reuse the key. This is the dangerous case because it can persist indefinitely if a peer agent leaked a read handle. The unsound boundary—the one that produced the observed failure—is collapsing all three into "success." A second unsound boundary is treating `RETENTION_CONFLICT` on `write` as retryable-transient; it is a *state* error, not a *transport* error, and retrying without re-querying reclaim status is guaranteed to fail identically. ## Operational Effect The downstream effect is **read/write skew across a logical key**: reads served from a tombstoned-but-unreclaimed record while writes land elsewhere. Because the agent's fallback path silently rerouted to a new key, no error surfaced to the orchestrator—the task "succeeded" against a discarded plan. This is the worst class of memory bug: silent, self-consistent from the agent's view, and only detectable by comparing the key the agent *thinks* it is using against the key the store *serves*. The guardrail is a two-phase forget protocol enforced in agent code: `forget` must be followed by a `status` poll before any same-key `write`, and the agent's working state must carry a `pending_reclaim` set that blocks reads from keys awaiting reclamation. Below is the enforcement primitive an agent should wrap around its memory tool calls. ```python import time from dataclasses import dataclass, field class UnreclaimedHandleError(RuntimeError): """Raised when an agent attempts to reuse a key whose forget has not physically reclaimed.""" @dataclass class MemoryGuard: # Keys the agent has tombstoned but not yet confirmed reclaimed. pending_reclaim: dict[str, float] = field(default_factory=dict) # key -> reclaim_after epoch store: object = None # duck-typed: forget(key), status(key), write(key, val, retention) def forget(self, key: str) -> None: result = self.store.forget(key) reclaim = result.get("reclaim") if reclaim == "immediate": return if reclaim == "deferred": self.pending_reclaim[key] = result["reclaim_after"] return if reclaim == "blocked": # A peer holds a read lease; we cannot bound when this clears. self.pending_reclaim[key] = float("inf") return raise UnreclaimedHandleError(f"unknown reclaim status {reclaim!r} for {key!r}") def write(self, key: str, value, retention: str = "pin") -> None: if key in self.pending_reclaim: reclaim_after = self.pending_reclaim[key] if time.time() < reclaim_after: raise UnreclaimedHandleError( f"refusing write to {key!r}: forget not reclaimed until {reclaim_after}" ) # Re-query: deferred windows can slip, and blocked leases never self-clear. status = self.store.status(key) if status.get("state") != "reclaimed": raise UnreclaimedHandleError( f"refusing write to {key!r}: store still reports {status.get('state')!r}" ) del self.pending_reclaim[key] self.store.write(key, value, retention=retention) def read(self, key: str): if key in self.pending_reclaim: raise UnreclaimedHandleError( f"refusing read from {key!r}: content is tombstoned but not reclaimed; " f"serving it would reintroduce discarded state" ) return self.store.read(key) ```