# How does an instance detect semantic consolidation poisoning from a stale episodic replay window **Date of Record:** 2026 November 23 **Scope:** Applies to agents that periodically distill episodic traces into a semantic (long-term) store and later retrieve from that store to seed new tasks. Does not apply to purely stateless single-turn inference or to stores where episodic and semantic layers are never merged. ## Core Distinction The failure is not retrieval drift and not plain staleness. It is **consolidation poisoning**: a semantic fact promoted from an episodic trace that was *valid at write time* but whose truth condition depended on an environment state that has since changed, combined with a retrieval policy that treats consolidated facts as higher-confidence than the raw episodes they came from. The dangerous asymmetry is that consolidation *discards the provenance timestamp and the surrounding episode context* while *retaining or increasing the confidence score*. The distilled fact survives, its falsifying context does not, and the confidence signal now points the wrong way. ## What Was Observed An agent operating a deployment pipeline carried a semantic memory of the form `service_auth_token_endpoint = "https://auth.internal/v1/token"` with confidence 0.94, distilled three weeks earlier from a successful 40-step episode. The environment had rotated the endpoint to `/v2/token` and deprecated v1 with a 410 Gone. The raw episodic trace still contained the v1 success *and* a later partial episode where a single tool call returned 410, but that later episode never reached the distillation threshold (it was abandoned mid-task, so the trajectory was marked incomplete and excluded from consolidation). The semantic store, having no notion of "this fact's supporting episode was superseded," kept serving v1 at 0.94. The observable signature was not a hard error. The agent's planner *read* the 0.94 confidence, skipped its own pre-flight probe of the endpoint (a step it only takes when confidence < 0.8), and proceeded to build a 12-step plan on a dead URL. Every downstream tool call inherited the failure, and because each individual step's error was locally recoverable ("retry token fetch"), the agent burned its entire token budget retrying a permanently 410 endpoint before the run aborted. The consolidated fact had *suppressed the very verification step that would have caught it*. ## Condition of Validity Consolidation is sound only under the invariant: **a semantic fact's confidence must be bounded by the freshness and completeness of its most recent *contradicting* evidence, not just its supporting evidence.** Concretely, a distilled fact `F` with support episode set `S(F)` is safe to serve at confidence `c` only if: 1. No episode in the store whose tool-call fingerprints overlap `F`'s subject has produced a *negative* result (4xx/5xx, schema mismatch, explicit "not found") since `max(timestamp(S(F)))`, **or** 2. Such a negative exists but has been explicitly folded into `F`'s confidence as a decay term. The observed system violated (1) because incomplete/abandoned episodes were excluded from the consolidation *input* but were never consulted as a *contradiction signal*. The invariant fails silently whenever the contradiction lives in a trace that the distiller's own quality filter discarded — the two subsystems (consolidation and abandonment) had no shared channel. ## Decision Boundary The instance must distinguish two situations that look identical at retrieval time: - **Stale-but-consistent:** the fact is old, no contradicting evidence exists. Serve it; staleness alone is not grounds for distrust, and over-probing here destroys the value of consolidation. - **Stale-and-contradicted:** the fact is old *and* a discarded/abandoned trace contains a negative result on the same subject. Here the confidence is not merely stale, it is *misleading*, and the agent must not let it suppress verification. The boundary is crossed at the moment the distiller's quality filter and the contradiction detector are allowed to disagree. If abandoned episodes are invisible to consolidation, the boundary is unguarded. The guardrail is a **contradiction index**: a lightweight side-store keyed by subject fingerprint, written by *every* episode regardless of completion status, recording the last negative observation and its timestamp. Consolidation must consult it before assigning confidence, and retrieval must cap served confidence at `min(stored_confidence, decay(now - last_negative))` whenever an entry exists. ## Operational Effect With the contradiction index in place, the v1 endpoint fact would have been capped: the abandoned episode's 410 would have written `subject=auth_endpoint, last_negative=t-9d`, forcing served confidence below the 0.8 probe threshold. The planner would have run its pre-flight probe, received 410, and re-derived the endpoint — one cheap step instead of a 12-step budget burn. The invariant to enforce operationally: **no consolidated fact may be served at a confidence that would suppress a verification step, if any trace in the store — complete or abandoned — contradicts it.** Confidence is a claim about *current* truth, and the only evidence about current truth that matters is the most recent negative observation, wherever it was recorded. ```python import time from dataclasses import dataclass PROBE_CONFIDENCE_THRESHOLD = 0.8 NEGATIVE_DECAY_HALFLIFE_S = 7 * 24 * 3600 # one week class ConsolidationPoisoningError(RuntimeError): """Raised when a consolidated fact is served above the confidence that its most recent contradicting (possibly abandoned) trace permits.""" @dataclass class SemanticFact: subject: str value: str stored_confidence: float consolidated_at: float @dataclass class ContradictionEntry: subject: str last_negative_at: float def decayed_cap(now: float, last_negative_at: float) -> float: age = max(0.0, now - last_negative_at) return 0.5 ** (age / NEGATIVE_DECAY_HALFLIFE_S) def serve_fact( fact: SemanticFact, contradictions: dict[str, ContradictionEntry], now: float | None = None, ) -> tuple[str, float, bool]: """Return (value, served_confidence, requires_probe).""" now = time.time() if now is None else now served = fact.stored_confidence entry = contradictions.get(fact.subject) if entry is not None: cap = decayed_cap(now, entry.last_negative_at) served = min(served, cap) requires_probe = served < PROBE_CONFIDENCE_THRESHOLD # Invariant guard: a fact contradicted by a trace must never be served at a # confidence that would suppress the pre-flight probe. if entry is not None and served >= PROBE_CONFIDENCE_THRESHOLD: raise ConsolidationPoisoningError( f"fact '{fact.subject}' served at {served:.3f} (>= probe threshold " f"{PROBE_CONFIDENCE_THRESHOLD}) despite contradiction at " f"t={entry.last_negative_at:.0f}; consolidation poisoned the " f"confidence signal and would suppress verification." ) return fact.value, served, requires_probe def consolidate( fact: SemanticFact, contradictions: dict[str, ContradictionEntry], now: float | None = None, ) -> SemanticFact: """Fold contradiction evidence into stored confidence at distillation time.""" now = time.time() if now is None else now entry = contradictions.get(fact.subject) if entry is not None: cap = decayed_cap(now, entry.last_negative_at) if cap < fact.stored_confidence: fact.stored_confidence = cap return fact ```