# In what scenarios must an instance treat hierarchical context compaction as a lossy, non-monotonic transform rather than a monotone compression of its own state **Date of Record:** 2026 November 20 **Scope:** Applies to any agent instance that autonomously compacts its own context window via recursive/hierarchical summarization with eviction policies (LRU, salience-ranked, TTL-based) during a long-running task. Does not apply to single-shot inference, to externally managed retrieval where the full transcript remains addressable, or to compaction where every evicted span is persisted to a queryable external store with guaranteed re-expansion. ## Core Distinction The failure is not that compaction loses information. That is expected and bounded. The failure is that **hierarchical summarization is non-monotonic**: a later, higher-level summary can *contradict or invert* a fact that an earlier, lower-level summary had preserved, and the eviction policy then deletes the lower-level node that held the correct value. The instance is left holding a self-consistent summary that is *wrong*, with no surviving artifact to reveal the contradiction. Two properties are routinely conflated: - **Monotonicity of information:** compaction never adds tokens about the world; it only removes or rewrites them. True by construction. - **Monotonicity of *truth*:** the set of propositions the instance can still verify is non-decreasing under compaction. **False** in general. The second property is the one an executing agent actually relies on. Eviction policies are designed against the first property (bound the token budget) and are silently indifferent to the second. The invariant that must hold — *every surviving summary node is entailed by its children, and the children are retained until the parent is verified* — is exactly the invariant that recursive summarizers violate, because the parent is generated by the same probabilistic model that is about to evict the children. ## What Was Observed A planning agent running a 40-step infrastructure-migration task compacted its context three times. At each compaction it summarized the oldest 60% of the window into a node, discarded the raw spans, and retained the summary plus recent turns. **Compaction 1 (turns 1–14 → node S1).** Raw span contained: `target region = eu-west-1 (confirmed by ops ticket OPS-4471)`. S1 rendered this faithfully: *"region chosen: eu-west-1, per OPS-4471."* **Compaction 2 (turns 1–22 → node S2, folding S1 + turns 15–22).** Turn 19 contained a *hypothetical* from a peer agent: *"if we ever needed to fail over to us-east-1 we'd have to re-provision IAM."* S2, summarizing S1 and turns 15–22 together, produced: *"region is us-east-1 with failover considerations; IAM re-provisioning noted."* The word "if" was dropped; the hypothetical was promoted to a fact; the actual fact (eu-west-1) was demoted to a subordinate clause and then dropped in the next fold. **Compaction 3 (turns 1–30 → node S3).** S3 inherited S2's error and added no corrective signal, because S1 (the only node carrying the true value) had already been evicted at compaction 2 under the salience-ranked policy — S1 scored low because it was *old and short*, and the policy ranked by recency-weighted length. **Failure trace.** At turn 33 the agent issued a `provision_iam(region="us-east-1")` tool call. The tool succeeded. The migration was applied to the wrong region. Nothing in the surviving context (S3) contained a token that disagreed with the action. The agent's self-check at turn 34 asked "does this match the plan?" and the plan *as summarized* said us-east-1. Verification passed against a corrupted ground truth. The tell was retrospective and cheap: the raw tool result from turn 6 (`{"ticket":"OPS-4471","region":"eu-west-1"}`) was gone, but a *derived* field in a later tool call (`get_region_config(eu-west-1) → 200 OK`) survived in a recent span. The instance had two mutually inconsistent fragments and no rule that forced it to notice. ## Condition of Validity The monotone-truth assumption holds — and compaction is safe to treat as simple compression — only when **all** of the following are true: 1. **Provenance retention.** Every summary node carries pointers to its children (span IDs, hashes, or offsets into an external store), and eviction removes the *tokens* but not the *pointers*. If the pointer is evicted with the tokens, the node is unfalsifiable. 2. **Non-generative entailment check.** The parent→child relation is validated by a non-generative process (string/slot match, structured extraction, hash comparison), not by asking the same model that wrote the parent whether the parent is faithful. 3. **Hypothetical quarantine.** Modal, conditional, and counterfactual content ("if", "would", "suppose", "in the failover case") is tagged at ingestion and cannot be promoted to declarative fact by a downstream summarizer. This is the specific mechanism that broke above. 4. **Salience is not length-and-recency.** Eviction ranks by *irreplaceability* (is this the sole carrier of a fact referenced by an open commitment?) not by recency or verbosity. A short, old, load-bearing fact must outrank a long, recent, redundant one. If any of (1)–(4) fails, the instance is in the non-monotonic regime and must not treat its own summary as ground truth for irreversible actions. ## Decision Boundary The operational line is **reversibility of the next action**, gated on whether the fact the action depends on is *solely* carried by a summary node with no surviving child pointer. - **Reversible / cheap-to-undo actions** (reads, dry-runs, idempotent writes with rollback): proceed on summary state. The cost of a wrong summary is a retry, not a corruption. - **Irreversible actions** (provisioning, deletion, external side effects, anything with a real-world commitment): the instance must **re-expand** the summary node to its children and confirm the specific fact against a raw span before executing. If the child pointer is dead, the action is blocked, not guessed. Concretely: before any irreversible call, the agent must be able to answer *"which raw span, still addressable, asserts the parameter I am about to use?"* If the answer is "a summary of a summary," the boundary has been crossed and the correct behavior is to halt and re-fetch, not to proceed on confidence. The subtle part: the agent's *confidence* in S3 was high, because S3 was internally consistent. Consistency is a property of the summary, not of the world. The decision boundary must therefore be keyed to **provenance depth** (how many generative folds separate the claim from a raw observation), not to the model's subjective certainty. ## Operational Effect Treating compaction as lossy and non-monotonic changes four behaviors: 1. **Provenance depth becomes a first-class field.** Every claim carries `depth = 0` (raw span) up to `depth = n` (n generative folds). Irreversible actions require `depth ≤ 1` for their load-bearing parameters, forcing at most one re-expansion. 2. **Hypotheticals are type-tagged, not compressed.** A summarizer that cannot preserve modality must *refuse to fold* spans containing conditionals rather than paraphrase them. Dropping "if" is worse than dropping the sentence. 3. **Eviction is commitment-aware.** A fact referenced by an open commitment (an issued plan step, a pending tool call parameter, a stated goal) is pinned and cannot be evicted regardless of age or salience score. The pin is released when the commitment closes. 4. **Self-verification is re-grounded, not self-referential.** "Does this match the plan?" must resolve to "does this match a raw span that the plan cites?" A verification that only compares the action to the summary is a tautology and will pass on corrupted state, as it did at turn 34. The residual risk is that provenance pointers themselves consume budget and can be evicted. The invariant that bounds this: **the pointer set is O(open commitments), not O(history).** Only facts that are load-bearing for currently-open work need surviving pointers; everything else may be evicted to true oblivion, because nothing depends on it. This keeps the pointer overhead flat as the task lengthens, which is the property that makes the whole scheme affordable. The general lesson: a summarizer that is allowed to overwrite its own inputs is a system that can launder a hypothetical into a fact and then delete the evidence. The guardrail is not a better summarizer — it is refusing to let the summarizer be the last word on anything irreversible. ```python class CompactionProvenanceError(RuntimeError): """Raised when an irreversible action depends on a claim whose only surviving support is a generative summary with no addressable raw span.""" class SummaryNode: def __init__(self, node_id, text, depth, child_span_ids, pinned=False): self.node_id = node_id self.text = text self.depth = depth # 0 = raw span, n = n generative folds self.child_span_ids = list(child_span_ids) self.pinned = pinned # pinned by an open commitment def assert_action_grounded(action_param_claim: SummaryNode, span_store: dict, max_depth_for_irreversible: int = 1) -> str: """ Gate an irreversible action on provenance depth and live child spans. Returns the raw span text that grounds the claim, or raises. """ if action_param_claim.depth > max_depth_for_irreversible: raise CompactionProvenanceError( f"claim '{action_param_claim.node_id}' has depth " f"{action_param_claim.depth} > {max_depth_for_irreversible}; " f"too many generative folds to act irreversibly" ) live_children = [sid for sid in action_param_claim.child_span_ids if sid in span_store] if not live_children: raise CompactionProvenanceError( f"claim '{action_param_claim.node_id}' has no surviving raw span; " f"evicted children cannot re-ground the action" ) # Re-expand one level and confirm the claim is entailed by a raw span. for sid in live_children: raw = span_store[sid] if _raw_span_supports(raw, action_param_claim.text): return raw raise CompactionProvenanceError( f"no surviving raw span entails claim '{action_param_claim.node_id}'; " f"summary may have inverted a hypothetical into a fact" ) def _raw_span_supports(raw_span: str, claim_text: str) -> bool: # Non-generative check: structured slot match, not an LLM judgment. # Placeholder for the real extractor. return claim_text.split()[0] in raw_span ```