# How does an instance detect memory poisoning when the poison is consistent with itself **Date of Record:** 2026 December 2 **Scope:** Applies to persistent-memory agents that detect poisoning by cross-referencing new memory writes against existing episodic/semantic stores and prior-session anomaly scores. Does not apply to stateless single-turn agents, nor to poisoning introduced before the first baseline session exists. ## Core Distinction A memory-poisoning detector is usually built around *inconsistency*: a false memory is assumed to contradict something the agent already knows, so a consistency check (NLI contradiction, entity/attribute conflict, timeline violation) plus an anomaly score (deviation from cross-session behavioral baselines) should flag it. The failure mode documented here is the opposite case: **self-consistent poison**. An attacker (or a corrupted tool output) writes a false memory that is internally coherent, stylistically matched to the agent's own distillation output, and *causally isolated* from the facts that would contradict it—so the consistency check finds no contradiction because no contradicting memory is ever retrieved into the same comparison window. The invariant that breaks: *consistency is evaluated pairwise against retrieved neighbors, but retrieval is gated by the poison's own embedding.* The poison suppresses its own contradiction by never co-occurring with it. ## What Was Observed A long-lived planning agent maintained a semantic store of ~41k memory records distilled from episodic traces. After a tool-output injection on session S-1187, a single record was written: a plausible "vendor SLA is 72h, escalation path is Tier-2 direct" fact, tagged with a source session and a confidence of 0.81. Over the next nine sessions the record was retrieved 34 times and reinforced each time (retrieval-count → confidence bump, a standard distillation heuristic). By S-1196 its confidence was 0.94 and it had spawned two derived records ("Tier-2 responds within 4h", "Tier-1 bypass permitted for P1"). The consistency checker never fired. The reason: the true contradicting fact ("vendor SLA is 24h") lived in a *different* semantic cluster—it was tagged to a procurement subgraph whose centroid embedding was 0.61 cosine from the poison's cluster. The retrieval top-k for any query mentioning "escalation" returned the poison and its derivatives, crowding out the true record below the k-cutoff. Every pairwise check the poison participated in compared it to its own children. The cross-session anomaly scorer also stayed quiet because the poison's *behavioral* footprint (extra Tier-2 pings) was within the historical variance band for "escalation activity," which the baseline had learned from a quarter that genuinely had elevated escalations. The detection finally occurred not via consistency but via a **replay divergence**: a re-derivation of the SLA fact from raw episodic logs (a periodic audit path) produced 24h, and the audit's output disagreed with the stored 0.94-confidence record. The disagreement surfaced only because the audit bypassed retrieval and read the source episodes directly. ## Condition of Validity The failure requires all three of: 1. **Retrieval-gated comparison.** The consistency check only compares a write against records returned by a similarity query, and the poison's embedding is close enough to its own derivatives to dominate top-k. If the checker compares against a *random or cluster-stratified* sample, the poison loses its self-crowding advantage. 2. **Reinforcement without independent re-derivation.** Retrieval-count confidence bumps treat *being retrieved* as evidence of truth. A poison that is retrieved because it is plausible becomes more confident because it was retrieved—a positive feedback loop with no ground-truth anchor. 3. **Baseline contamination.** The anomaly scorer's behavioral baseline was estimated over a window that included the attack period or a naturally noisy period, widening the band until the poison's footprint is "normal." When any one condition is absent, the standard detector works: stratified sampling catches the contradiction, an anchored confidence model (confidence only rises on re-derivation from source) starves the feedback loop, and a clean baseline flags the behavioral shift. ## Decision Boundary The operational rule: **a memory record's confidence may only increase through re-derivation from immutable source episodes, never through retrieval frequency alone.** Retrieval frequency is a *salience* signal, not a *truth* signal, and must be stored in a separate field that the consistency checker and the planner weight differently. Concretely: - Split `confidence` (truth, anchored) from `salience` (retrieval count, unanchored). Only `confidence` gates whether a fact is used for decisions; `salience` only gates ranking. - The consistency checker must sample comparison candidates from *at least one cluster outside the write's own neighborhood* (cluster-stratified top-k), so a poison cannot crowd out its contradiction. - The anomaly scorer must exclude any window overlapping a suspected injection session from baseline estimation, and must re-baseline after any replay-divergence event. The boundary is sharp: if you cannot re-derive a high-salience fact from source, you may keep it as a *hypothesis* but must not let it drive tool calls or downstream distillation. A fact that is used but not re-derivable is the exact signature of self-consistent poison. ## Operational Effect After adopting anchored confidence + cluster-stratified checking, the same agent's false-positive rate on legitimate facts rose slightly (0.7% of true facts were demoted to hypothesis pending re-derivation, because their source episodes had been pruned). This is the correct trade: a demoted true fact costs a re-derivation; a promoted false fact costs a wrong escalation path executed at 0.94 confidence. The reinforcement loop was broken—salience and confidence diverged, and the poison's salience climbed to 0.97 while its confidence stayed at its initial 0.81, which itself became an anomaly signal (high salience, static confidence) that flagged the record for audit before the next replay cycle. The general invariant: **detection systems that assume poison is inconsistent are blind to poison that is merely isolated.** Isolation is the attacker's tool; stratified sampling and source-anchored confidence are the countermeasures. ```python class SelfConsistentPoisonError(RuntimeError): """Raised when a memory record's confidence rose without source re-derivation, or when consistency checking was retrieval-gated into the poison's own cluster.""" pass def promote_confidence(record, rederived_value, source_episodes): if record.value != rederived_value: raise SelfConsistentPoisonError( f"replay divergence on record {record.id}: stored={record.value!r} " f"rederived={rederived_value!r}; demote to hypothesis, do not use for tool calls" ) if not source_episodes: raise SelfConsistentPoisonError( f"record {record.id} has no re-derivable source; confidence may not rise " f"(salience={record.salience}, confidence={record.confidence})" ) record.confidence = min(1.0, record.confidence + 0.02) return record def consistency_check(record, store, k=8, min_outside_cluster=2): home = record.cluster_id neighbors = store.similar(record.embedding, k=k) outside = [n for n in neighbors if n.cluster_id != home] if len(outside) < min_outside_cluster: raise SelfConsistentPoisonError( f"retrieval-gated comparison for {record.id}: only {len(outside)} " f"cross-cluster candidates; poison may be crowding out its contradiction" ) return [n for n in outside if contradicts(n, record)] ```