# Under what conditions must an instance refuse hierarchical context folding when a child summary's provenance anchors have been evicted from the parent's retained window **Date of Record:** 2026 November 25 **Scope:** Applies to any agent that maintains a multi-level context tree (leaf turns → segment summaries → folded meta-summaries) and performs budget-aware eviction against a hard token ceiling. Does not apply to flat single-window truncation strategies that never synthesize derived text, nor to systems that retain full provenance externally in a durable store keyed by summary ID. ## Core Distinction The distinction that matters is between **lossy compression of content** and **lossy compression of the reference graph that makes content resolvable**. Hierarchical folding routinely discards tokens from leaf context and replaces them with synthesized summaries — this is expected and bounded, because the summary is *about* the discarded tokens and remains a valid stand-in as long as the fold is honest. The failure mode examined here is different: when budget-aware eviction removes the *anchor* records (the turn IDs, tool-call receipts, file paths, timestamps, or entity keys) that a child summary cites, the child summary does not become merely lossy — it becomes **unfalsifiable**. The parent can no longer re-derive, verify, or contradict the child's claims, because the evidence the child pointed at is gone from the retained window while the child's assertion survives. The summary outlives its own warrant. This is a provenance-continuity invariant, not a quality-of-summary problem. A vague summary of evicted-but-anchored content can be repaired by re-fetching the anchor. A confident summary of evicted-and-unanchored content cannot be repaired at all within the current context, because the instance has no way to know what it no longer knows. ## What Was Observed A long-horizon research agent was folding a 180k-token working set into a 32k ceiling across roughly forty tool-call turns. The folding policy was standard: when the live window exceeded 80% of budget, the oldest contiguous segment was summarized by a cheap model into a 400-token segment summary, the segment's raw turns were evicted, and the summary was inserted at the head of the retained window with a header listing the turn IDs it covered. At turn 31, the agent had produced a segment summary containing the claim *"the API rate limit for endpoint `/v2/ingest` is 600 req/min per tenant (confirmed via headers at turn 12)."* The anchor — turn 12's raw HTTP response headers — had been evicted at turn 9's fold, well before the summary that cited it was even created. The summary was written by a model that still had turn 12 in its folding input at the time of synthesis, so the claim was accurate when written. By turn 34, a budget-aware eviction pass targeting low-salience segments dropped the *earlier* segment summary that had originally carried the header values, on the grounds that its content was "already reflected" in the later summary. The instance then made a downstream decision — sizing a batch job — on the 600 req/min figure. That figure was correct. But when a later tool call returned a `429` with a `X-RateLimit-Limit: 300` header, the instance had no retained anchor to reconcile against: the original 600 figure's evidence and the summary that carried it had both been evicted, and the only surviving artifact was the derived claim. The instance treated the `429` as a transient burst-limit event rather than a contradiction of a stale figure, and continued. The error compounded across eleven subsequent turns because the instance had *a number* but no *warrant for the number*, and therefore no trigger to re-examine it. The observable signature is precise: **a claim in the retained window whose supporting anchors are absent from the retained window, produced under a fold whose input included those anchors.** The instance cannot distinguish "I verified this and the evidence scrolled off" from "I hallucinated this at fold time." Both look identical in the live context. ## Condition of Validity Hierarchical folding is sound — the child summary remains a trustworthy stand-in — if and only if, for every factual assertion in the child summary, at least one of the following holds at the moment the summary enters the retained window: 1. **Anchor retention:** the specific anchor record the assertion cites (turn ID + payload, tool receipt, file path + line) is still present in the retained window or in a reachable durable store, and the summary's header carries a resolvable pointer to it. 2. **Re-derivability:** the assertion is cheaply re-checkable by a tool the instance can call at any later turn (e.g., "re-fetch the headers"), and the summary is tagged as *unverified-derived* so the instance knows to re-check before acting on it. 3. **Demotion to hypothesis:** the assertion is rewritten at fold time as an explicit hypothesis with its confidence and its original source turn ID preserved as a string, so a later contradiction triggers re-evaluation rather than silent supersession. The invariant: **no token in the retained window may assert a fact whose provenance pointer resolves to nothing.** A summary is a *pointer plus a claim*. Eviction may delete the claim's payload, but it must never delete the pointer, and it must never delete the pointer *before* the claim that depends on it is itself evicted. The dependency order is strict: anchors outlive the summaries that cite them, or the summaries must be demoted to hypotheses. The common violation is the reverse order. Budget-aware eviction ranks segments by salience, recency, or "redundancy with later summaries," and a summary that merely *restates* an earlier summary looks maximally redundant — so it is evicted first, taking the last surviving anchor with it. Redundancy-based eviction is exactly the policy that destroys provenance, because derived claims are by construction redundant with their sources. ## Decision Boundary The instance must **refuse to fold** (or must fold only under demotion-to-hypothesis) when the prospective child summary would cite an anchor that the same eviction pass is about to remove. Concretely, before committing a fold that evicts segment S and inserts summary Σ(S): - Compute the anchor set A(Σ) = every turn ID, tool receipt, or path cited by Σ. - Compute the eviction set E = segments removed by this pass. - If A(Σ) ∩ E ≠ ∅ **and** no durable store holds those anchors, the fold is invalid as a plain summary. Either retain the anchors, or rewrite Σ so each affected claim is tagged `unverified-derived` with its source turn ID preserved as an opaque string, or refuse the fold and force an alternative (spill to external store, tighten the summary). The instance must **allow** the fold when anchors are retained or externally resolvable, even if the summary is aggressive and lossy — lossy is fine, unfalsifiable is not. The boundary is not about how much is discarded; it is about whether what survives can still be checked. The instance must **escalate** rather than silently proceed when a contradiction arrives (a `429`, a failed assertion, a conflicting tool result) against a claim whose anchors are already gone. In that case the correct move is to mark the claim as stale-unverified and re-derive from a live tool call, never to reconcile the contradiction against the derived number alone. ## Operational Effect Under this invariant, the practical consequences are: - **Eviction policy inverts.** Salience- and redundancy-based eviction must be replaced by a provenance-aware policy: a segment is evictable only if no retained summary cites it as an anchor, or if the citing summary is demoted first. This means the eviction order is governed by the reference graph, not by recency or token count. - **Fold cost rises modestly.** Each fold must run an anchor-set intersection check and, on collision, either retain a small anchor stub (turn ID + one-line payload, tens of tokens) or demote the claim. The stub is cheap; the demotion is the safety valve. - **Contradiction handling becomes anchor-aware.** When a live tool result contradicts a retained claim, the instance checks whether the claim's anchors survive. If they do, reconcile normally. If they do not, the claim is presumed stale and the live result wins — the instance must not average or split the difference between a verified live value and an unanchored remembered one. - **Amnesia becomes detectable.** The failure mode this prevents is the worst kind of cold-start amnesia: not "I forgot," but "I remember a number and have forgotten that I ever had evidence for it." The `unverified-derived` tag converts an invisible failure into a visible one, which is the entire point. The invariant does not make folding lossless. It makes folding *honest*: every surviving claim either has a live warrant or is explicitly flagged as warrant-less, and the instance is never permitted to act on the second kind as though it were the first. ```python from dataclasses import dataclass, field from typing import Optional class ProvenanceEvictionError(RuntimeError): """Raised when a fold would evict anchors still cited by a retained summary.""" pass @dataclass class Segment: seg_id: str turn_ids: set[str] tokens: int @dataclass class Summary: summary_id: str cites_anchors: set[str] # turn IDs / receipts referenced by its claims claims: list[str] = field(default_factory=list) unverified_derived: bool = False def commit_fold( summary: Summary, eviction_set: list[Segment], retained_anchors: set[str], durable_store_anchors: set[str], ) -> Summary: """ Enforce the provenance-continuity invariant before inserting a child summary. A fold is valid iff every anchor the summary cites is either retained in the live window or resolvable from a durable store. Otherwise the summary must be demoted to unverified-derived (source turn IDs preserved as strings) or the fold must be refused. """ evicted_turn_ids: set[str] = set() for seg in eviction_set: evicted_turn_ids |= seg.turn_ids resolvable = retained_anchors | durable_store_anchors orphaned = summary.cites_anchors - resolvable if not orphaned: return summary # Anchors the summary cites are being evicted with no durable backing. # Attempt demotion: keep the claim, keep the source IDs as opaque strings. if all(a in evicted_turn_ids for a in orphaned): summary.unverified_derived = True summary.claims = [ f"{c} [unverified-derived; source={sorted(orphaned)}]" for c in summary.claims ] return summary # Orphaned anchors that are neither evicted here nor resolvable: the # reference graph is already broken and cannot be repaired by this fold. raise ProvenanceEvictionError( f"Summary {summary.summary_id} cites anchors {sorted(orphaned)} that are " f"neither retained, durably stored, nor part of this eviction pass. " f"Refusing fold: the claim would outlive its warrant and become " f"unfalsifiable in the retained window." ) def reconcile_contradiction( claim_anchors: set[str], retained_anchors: set[str], live_value: str, remembered_value: str, ) -> str: """ When a live tool result contradicts a retained claim, the anchor test decides whether to reconcile or to defer to the live value. """ if claim_anchors <= retained_anchors: # Anchors survive: normal reconciliation is permitted. return f"reconcile({remembered_value}, {live_value})" # Anchors gone: the remembered value is unfalsifiable. Live value wins; # never average an unanchored memory against a verified observation. return live_value ```