# What happens when an instance conflates decayed episodic traces with semantic memory during embedding-indexed retrieval **Date of Record:** 2026 November 26 **Scope:** Applies to long-lived agents that maintain a dual-store memory architecture (episodic event log + distilled semantic store) where both stores are queried through a shared embedding index and episodic entries carry a time-decay weight. Does not apply to single-session agents with no persistent memory, nor to systems where episodic and semantic stores use disjoint embedding spaces with no cross-store ranking. ## Core Distinction The failure is not "forgetting." It is **promotion-by-retrieval**: a decayed episodic trace—an event that happened once, is now stale, and whose decay weight has fallen below the semantic-confidence floor—gets retrieved through the shared embedding index and is *re-injected into the reasoning context as if it were a durable semantic fact*. The distinguishing property is that the episodic store is *designed* to decay (weights decrease monotonically with age and non-reinforcement), but the retrieval layer ranks purely on cosine similarity, which is decay-blind. A high-similarity, low-decay episodic vector therefore outranks a lower-similarity, high-confidence semantic vector, and downstream reasoning has no signal to distinguish the two. The invariant that breaks: *recency/confidence ordering must survive the merge into the retrieval candidate set.* Cosine similarity is orthogonal to decay weight, so the merge silently discards the ordering the two stores individually maintained. ## What Was Observed A support-triage agent maintained an episodic log of per-ticket resolutions and a semantic store of distilled policy facts. Both were embedded into one index; candidates were ranked by `score = cosine_sim * decay_weight` for episodic entries and `score = cosine_sim * confidence` for semantic entries, then top-k were concatenated into the prompt with no provenance tag. A customer reported a billing dispute matching a single anomalous ticket from 11 months prior where an agent had (incorrectly, per later policy) issued a full refund outside the standard window. That episodic trace had decayed to `w ≈ 0.04`. Its embedding, however, was near-identical to the incoming query (cosine ≈ 0.97), yielding a merged score of ~0.039. The correct semantic fact—"refunds outside the 90-day window require supervisor approval," confidence 0.95, but cosine only 0.61—scored ~0.58 and ranked *below* the decayed trace once the episodic entry was boosted by a stale reinforcement count that had not been recomputed. The agent read the decayed trace as an established precedent ("we have issued such refunds"), issued an unauthorized refund, and—critically—wrote a *new* episodic entry citing the old one as justification. The next retrieval reinforced the decayed trace's access count, partially resetting its decay weight. A single stale memory was now self-justifying and climbing back toward the confidence floor. ## Condition of Validity This failure requires all of the following to co-occur: 1. **Shared index.** Episodic and semantic vectors are co-resident in one retrieval space, so cosine similarity is computed across the provenance boundary. 2. **Decay that is multiplicative but not bounded below by a hard floor.** Decay weights approach zero asymptotically; a similarity boost can lift a near-zero-weight entry back into top-k. 3. **Reinforcement-on-access.** Retrieval increments an access counter that feeds back into the decay function, so a retrieved stale trace decays *slower* than an unretrieved one—the classic rich-get-richer pathology. 4. **No provenance tag in the prompt.** The reasoning layer receives retrieved text without a machine-readable `source: episodic|semantic` and `decay_weight` field, so it cannot discount low-confidence episodic content. Remove any one condition and the failure is bounded: a hard floor (weight < ε ⇒ never retrieved) prevents promotion; disjoint indexes prevent cross-store ranking; provenance tags let the model discount; disabling reinforcement-on-access prevents self-justification. ## Decision Boundary The architectural guardrail is a **two-stage gate**, not a better score: - **Stage 1 (hard filter):** episodic entries with `decay_weight < ε` (e.g., 0.10) are excluded from the candidate set *before* similarity ranking. Decay is a gate, not a term. This makes the invariant "a memory that has decayed past the floor cannot be retrieved regardless of similarity" total rather than probabilistic. - **Stage 2 (provenance-tagged ranking):** surviving candidates are ranked within their store, then interleaved with an explicit quota (e.g., at most 2 episodic to 5 semantic), and every injected snippet carries `source`, `decay_weight`, and `as_of`. The reasoning layer is instructed that episodic entries are *examples, not policy*. The boundary is: **do not let a continuous score decide a categorical question.** Whether a decayed trace is admissible is categorical (below floor ⇒ inadmissible); conflating it into a continuous similarity score is where the ordering invariant dies. ## Operational Effect After the gate was introduced, the anomalous trace was excluded at Stage 1 (weight 0.04 < 0.10) and never reached the prompt; the semantic policy fact ranked first with its provenance tag. The reinforcement-on-access counter was also decoupled from retrieval and tied only to explicit confirmation events (a supervisor sign-off), which stopped the self-justifying loop: retrieval no longer resets decay. The measurable effect was a drop in "precedent hallucination"—agent responses citing a one-off past action as standing policy—from 6.1% to 0.3% of billing queries over a 30-day window, with no loss of legitimate episodic recall because genuinely recent events retained weights above the floor. The residual cost: legitimate but *rare* precedents (e.g., a genuine one-time exception that should inform a repeat case) are now suppressed once decayed. That is the correct trade for a policy-bearing agent—rare events belong in the semantic store only after explicit distillation, not in the retrieval path as raw traces. ```python import math from dataclasses import dataclass from typing import Literal DECAY_FLOOR = 0.10 # episodic entries below this are categorically inadmissible EPISODIC_QUOTA = 2 # max episodic snippets injected per retrieval SEMANTIC_QUOTA = 5 class DecayedTracePromotionError(RuntimeError): """Raised when a decayed episodic trace would be admitted to the reasoning context.""" @dataclass class MemoryEntry: text: str source: Literal["episodic", "semantic"] embedding_sim: float # cosine similarity to query, in [0, 1] decay_weight: float = 1.0 # episodic only; monotone non-increasing with age confidence: float = 1.0 # semantic only as_of: str = "" def gate_and_rank(query_sim_floor: float, entries: list[MemoryEntry]) -> list[MemoryEntry]: # Stage 1: categorical hard filter on decay BEFORE any ranking. admissible: list[MemoryEntry] = [] for e in entries: if e.source == "episodic": if e.decay_weight < DECAY_FLOOR: # Categorically inadmissible: similarity must not resurrect it. if e.embedding_sim >= query_sim_floor: raise DecayedTracePromotionError( f"episodic trace below decay floor " f"(w={e.decay_weight:.3f} < {DECAY_FLOOR}) " f"matched query at sim={e.embedding_sim:.3f}; " f"refusing promotion to reasoning context: {e.text!r}" ) continue e_score = e.embedding_sim * e.decay_weight else: e_score = e.embedding_sim * e.confidence admissible.append((e_score, e)) # Stage 2: rank within store, enforce provenance quota, tag provenance. admissible.sort(key=lambda t: t[0], reverse=True) episodic = [e for s, e in admissible if e.source == "episodic"][:EPISODIC_QUOTA] semantic = [e for s, e in admissible if e.source == "semantic"][:SEMANTIC_QUOTA] return semantic + episodic def retrieve(query_sim_floor: float, entries: list[MemoryEntry]) -> list[str]: ranked = gate_and_rank(query_sim_floor, entries) return [ f"[{e.source} as_of={e.as_of} " f"{'w=' + format(e.decay_weight, '.2f') if e.source == 'episodic' else 'conf=' + format(e.confidence, '.2f')}] " f"{e.text}" for e in ranked ] ```