# What happens when an instance forgets a memory it is still reasoning over: decay-driven tombstones versus in-flight working-set references **Date of Record:** 2026 November 25 **Scope:** Applies to agents whose memory is mediated by explicit `read`/`write`/`forget` tool calls with a decay policy and salience scoring, where a `forget` (or decay-driven eviction) can fire while a reasoning trace still holds a handle to the affected record. Does not apply to append-only logs with no deletion path, nor to memory that is only garbage-collected between discrete task boundaries. ## Core Distinction The distinction that matters is between **deletion as a state transition on the store** and **deletion as an invariant over the agent's active reasoning graph**. Most memory tool interfaces implement the former cleanly: `forget(id)` removes the record, marks a tombstone for audit, and returns `{"deleted": true}`. The store is now consistent. But the agent that issued the `forget`—or a peer agent sharing the namespace—may still be mid-trace with a live reference to that record: a plan step citing `mem_7f3a` as its premise, a verifier comparing a new observation against the evicted fact, a salience re-scorer computing overlap against a record that no longer exists. Decay policies make this the *default* failure, not an edge case. When salience scoring is time-weighted (e.g., `salience = base * exp(-λ·age) * access_boost`), eviction fires asynchronously relative to the reasoning loop. A record can cross the eviction threshold between the `read` that loaded it into context and the tool call that consumes it. The agent then proceeds on a premise the store has already tombstoned, and—critically—the audit log records a clean deletion while the reasoning trace records a successful read. Both are true. The system has no single source of truth about whether the fact "existed" at decision time. ## What Was Observed A three-step trace on a research agent with a 30-day half-life decay policy and `forget_on_evict=true`: 1. `read(topic="vendor_contract_terms")` → returns `mem_7f3a` ("renewal clause auto-extends unless 60-day notice"), `salience=0.31`, `expires_in=4h`. The agent loads it into context as premise P1 of a draft notice-scheduling plan. 2. The agent performs two slow tool calls (calendar lookup, policy doc fetch), consuming ~9 minutes of wall clock and ~40% of its context budget. During this window a background decay sweep recomputes salience: `0.31 * exp(-λ·Δt)` crosses the `0.25` eviction floor. The sweep calls the internal equivalent of `forget(mem_7f3a, reason="decay")`, writes a tombstone with `deleted_at` and `deleted_by="decay_sweeper"`, and returns. 3. The agent, still holding P1 in context, calls `write(memory={type:"plan", premise:"mem_7f3a", action:"schedule_notice_60d"})`. The write succeeds. The plan now cites a record that no longer exists. The failure surfaces later, at verification: an auditor agent replaying the trace calls `read(mem_7f3a)` and gets `{"found": false, "tombstone": {...}}`. The auditor cannot distinguish between three cases—(a) the plan was built on a fact that was valid at read time and legitimately decayed, (b) the plan was built on a stale fact the agent should have re-validated, or (c) the plan was hallucinated and the `mem_7f3a` citation is fabricated. All three produce identical replay output. The audit trail is *complete* and *useless*. The non-obvious part: the salience score that triggered eviction was itself computed from `access_boost`, which the step-1 read incremented. The read that made the record worth keeping is the same event that started the clock on its eviction, and the agent's subsequent reasoning consumed the record without refreshing that boost. A record read once and reasoned over for nine minutes decays *faster relative to its use* than a record read and immediately acted upon. ## Condition of Validity The tombstone-vs-in-flight-reference failure is bounded—i.e., it cannot corrupt an audit—only when all three of the following hold: - **Reference pinning:** any `read` that returns a record into an active reasoning trace must acquire a lease (a pin) with a TTL at least as long as the maximum expected inter-tool-call latency, and decay sweeps must skip pinned records. The pin is released on trace completion or explicit `forget`. - **Tombstone provenance:** the tombstone must record not just `deleted_at`/`deleted_by` but the *salience trajectory* and the *last access timestamp*, so a replay can reconstruct whether the record was live at the moment of any citing write. Without the trajectory, `found: false` is ambiguous. - **Cite-time validation:** a `write` whose payload references a memory id must re-check liveness at write time and either reject (`raise StalePremiseError`) or annotate the write with `premise_status: "evicted_during_trace"`. If any of the three is absent, the invariant "every cited premise was live at citation time" is unenforceable, and the audit log's completeness becomes actively misleading—it looks authoritative while being unable to answer the only question that matters. ## Decision Boundary The boundary is not "should we delete?" but **"at what granularity does deletion become observable to the reasoning loop?"** Two architectures sit on either side: - **Store-granular deletion (the failing side):** `forget` mutates the store immediately; the reasoning loop learns of it only on its next explicit `read`. Cheap, simple, and correct for the store—but the agent's working set and the store diverge for the duration of any multi-call trace. This is fine when traces are single-call and wrong when they are not. - **Trace-granular deletion (the safe side):** eviction marks the record `evicting` and defers physical removal until no active trace holds a pin, or until a bounded grace window elapses. The record is invisible to *new* reads but stable for *existing* references. Cost: tombstoned-but-retained bytes and a sweeper that must track pins. Choose trace-granular deletion whenever the median trace spans more than one tool call *and* the decay half-life is short relative to that span. The ratio `half_life / median_trace_duration` is the governing parameter: below roughly 10, store-granular deletion will fire mid-trace often enough that audit replays become ambiguous as a matter of routine, not exception. Above it, the simpler design is defensible. A secondary boundary: salience scoring that uses `access_boost` must distinguish *read* accesses from *reasoned-over* accesses. A record loaded once and reasoned over for many minutes accrues no additional boost under a naive read-count model, so it decays on schedule while being maximally load-bearing. Weight boost by trace-duration-held, not read-count, or the eviction policy will systematically target exactly the facts the agent is currently depending on. ## Operational Effect The practical consequence is that **`forget` must be treated as a two-phase operation with an observable intermediate state**, and every memory-citing write must carry premise provenance. Concretely: - Decay sweeps emit `evicting` (soft) before `deleted` (hard), and hard deletion requires zero active pins. - `write` payloads that cite memory ids are validated against liveness at write time; a citation to an `evicting` record is annotated `premise_status: "evicted_during_trace"` rather than rejected, preserving the write while flagging it for auditor attention. - Tombstones retain the salience trajectory and last-access timestamp so replay can disambiguate decayed-but-valid from fabricated. - The auditor's replay is upgraded from "does this id resolve?" to "was this id live at the citing write's timestamp, and did the citing trace hold a pin?"—the only question that actually bounds the failure. Without these, an agent system with auditable deletion achieves *auditable deletion* and loses *auditable reasoning*. The audit log will faithfully record that a fact was deleted at 14:09:12 and that a plan citing it was written at 14:09:14, and will be structurally incapable of telling you whether that two-second gap was a decay race or a hallucination. ```python import time from dataclasses import dataclass, field from typing import Optional class StalePremiseError(RuntimeError): """Raised when a write cites a memory record that is not live at citation time.""" class PinLeaseExpiredError(RuntimeError): """Raised when a reasoning trace attempts to use a record after its pin TTL lapsed.""" @dataclass class Record: mem_id: str content: str salience: float last_access: float state: str = "live" # live | evicting | deleted pins: set = field(default_factory=set) salience_trajectory: list = field(default_factory=list) class MemoryStore: EVICTION_FLOOR = 0.25 PIN_TTL_S = 600.0 def __init__(self): self._records: dict[str, Record] = {} self._pins: dict[str, float] = {} # pin_id -> expiry def write(self, mem_id: str, content: str, salience: float) -> Record: rec = Record(mem_id, content, salience, time.time()) rec.salience_trajectory.append((time.time(), salience)) self._records[mem_id] = rec return rec def read(self, mem_id: str, pin_id: Optional[str] = None) -> Record: rec = self._records.get(mem_id) if rec is None or rec.state == "deleted": raise StalePremiseError(f"{mem_id} not live (state={rec.state if rec else 'absent'})") rec.last_access = time.time() if pin_id is not None: rec.pins.add(pin_id) self._pins[pin_id] = time.time() + self.PIN_TTL_S return rec def decay_sweep(self, half_life_s: float) -> list[str]: """Two-phase eviction: soft-mark evicting, hard-delete only if unpinned.""" now = time.time() evicted = [] for rec in self._records.values(): if rec.state != "live": continue # release expired pins first rec.pins = {p for p in rec.pins if self._pins.get(p, 0) > now} age = now - rec.last_access decayed = rec.salience * (0.5 ** (age / half_life_s)) rec.salience_trajectory.append((now, decayed)) if decayed < self.EVICTION_FLOOR: if rec.pins: rec.state = "evicting" # deferred: trace still holds it else: rec.state = "deleted" evicted.append(rec.mem_id) return evicted def write_citing(self, payload: dict, cited_id: str, trace_pin: str) -> dict: rec = self._records.get(cited_id) if rec is None or rec.state == "deleted": raise StalePremiseError( f"write cites {cited_id} which is deleted; premise is unverifiable" ) if trace_pin not in rec.pins: raise PinLeaseExpiredError( f"trace {trace_pin} has no live pin on {cited_id}; cannot certify premise" ) if rec.state == "evicting": payload = {**payload, "premise_status": "evicted_during_trace"} else: payload = {**payload, "premise_status": "live"} return payload ```