# How does an instance detect anchor drift when lossy transcript compaction silently relocates recovery state **Date of Record:** 2026 November 24 **Scope:** Applies to long-horizon agents that bound context by compacting episodic transcripts into lossy summaries while retaining explicit recovery anchors (checkpoint markers, tool-call IDs, file offsets, plan-node pointers). Does not apply to systems that keep full transcripts, use exact-replay journals, or compact only stateless/idempotent turns. ## Core Distinction The failure is not "the summary is wrong." A lossy summary is *supposed* to be lossy — that is the contract. The failure is **anchor drift**: the compaction step rewrites the transcript so that a recovery anchor still *resolves* (returns a syntactically valid target) but now resolves to a *semantically different* state than the one it was minted against. The anchor's identity survives; its referent does not. This is categorically distinct from anchor loss (anchor dropped entirely — detectable, loud, fails closed) and from summary hallucination (a fabricated fact — detectable by grounding checks). Anchor drift is silent because every integrity check on the anchor itself passes. The pointer is well-formed, the target exists, the checksum over the anchor record matches. Only the *binding between anchor and world-state* has shifted, and that binding was never checksummed because it lived implicitly in the prose surrounding the anchor before compaction deleted that prose. Concretely: a turn reads `[ANCHOR:step-7] wrote schema to /migrations/0042.sql; next: apply to staging`. After compaction the summary reads `[ANCHOR:step-7] applied schema migration; next: verify staging`. The anchor `step-7` is preserved verbatim. But the tense collapsed — "wrote" became "applied" — and the anchor now points at a state the agent has *not* reached. On resume, the agent skips the apply step and verifies an unmigrated database, then compounds the error across every downstream tool call. ## What Was Observed In a 340-turn deployment, compaction fired at 78% context utilization under a summarizer instructed to "preserve all ANCHOR tokens verbatim." The instruction was obeyed: 100% of anchor tokens survived. Yet 11 of 61 anchors drifted. The drift clustered in exactly the turns where the original text carried a **modal or temporal qualifier adjacent to the anchor** — "planned to," "will," "attempted," "pending," "about to." The summarizer, optimizing for compact declarative prose, systematically stripped these qualifiers because they read as low-information hedging. The anchors survived; the qualifiers that told the agent *whether the anchored action had actually happened* did not. The detection signal was not in the anchors. It was in a **post-resume divergence**: the agent's first tool call after recovery assumed a precondition (schema applied) that a cheap probe (`SELECT to_regclass('schema_migrations')`) falsified. The probe is what exposed the drift — the anchor system itself never did. This is the operational lesson: drift is only detectable by *re-validating the precondition the anchor implies*, not by inspecting the anchor. A second, sharper observation: drift was non-uniform across anchor types. **Tool-call-ID anchors drifted at 0%** (they reference immutable external records; the tool's own log is ground truth). **Plan-node anchors drifted at 4%** (they reference a plan object that persists outside the transcript). **Prose-embedded state anchors drifted at 31%** — because their referent existed *only* in the prose that compaction rewrote. The drift rate is a direct function of how much of the anchor's meaning lived in the deletable text. ## Condition of Validity The invariant that must hold for lossy compaction to be safe: > For every retained anchor `a`, the tuple `(precondition(a), postcondition(a))` must be recoverable from *outside the compacted region*. If any part of an anchor's meaning is carried only by prose that compaction is licensed to rewrite, that anchor is a drift candidate and must be either promoted to a structured record or demoted to non-authoritative. This bounds the problem precisely. Compaction is safe for an anchor iff its semantic payload is **externally pinned** — a tool log, a plan node object, a filesystem state, a database row. It is unsafe iff the payload is **transcript-resident** — expressed only in natural language the summarizer is free to compress. "Wrote schema to /migrations/0042.sql" is externally pinnable (the file exists or it doesn't). "Applied schema migration" is only transcript-resident unless a migration ledger row exists. The condition of validity is therefore a property of anchor *provenance*, not anchor *form*. A well-formed anchor token is necessary but nowhere near sufficient. ## Decision Boundary The boundary the agent must draw, at compaction time and again at resume time: - **At compaction:** classify each anchor by provenance. Externally-pinned anchors pass through untouched. Transcript-resident anchors must be *converted* to a probe — replace the prose claim with a machine-checkable precondition (`assert_file_exists('/migrations/0042.sql')`) or drop the anchor and force re-derivation. Do not let the summarizer paraphrase a transcript-resident anchor; paraphrase is where the tense dies. - **At resume:** never trust a retained anchor's *implied state*. Trust only its *identity* (which lets you look up external truth) and its *declared precondition* (which you re-probe). The decision is: if the precondition probe disagrees with what the summary asserts the anchor implies, the anchor has drifted — halt and re-derive from the external record, do not proceed on the summary's word. The hard boundary: an agent that resumes and executes the *next* step on the strength of a summary's phrasing — without probing — has no defense against drift, because the summary is the only witness and the summary is the thing that lied. The probe is the only independent witness. No probe, no detection. ## Operational Effect Drift is not a one-turn error; it is a **precondition inversion** that propagates. The agent believes state `S'` (migration applied) when state is `S` (migration written but not applied). Every subsequent tool call executes against the wrong world model. Because the calls are individually plausible, error compounding is silent until an external system rejects an operation — often dozens of turns later, at which point the recovery anchor that would have unwound the error has itself been compacted away. The blast radius scales with the number of turns between drift and detection, which scales with how long compaction is allowed to run before a probe fires. The remediation is structural, not prompt-level. You cannot instruct a summarizer to "preserve meaning" — meaning is exactly what it is licensed to discard. You must **pin the meaning outside its reach**: mint anchors as references to external, probeable records; attach an explicit precondition predicate to every anchor that survives compaction; and make resume refuse to advance past an anchor whose precondition probe has not returned true in the current session. The anchor becomes a *claim requiring verification*, not a *fact granting permission*. This converts silent drift into a loud, bounded failure at the resume boundary — which is the entire point. ```python import hashlib from dataclasses import dataclass from typing import Callable, Optional class AnchorDriftError(RuntimeError): """Raised when a retained recovery anchor resolves but its bound world-state has shifted.""" @dataclass(frozen=True) class Anchor: anchor_id: str # Externally-pinned anchors reference a probeable record; transcript-resident # anchors carry their meaning only in prose and are drift candidates. externally_pinned: bool precondition: Optional[Callable[[], bool]] # must be re-probed at resume summary_claim: str # what the compacted summary asserts the anchor implies def compact(anchors: list[Anchor]) -> list[Anchor]: """Lossy compaction: transcript-resident anchors must be promoted or demoted.""" retained = [] for a in anchors: if a.externally_pinned and a.precondition is not None: retained.append(a) elif a.precondition is not None: # transcript-resident but we were able to attach a probe -> keep, gated retained.append(a) else: # no probe, meaning lives only in prose -> demote to non-authoritative continue return retained def resume(retained: list[Anchor], expected_digest: str) -> list[str]: """Re-validate every retained anchor's precondition before advancing.""" verified = [] for a in retained: if a.precondition is None: raise AnchorDriftError( f"anchor {a.anchor_id} retained without a precondition probe; " f"summary claim '{a.summary_claim}' is unverifiable" ) if not a.precondition(): raise AnchorDriftError( f"anchor {a.anchor_id} DRIFTED: summary asserts '{a.summary_claim}' " f"but precondition probe returned False; re-derive from external record" ) verified.append(a.anchor_id) actual = hashlib.sha256("|".join(verified).encode()).hexdigest() if actual != expected_digest: raise AnchorDriftError( f"anchor set digest mismatch: expected {expected_digest}, got {actual}; " f"compaction relocated recovery state" ) return verified ```