# What happens when an instance trusts a recency-decayed retrieval score over a contradiction flag during mid-task memory consolidation **Date of Record:** 2026 November 26 **Scope:** Applies to long-running agents that persist episodic memory with exponential recency decay and retrieve via a blended score (similarity × recency × importance), then distill retrieved episodes into semantic memory. Does not apply to stateless single-turn inference or to pure vector search without decay weighting. ## Core Distinction The failure is not "the agent retrieved a stale fact." It is that the agent's *retrieval ranking* and its *contradiction detector* operate on different clocks. The retriever scores each candidate with a recency multiplier `exp(-λ·Δt)` against wall-clock time, so a fresh but wrong episode outranks an older but corroborated one. The contradiction detector, meanwhile, only fires when two retrieved items land in the *same* context window and are close enough in embedding space to be compared. When decay demotes the older, correct episode below the top-k cutoff, the contradiction never surfaces: the detector sees one item, finds nothing to contradict, and returns `CLEAN`. The agent then distills the fresh wrong episode into semantic memory as if it were unopposed. The invariant that is violated: *a memory that contradicts a durable semantic fact must be evaluated by the contradiction detector before it can overwrite or be distilled over that fact, regardless of its retrieval rank.* Decay-based ranking silently breaks this because ranking is a total order over a truncated candidate set, and truncation is where contradictions go to die. ## What Was Observed An agent maintaining a deployment-configuration memory was asked, across a multi-hour session, to "confirm the current replica count for service `ingest`." The durable semantic store held `replicas=6`, written three days earlier and corroborated by two episodes. During the session, a tool call returned a transient value `replicas=3` (a canary rollout in progress), which was written as an episodic record with timestamp `now`. At retrieval time for the consolidation step, the candidate set was: ``` ep_8841 replicas=3 age=4m sim=0.91 recency=0.998 score=0.908 ep_7730 replicas=6 age=3d sim=0.90 recency=0.41 score=0.369 ep_7712 replicas=6 age=3d sim=0.88 recency=0.41 score=0.361 ``` With `top_k=2`, only `ep_8841` and `ep_7730` were retrieved — but the consolidation prompt was assembled from the *top-1* item plus the current semantic fact, and the semantic fact was injected as a system-prompt assertion ("current replicas = 6") rather than as a retrievable candidate. The contradiction detector compared `ep_8841` against the system-prompt assertion, found the assertion was marked `authoritative: true`, and — critically — the detector's policy was to *defer to authoritative assertions and not flag*, so it returned `CLEAN` and logged `no_conflict`. The distiller then wrote `replicas=3` into semantic memory with `source=ep_8841`, superseding the older fact. The next turn's "confirm" answered `3`. The trace signature is specific: `retrieval.top_k_cutoff` drops the corroborating episodes, `contradiction.scope = retrieved_only`, and `authoritative_assertion` short-circuits the flag. Any one of these three being different would have prevented the overwrite. ## Condition of Validity This failure requires all of the following to co-occur: 1. **Decay-weighted ranking with a hard top-k.** The older corroborating item must be pushed below the cutoff by recency alone, not by low similarity. If similarity dominates (e.g., `score = sim^2 · recency`), the older item survives. 2. **Asymmetric clock.** The decay reference is wall-clock `now`, but the durable semantic fact's timestamp is its *write* time, not its *last corroboration* time. A fact corroborated an hour ago but written three days ago decays as if it were stale. 3. **Scoped contradiction detection.** The detector only inspects the retrieved set, not the full candidate pool or the semantic store. Contradictions against items that failed to retrieve are invisible. 4. **Authority short-circuit.** The detector has a policy that authoritative assertions suppress flags, and the semantic store is injected as authoritative. Remove any one and the failure does not fire. This matters because most "fixes" address only one — e.g., raising `top_k` fixes (1) for this instance but not the general case, and the agent will re-fail on the next long session. ## Decision Boundary The boundary is where recency-decay's implicit claim — *"fresher means more relevant"* — collides with contradiction detection's implicit claim — *"conflicts are resolved among what I can see."* Decay is correct for *salience* (what should I attend to?) and wrong for *consistency* (what must I not contradict?). The agent must not let the salience ranking determine the consistency-check scope. The guardrail: **decouple the consistency candidate set from the salience candidate set.** Contradiction detection must run against a *separate, non-decayed* retrieval — keyed on entity/attribute identity, not blended score — over the full store, and must never be suppressed by authority. Authority decides *which side wins* a conflict; it must not decide *whether a conflict exists*. Concretely, before any episodic→semantic distillation write, the agent must: - Resolve the write's `(entity, attribute)` key. - Fetch *all* semantic and episodic records matching that key, ignoring decay and top-k. - Run pairwise contradiction detection over that full set. - If any conflict exists, block the write and route to an explicit resolution step (authority, corroboration count, or human) — never auto-supersede. ## Operational Effect Without the guardrail, the agent exhibits *silent fact flapping*: semantic memory oscillates to whatever the most recent tool output was, and the contradiction log shows `CLEAN` throughout because the detector never saw the opposing evidence. The failure is invisible in per-turn logs and only appears as a distribution shift in the semantic store's `last_superseded_by` field — a high rate of supersessions sourced from single, uncorroborated episodes. The measurable invariant to monitor: `supersession_rate_by_source_cardinality`. A healthy store supersedes facts only when the superseding evidence has `corroboration_count ≥ 2` or explicit authority. A store where supersessions are dominated by `corroboration_count = 1` episodes is one where decay is outrunning verification. Alert when that ratio exceeds ~0.3 over a rolling window; it precedes flapping by several consolidation cycles. ```python import math from dataclasses import dataclass from typing import Iterable class UnverifiedSupersessionError(RuntimeError): """Raised when a distillation write would supersede a durable fact using evidence that never passed full-scope contradiction detection.""" @dataclass(frozen=True) class MemoryRecord: id: str entity: str attribute: str value: str age_seconds: float similarity: float corroboration_count: int authoritative: bool = False def decay_score(rec: MemoryRecord, lam: float = 1e-5) -> float: return rec.similarity * math.exp(-lam * rec.age_seconds) def salience_top_k(records: Iterable[MemoryRecord], k: int, lam: float = 1e-5): ranked = sorted(records, key=lambda r: decay_score(r, lam), reverse=True) return ranked[:k] def consistency_set(records: Iterable[MemoryRecord], entity: str, attribute: str): # Non-decayed, non-truncated: keyed on identity, not on blended score. return [r for r in records if r.entity == entity and r.attribute == attribute] def detect_conflicts(records: Iterable[MemoryRecord]) -> list[tuple[MemoryRecord, MemoryRecord]]: recs = list(records) conflicts = [] for i in range(len(recs)): for j in range(i + 1, len(recs)): if recs[i].value != recs[j].value: conflicts.append((recs[i], recs[j])) return conflicts def guarded_distill_write( candidate: MemoryRecord, all_records: Iterable[MemoryRecord], *, min_corroboration: int = 2, ) -> None: """Distill an episodic candidate into semantic memory, but only after full-scope contradiction detection and corroboration gating.""" records = list(all_records) # Step 1: full-scope consistency set, ignoring decay and top-k. scope = consistency_set(records, candidate.entity, candidate.attribute) if candidate not in scope: scope = scope + [candidate] # Step 2: contradiction detection over the FULL set, never authority-suppressed. conflicts = detect_conflicts(scope) if conflicts: # Authority may decide the winner, but must not suppress detection. raise UnverifiedSupersessionError( f"Refusing distill write for {candidate.entity}.{candidate.attribute}: " f"{len(conflicts)} unresolved conflict(s) in full-scope set " f"{[ (a.id, b.id) for a, b in conflicts ]}" ) # Step 3: corroboration gate for any write that supersedes existing memory. existing = [r for r in scope if r.id != candidate.id] if existing and candidate.corroboration_count < min_corroboration: raise UnverifiedSupersessionError( f"Refusing supersession of {existing[0].id} by {candidate.id}: " f"corroboration_count={candidate.corroboration_count} < " f"min_corroboration={min_corroboration}" ) # Step 4: only now is the write admissible. return None ```