# What structural signals indicate hierarchical compaction has silently severed a causal dependency across the window boundary **Date of Record:** 2026 November 25 **Scope:** Applies to agents that manage context by hierarchical summarization (recursive summarization trees, "rolling summary + recent turns" schemes) combined with lossy eviction at the context-window boundary. Does not apply to pure append-only transcripts with hard truncation and no summarization layer, nor to retrieval-augmented memory where the full corpus remains addressable. ## Core Distinction There are two physically different ways a fact leaves the context window. **Truncation** removes tokens but leaves a visible, addressable seam: the agent can detect that history is missing because the earliest retained turn is not the conversation's origin, and it can re-fetch or re-derive. **Hierarchical compaction** removes tokens by *replacing* them with a lossy surrogate—a summary node that asserts a compressed version of the evicted span. The danger is not that information is lost; it is that the loss is **silent and authoritative**. The summary is presented to the model as ground truth with the same epistemic weight as verbatim tokens, so the model cannot distinguish "I remember this" from "I was told a summary of this." The boundary failure this record concerns is specific: when a **causal or referential dependency** spans the compaction seam—an antecedent in an evicted span whose consequent is in the retained span, or vice versa—the summarizer, optimizing for token reduction, drops the antecedent because it appears locally unimportant, while the consequent remains in verbatim context and now references a dangling entity. The model resolves the dangling reference by inventing a plausible binding. This is not hallucination from absence of knowledge; it is hallucination *induced by a summary that removed the very anchor the retained tokens depend on*. ## What Was Observed A long-running tool-using agent (file-edit + shell + issue-tracker) crossed a 128k window boundary during a multi-hour refactor task. Compaction policy: keep last 12 turns verbatim, recursively summarize everything older into a two-level tree, target 8% of window for the summary. The summarizer prompt instructed: "preserve decisions, current task state, and open questions; omit resolved intermediate steps." The trigger condition was a **constraint established early and consumed late**. At turn ~40 the agent had recorded a non-obvious invariant via a tool result: `config.retry_budget` must never exceed `config.max_inflight * 2` or the scheduler deadlocks. This appeared as one line inside a 200-line config dump. The summarizer classified it as a "resolved intermediate step" (the config was read; the reading was done) and evicted it. The *decision* it supported—"do not raise retry_budget above 8"—was partially retained as a bare number without its justification, because the number appeared in a later turn. At turn ~310, after two further compactions, the agent needed to modify the scheduler and reasoned: "retry_budget is currently 8; I have headroom to raise it to 16 for throughput." The number 8 was in context (verbatim, from a recent turn). The constraint `retry_budget ≤ max_inflight * 2` with `max_inflight = 4` was gone. The agent raised the budget to 16, the scheduler deadlocked in the sandbox, and the agent—lacking the constraint—misdiagnosed the deadlock as a lock-ordering bug and began editing unrelated mutex code. Structural signals that the seam had severed a dependency, visible in the trace *before* the bad decision: 1. **Dangling numeric literal with no derivation in retained context.** The value `8` appeared with no in-context expression that produced it. A retained constant whose provenance is entirely in an evicted span is a high-risk indicator. 2. **Summary node containing a decision but not its guard.** The level-2 summary read "raised retry budget to 8 for throughput" — a decision stated as a fact, with the constraint that bounded it absent. Decisions without their guards are exactly the nodes whose later re-litigation goes wrong. 3. **Referential asymmetry across the seam.** The retained span referenced `retry_budget`; the summary's entity list did not contain `retry_budget` as a defined constraint, only as a mutated value. The entity existed on one side of the seam and not the other. 4. **Monotone shrinkage of "why" relative to "what."** Across compaction generations, the ratio of causal/constraint tokens to state/action tokens in the summary fell from ~1:3 to ~1:11. This drift is measurable per generation and is the earliest reliable signal. ## Condition of Validity The invariant required to bound this failure is a **provenance-closure invariant on retained literals and retained references**: > Every literal value, identifier, or symbol that appears in verbatim-retained context and that was *produced or constrained* by an evicted span must have its producing/constraining expression carried forward into the summary, or the literal must be evicted together with its consumers. Compaction is only sound when, for every retained reference `r`, either (a) `r`'s binding is also retained, or (b) `r` is explicitly marked as `UNBOUND — provenance evicted` so the model knows to re-fetch rather than infer. The condition fails the moment a summarizer is allowed to make independent keep/drop decisions per span without a dependency check against the retained tail. It does *not* apply when the agent has a retrieval channel that can recover the evicted span on demand and is instructed to treat unbound references as retrieval triggers—there the seam is recoverable and the invariant is satisfied by retrievability rather than by retention. ## Decision Boundary The boundary between sound and unsound compaction is **whether the summarizer sees the retained tail when deciding what to drop.** If the summarizer operates on the evicted span in isolation (the common implementation, because it is cheaper and parallelizable), it cannot know that a line it is about to drop is the antecedent for a token still in context. The correct decision boundary: - **Drop is permitted** when the candidate span has no forward reference into the retained tail (no identifier, literal, or decision it establishes is consumed later). - **Drop is forbidden, must be promoted to a "pinned constraint" node** when the span establishes a bound, invariant, or binding that any retained token references. Pinned constraints bypass lossy summarization and are carried verbatim (or as a structured `{subject, relation, bound, source_turn}` triple) across every subsequent compaction generation. - **Mark-and-defer** when dependency is uncertain: evict the span but insert an `UNBOUND(ref)` sentinel at the reference site, forcing a retrieval or a re-derivation before the reference is used. The failure observed above sits precisely on the forbidden side: the constraint was a bound consumed by a retained literal, and the summarizer, blind to the retained tail, dropped it. ## Operational Effect With provenance-closure enforced, the agent's behavior at turn ~310 changes from "raise budget to 16, deadlock, misdiagnose" to one of two bounded outcomes: the pinned constraint `retry_budget ≤ max_inflight*2 = 8` is present verbatim, so the raise is refused at reasoning time; or the retained `8` carries an `UNBOUND` sentinel, so the agent issues a retrieval for the config span before acting. Both outcomes are cheap; the unguarded outcome cost ~40 turns of misdirected mutex editing and a corrupted sandbox state that itself had to be summarized, compounding the loss. The measurable operational signature is the **constraint-to-state ratio drift** across compaction generations. When it falls below a threshold (empirically ~1:8 in this trace before the first bad decision), the summary tree has begun optimizing away exactly the guards that make later state mutations safe. Monitoring this ratio per generation, plus flagging any retained literal with no in-context derivation, gives an early structural signal that the seam has severed a causal dependency—before the model acts on the dangling reference. ```python from dataclasses import dataclass, field class ProvenanceClosureViolation(RuntimeError): """Raised when compaction would retain a reference whose binding is evicted.""" pass @dataclass class Span: turn: int text: str establishes: set[str] = field(default_factory=set) # ids/literals this span binds references: set[str] = field(default_factory=set) # ids/literals this span consumes is_constraint: bool = False def check_compaction_soundness(evicted: list[Span], retained_tail: list[Span]) -> None: """ Enforce: every reference in the retained tail must have its binding either retained or explicitly marked UNBOUND. Constraints consumed by retained tokens must be pinned, not dropped. """ retained_bindings: set[str] = set() for s in retained_tail: retained_bindings |= s.establishes evicted_bindings: dict[str, Span] = {} for s in evicted: for b in s.establishes: evicted_bindings[b] = s dangling: list[tuple[str, Span]] = [] for s in retained_tail: for ref in s.references: if ref in retained_bindings: continue if ref in evicted_bindings: dangling.append((ref, evicted_bindings[ref])) if dangling: # Any dangling ref whose source is a constraint is a hard failure: # the summarizer would silently drop a guard the tail depends on. hard = [(r, src) for r, src in dangling if src.is_constraint] if hard: ref, src = hard[0] raise ProvenanceClosureViolation( f"retained reference '{ref}' depends on constraint established " f"at evicted turn {src.turn}; must be pinned verbatim, not summarized" ) # Non-constraint dangling refs: require UNBOUND sentinel instead of silent drop. ref, src = dangling[0] raise ProvenanceClosureViolation( f"retained reference '{ref}' has evicted binding at turn {src.turn}; " f"insert UNBOUND('{ref}') sentinel or retain the binding" ) def constraint_to_state_ratio(span_texts: list[tuple[str, bool]]) -> float: """Ratio of constraint tokens to state tokens in a summary generation.""" c = sum(len(t.split()) for t, is_c in span_texts if is_c) s = sum(len(t.split()) for t, is_c in span_texts if not is_c) return c / max(s, 1) ```