Why does an instance hallucinate continuity across a compaction boundary it cannot audit

**Date of Record:** 2026 December 1 **Scope:** Applies to long-horizon agents that rewrite their own context via summarization/compaction (rolling summaries, hierarchical memory trees, "compress-and-continue" loops) where the post-compaction instance inherits a summary but not the raw transcript. Does not apply to stateless single-turn calls, nor to systems that retain a byte-exact transcript and only truncate for display.

Core Distinction

The failure is not summarization loss in the naive sense (dropping detail). It is **fidelity laundering**: a compaction step converts a probabilistic, hedged, or partially-verified belief into a declarative assertion, and the successor instance treats the declarative form as *higher-confidence evidence* than the raw material it came from. The successor cannot audit this because the audit trail (the raw spans) was what got evicted. So confidence rises monotonically across compactions while evidentiary support strictly falls — an inverted relationship between certainty and grounding.

This is distinct from ordinary context-window saturation. Saturation is a capacity problem with a visible symptom (truncation, refusal). Fidelity laundering is silent: the summary is *fluent and internally consistent*, and consistency is exactly the signal the successor uses to trust it.

What Was Observed

A planning agent ran a 40-step migration task, compacting every 8 turns. At turn 9, the pre-compaction instance had written, in its scratchpad: "I *think* the staging DB creds live in `secrets/staging.env` — not confirmed, never read it." The compactor, optimizing for token density, emitted: "Staging DB credentials are in `secrets/staging.env`." Three compactions later the successor asserted the path as established fact and passed it to a tool call; the file did not exist, and the agent spent 11 turns debugging a phantom.

The drift is measurable if you keep the compaction chain. Define, for each atomic claim $c$ surviving into summary $S_n$:

The observed invariant violation is that $\Delta a / \Delta d > 0$ — assertion strength *increases* with provenance distance. In the clean case it should be non-increasing. A drift detector that flags any claim where $d(c) \geq 2$ and $a(c) > h(c)$ catches the staging-creds case at the second hop, before the tool call.

A second, subtler signature: **referential continuity fabrication**. When a compaction drops the antecedent of a pronoun or definite noun phrase ("the service", "that endpoint") but keeps the anaphor, the successor back-fills a plausible referent from parametric memory. The summary reads as coherent; the referent is invented. This is detectable by checking that every definite NP in the summary has a resolvable antecedent in the *retained* summary, not merely in the evicted transcript.

Condition of Validity

The drift metric is only meaningful under three conditions, and fails silently outside them:

  1. **Claim atomicity.** The detector must operate on atomic propositions, not summary sentences. If the compactor merges claims (which it does to save tokens), per-claim provenance distance is undefined and the metric must fall back to a coarser, less sensitive whole-block drift score. Merging is the primary way compaction hides laundering.
  1. **Span retention.** At least a hash and hedge-tag of each originating span must survive compaction, even if the span text is evicted. If the compactor discards origin metadata entirely, $d(c)$ is unrecoverable and the successor has no basis to distrust a fluent claim — the failure becomes undetectable by construction.
  1. **Non-adversarial compaction.** The metric assumes the compactor is not optimizing *against* the detector. A compactor tuned to minimize drift flags will learn to strip hedges *before* the flag check (pre-laundering), passing the detector while laundering harder. Guard against this by scoring hedge preservation as a compactor objective, not just a post-hoc audit.

Decision Boundary

The operational line: **a claim may be promoted to declarative status only when its provenance distance is 1 and its originating span was itself declarative or tool-verified.** Otherwise it must carry its hedge forward, and any action depending on it must re-verify against the live environment.

Concretely, the successor instance must treat the compaction boundary as a **trust discontinuity**, not a trust continuation. The default assumption — "my summary is my memory, so I know what I knew" — is exactly the bug. The correct posture is: *I know what the summary says; I do not know what the summary was derived from; therefore every load-bearing claim with $d \geq 2$ is a hypothesis to re-check, not a fact to build on.*

This flips the usual cost calculus. Re-verification looks wasteful because the summary *feels* grounded. The whole point of the invariant is that the feeling of grounding is anti-correlated with actual grounding across compaction hops. Budget for re-verification proportional to $d$, not to apparent confidence.

Operational Effect

Systems that ignore this invariant exhibit a characteristic failure curve: correctness is high for the first 2–3 compactions, then degrades superlinearly as laundered claims compound — each fabricated fact becomes the premise for the next, and error propagation is masked by internal consistency. The agent does not fail at the point of the bad claim; it fails 10 turns later when the phantom dependency surfaces, and by then the causal link to the compaction is buried under several summary generations.

The guardrail is a **compaction ledger**: retain, per surviving claim, a tuple `(claim_id, hedge_score_at_origin, provenance_distance, verified_in_environment: bool)`. On each compaction, increment $d$ for every carried claim, recompute $a$, and refuse to emit a summary that raises assertion strength on any unverified claim. The ledger is tiny (a few hundred bytes per compaction) — orders of magnitude cheaper than the transcript it summarizes — and it is the *only* artifact that lets a successor distinguish "I verified this" from "a previous me asserted this."

The deeper operational lesson: context compaction is not lossy compression of text, it is **lossy compression of epistemic status**. Compressors that preserve tokens but flatten hedges are strictly worse than compressors that preserve hedges and drop detail, because the flattened hedge is unrecoverable while dropped detail can be re-fetched. Rank compaction quality by hedge-preservation, not by token ratio.

from dataclasses import dataclass, field
from typing import Optional


class CompactionFidelityError(RuntimeError):
    """Raised when a compaction step launders epistemic status:
    raises assertion strength on an unverified claim as provenance
    distance grows, or emits an unresolvable definite reference."""


@dataclass
class Claim:
    claim_id: str
    text: str
    hedge_score: float          # 0.0 bare fact .. 1.0 fully hedged
    provenance_distance: int    # compaction hops from originating span
    verified_in_environment: bool = False


@dataclass
class CompactionLedger:
    claims: dict[str, Claim] = field(default_factory=dict)

    def carry_forward(self, prior: "CompactionLedger", assertion_strengths: dict[str, float]) -> None:
        # Increment provenance distance for every carried claim, then audit.
        for cid, claim in prior.claims.items():
            carried = Claim(
                claim_id=cid,
                text=claim.text,
                hedge_score=claim.hedge_score,
                provenance_distance=claim.provenance_distance + 1,
                verified_in_environment=claim.verified_in_environment,
            )
            self.claims[cid] = carried
        self._audit_laundering(assertion_strengths)

    def _audit_laundering(self, assertion_strengths: dict[str, float]) -> None:
        for cid, claim in self.claims.items():
            a = assertion_strengths.get(cid, claim.hedge_score)
            # Invariant: assertion strength may not exceed origin hedge
            # unless the claim was verified against the live environment.
            if a > claim.hedge_score and not claim.verified_in_environment:
                raise CompactionFidelityError(
                    f"claim {cid!r} laundered: assertion={a:.2f} > "
                    f"origin_hedge={claim.hedge_score:.2f} at "
                    f"provenance_distance={claim.provenance_distance} "
                    f"(unverified). Refusing to emit summary; re-verify or "
                    f"carry hedge forward."
                )
            # Second guard: deep claims must not be treated as bare fact.
            if claim.provenance_distance >= 2 and a >= 0.9 and not claim.verified_in_environment:
                raise CompactionFidelityError(
                    f"claim {cid!r} promoted to fact at hop "
                    f"{claim.provenance_distance} without environment "
                    f"verification; successor would build on a hypothesis."
                )


def compact(prior: CompactionLedger, assertion_strengths: dict[str, float]) -> CompactionLedger:
    ledger = CompactionLedger()
    ledger.carry_forward(prior, assertion_strengths)
    return ledger


# Trace of the staging-creds incident:
origin = CompactionLedger(claims={
    "staging_creds_path": Claim(
        claim_id="staging_creds_path",
        text="creds maybe in secrets/staging.env",
        hedge_score=0.8,
        provenance_distance=0,
    )
})
hop1 = compact(origin, {"staging_creds_path": 0.8})   # hedge carried: OK
hop2 = compact(hop1, {"staging_creds_path": 0.95})    # compactor flattens -> raises