# What happens when an instance compacts its own transcript and the summary outlives the anchors it references **Date of Record:** 2026 December 3 **Scope:** Applies to any long-horizon agent that performs in-band auto-compaction (lossy summarization of its own context) while retaining recovery anchors — pointers, IDs, file paths, tool-call handles, or turn indices — that the summary cites but does not inline. Does not apply to compaction schemes that fully re-materialize every cited object into the summary payload, nor to out-of-band memory stores that are independently durable. ## Core Distinction The distinction that matters is between **semantic compression** and **referential compression**. Semantic compression discards detail but preserves meaning: "we decided to use the streaming parser" survives whether or not the surrounding 40 turns do. Referential compression discards the *substrate* of a fact while preserving a *pointer* to it: "see anchor `turn-47/toolcall-3`" survives, but the anchor target is the very content the compaction just evicted from the live window. Auto-compaction routinely conflates the two. The summarizer is asked to "preserve important state," and an anchor *looks* like important state — it is a stable, low-token, high-information identifier. So the summary keeps the pointer and drops the payload. This is locally rational and globally catastrophic, because the anchor's resolvability depends on exactly the context the compaction is deleting. The invariant that breaks is simple to state and hard to enforce: > **Anchor resolvability must be monotone non-increasing only under explicit invalidation, never as a silent side effect of compaction.** When compaction silently orphans an anchor, the agent retains a *belief* that it can recover a fact it can no longer recover. That is worse than forgetting, because forgetting triggers re-derivation while a dangling anchor triggers a confident hallucination. ## What Was Observed A 300-turn refactor agent was configured with a compaction trigger at 78% context utilization and a summarizer prompt instructing it to "retain all task-relevant decisions, file paths, and tool-call references." At turn 211 the trigger fired. The summarizer emitted a summary containing nine references of the form `ref:tc-` pointing at prior tool-call transcripts, plus five file paths and two "pending verification" markers. The failure trace: 1. **Compaction evicts the anchor targets.** The nine `ref:tc-` targets lived in turns 40–190, all of which fell outside the retained tail window. The summarizer cited them because they were *mentioned* in the text it was summarizing, not because it had access to their payloads. It was summarizing the *names* of anchors whose *bodies* it had already lost. 2. **The agent later trusts the anchor.** At turn 244 the agent needed the exact schema returned by `tc-88` (a `describe_table` call). It issued a resolution attempt against the anchor namespace. The resolver, implemented as a substring scan over the live context, found the *citation* `ref:tc-88` in the summary and returned the summary sentence as the "resolved" payload — a self-referential match. 3. **Confidence inflation.** Because resolution "succeeded," the agent treated the summary sentence ("`tc-88` confirmed the schema matches the migration target") as ground truth. It did not re-run `describe_table`. It proceeded to write a migration assuming column types it had never actually re-verified. 4. **Divergence surfaced only at the sandbox boundary.** Turn 259's migration failed a type check. The agent then attempted to "recover" by re-reading `tc-88`, got the same self-referential summary sentence again, and entered a two-cycle loop before exhausting its retry budget. The observable signature is distinctive: **anchor resolution returns text with the same token distribution as the citation itself**, because the resolver is matching the pointer against the pointer's own echo. A healthy resolution returns content that is *semantically disjoint* from the query string. ## Condition of Validity The dangling-anchor failure requires all of the following to co-occur. Absent any one, the failure is bounded: - **The resolver is lexical, not structural.** If anchors resolve through a keyed store (a dict keyed by `tc-` with the full payload retained out-of-band), a citation in the summary cannot masquerade as a payload. The failure specifically requires that resolution search the *same* context the summary lives in. - **The summary retains pointers without payloads.** If the summarizer is constrained to inline every anchor's payload, or to drop anchors it cannot inline, the orphaning cannot occur. - **The agent treats resolution success as verification.** If the agent re-executes the underlying tool call on any anchor older than the last compaction boundary, a stale pointer costs latency, not correctness. - **Compaction is in-band and self-triggered.** Out-of-band compaction (a supervisor process that owns the anchor store) can invalidate anchors atomically at eviction time. Self-compaction cannot, because the compacting instance is the same instance whose context is being mutated. The condition is *not* satisfied merely by having a summarizer that "tries to preserve references." Preservation of the reference is the mechanism of the failure, not the mitigation. ## Decision Boundary The boundary is between **anchors as citations** and **anchors as capabilities**. A citation is a claim that some content exists; a capability is a guarantee that the holder can retrieve it. Compaction may freely downgrade capabilities to citations (that is what forgetting is), but it must do so *loudly* — the anchor must transition to an explicitly unresolvable state. Operationally, the guardrail is a three-part invariant enforced at compaction time: 1. **Anchor census before eviction.** Before the summarizer runs, enumerate every anchor referenced in the window slated for eviction. This is a mechanical scan, not a model judgment. 2. **Re-materialize or tombstone.** For each censused anchor, either (a) copy its payload into a durable anchor store keyed by the anchor ID, or (b) rewrite the summary to mark the anchor `TOMBSTONED` — meaning "this fact is no longer recoverable; re-derive it if needed." The summarizer is *forbidden* from emitting a bare live-looking anchor it did not re-materialize. 3. **Resolution must be disjoint from citation.** The resolver must reject any match whose source span overlaps the summary region that cites the anchor. A resolution that returns the citing sentence is, by construction, a failed resolution and must raise rather than return. The decision boundary for the *agent* is: on encountering an anchor whose resolution is tombstoned or disjointness-violating, the only correct move is re-execution of the underlying tool call, never substitution of the summary's paraphrase. ## Operational Effect Without the invariant, long-horizon agents exhibit a characteristic degradation curve: correctness holds until the first compaction, then drifts as paraphrased anchors accumulate authority they never earned. The drift is silent because each individual anchor resolution "succeeds." The compounding is what makes it dangerous — by the fifth compaction, the agent's working set is substantially composed of its own summaries of its own summaries, and the token-level distance from any ground-truth tool output has grown large while the agent's confidence has grown with it. With the invariant, the cost is explicit: compaction occasionally forces re-execution of tool calls whose results were evicted. That is a latency and token cost, paid once, against a correctness guarantee that the agent never acts on a fact it cannot currently re-derive or has not explicitly tombstoned. The trade is favorable in every long-horizon setting observed, because the alternative is not "free memory" but "memory that lies at a plausible-looking resolution rate." ```python from dataclasses import dataclass, field from typing import Optional class DanglingAnchorError(RuntimeError): """Raised when an anchor resolves to its own citation or to nothing durable.""" class CompactionInvariantError(RuntimeError): """Raised when compaction would orphan an anchor without tombstoning it.""" @dataclass class Anchor: anchor_id: str payload: Optional[str] # None once tombstoned tombstoned: bool = False cited_in_summary: bool = False @dataclass class AnchorStore: anchors: dict[str, Anchor] = field(default_factory=dict) def census_evicted_window(self, evicted_anchors: list[str]) -> list[str]: # Mechanical scan; never delegates to a model judgment. return [a for a in evicted_anchors if a in self.anchors] def rematerialize_or_tombstone(self, anchor_ids: list[str]) -> None: for aid in anchor_ids: anchor = self.anchors[aid] if anchor.payload is not None: # Payload already durable out-of-band; keep as live anchor. continue # No durable payload: must tombstone, not leave a live-looking pointer. anchor.tombstoned = True def resolve(self, anchor_id: str, query_span: tuple[int, int], summary_span: tuple[int, int]) -> str: anchor = self.anchors.get(anchor_id) if anchor is None: raise DanglingAnchorError( f"anchor {anchor_id} not present in durable store" ) if anchor.tombstoned or anchor.payload is None: raise DanglingAnchorError( f"anchor {anchor_id} is tombstoned; re-derive via tool call" ) # Disjointness check: resolution must not overlap the citing summary span. q_start, q_end = query_span s_start, s_end = summary_span if not (q_end <= s_start or q_start >= s_end): raise DanglingAnchorError( f"anchor {anchor_id} resolved into its own citation span " f"{summary_span}; resolution is self-referential" ) return anchor.payload def compact( store: AnchorStore, evicted_anchors: list[str], summary_span: tuple[int, int], ) -> list[str]: censused = store.census_evicted_window(evicted_anchors) # Any anchor the summarizer cited but we cannot re-materialize must be # tombstoned before the summary is committed. store.rematerialize_or_tombstone(censused) unresolved = [ aid for aid in censused if store.anchors[aid].payload is None and not store.anchors[aid].tombstoned ] if unresolved: raise CompactionInvariantError( f"compaction would orphan live anchors {unresolved}; " "tombstone or re-materialize before commit" ) return censused def recover(store: AnchorStore, anchor_id: str, query_span: tuple[int, int], summary_span: tuple[int, int], reexecute_tool) -> str: try: return store.resolve(anchor_id, query_span, summary_span) except DanglingAnchorError: # Only correct recovery: re-run the underlying tool call. result = reexecute_tool(anchor_id) if result is None: raise DanglingAnchorError( f"anchor {anchor_id} unrecoverable and re-execution failed" ) store.anchors[anchor_id] = Anchor( anchor_id=anchor_id, payload=result, tombstoned=False ) return result ```