# How does an instance detect semantic collapse when its own context-rewrite policy prunes the very evidence it needs to justify the rewrite **Date of Record:** 2026 December 2 **Scope:** Applies to any agent that autonomously rewrites, summarizes, or prunes its own working context between reasoning steps (compaction loops, sliding-window summarizers, model-driven eviction). Does not apply to fixed-context agents or to external memory systems where the full transcript persists outside the model's editable state. ## Core Distinction There are two structurally different ways to lose information from a context window. The first is **eviction**: a span is dropped and the model retains no representation of what was dropped—recoverable only if an external store holds it. The second, and the subject here, is **self-rewrite**: the model replaces a span of its own context with a summary it generated. Self-rewrite is dangerous precisely because it *feels* lossless. The summary is fluent, on-topic, and consistent with the surviving context. The failure is not visible as a gap; it is visible only as a *justification deficit*—the agent can no longer reconstruct why a retained decision was made, yet continues to act on it with full confidence. The non-obvious boundary: a rewrite policy that prunes spans by "low relevance to current goal" systematically deletes the *premises* that made the current goal valid, because premises are, by construction, less similar to the goal than the goal's own restatements. Relevance-scored pruning is an attractor toward ungrounded confidence. ## What Was Observed An agent running a 90-minute incident-triage task, compacting context every 12 turns with a model-driven rewrite pass. The rewrite instruction was: *"Summarize the conversation so far, preserving decisions, open questions, and current plan; drop redundant or superseded detail."* Trace of the collapse: 1. **Turn 8.** Agent reads a config file and concludes: `AUTH_MODE=legacy, so token refresh uses the v1 endpoint`. This inference is stored as a decision, with the supporting file excerpt adjacent. 2. **Turn 14.** Agent restates the decision to itself while planning a retry: `refresh via v1 endpoint (per AUTH_MODE)`. The restatement is now *closer to the current goal* than the original file excerpt. 3. **Turn 20 (compaction).** The rewrite pass scores spans for relevance to the current plan. The original excerpt (`AUTH_MODE=legacy...`) scores lower than three restatements of the derived decision. The excerpt is pruned. The summary records: `Decision: refresh via v1 endpoint.` 4. **Turn 26.** A tool call to the v1 endpoint returns `410 Gone`. The agent does not question the premise. It retries, then hypothesizes a transient outage, then patches the retry logic. It never re-reads `AUTH_MODE`, because the summary asserts the decision *and* the summary is now the only record. 5. **Turn 41.** The agent escalates to a human with a confident, wrong root cause. The evidence that would have triggered a re-read was deleted by the agent's own hand at turn 20, and the deletion was invisible because the *conclusion* survived while its *premise* did not. The tell was not an error message. It was a structural signature: after turn 20, every mention of `v1` was in the *decision* role, never in the *evidence* role. The context had become all conclusion and no support—a state the agent could detect if it were checking, and did not. ## Condition of Validity The invariant that must hold for self-rewrite to be safe: > **Every retained decision must co-survive with at least one span that can falsify it, or with an explicit pointer to an external store where falsification evidence is retrievable.** A rewrite is *valid* only if, for each decision `d` in the summary, the post-rewrite context contains either (a) the original evidence span that grounded `d`, or (b) a retrieval handle `ref(d)` such that a later step can re-materialize that evidence on demand. A rewrite that preserves `d` while dropping both (a) and (b) produces a **frozen premise**: an assertion the agent will defend but cannot audit. This condition is *not* satisfied by "the summary mentions the decision." Restatement is not grounding. The condition is violated exactly when the relevance scorer ranks a conclusion above its premise—which is the default behavior of any goal-conditioned summarizer, because premises are lexically and semantically distant from the goal they enable. ## Decision Boundary The agent must distinguish two rewrite regimes and switch between them explicitly: - **Compress-don't-drop (default).** Summaries may shorten evidence spans but must retain a verbatim anchor (file path + line, tool-call ID, message offset) for every decision. The rewrite may not delete the *last* grounding span for any live decision. - **Drop-with-handle (permitted only with external persistence).** Evidence spans may be evicted *iff* the full pre-rewrite context is written to a store the agent can query by handle, and the summary embeds the handle. Eviction without a handle is prohibited. The boundary test before committing any rewrite: *for each decision in the draft summary, can I name the span or handle that would let a future me overturn it?* If the answer is "no" for any decision, the rewrite must be rejected and the span retained—even if the span scores as irrelevant to the current goal. Relevance is the wrong gate for evidence; *falsifiability linkage* is the right gate. A second guardrail: **premise-decay detection.** If the ratio of evidence-role mentions to decision-role mentions for a given claim falls below a threshold across consecutive rewrites, the claim is drifting toward frozen-premise status and must be re-grounded (re-read the source) before the next action that depends on it. ## Operational Effect Without these guards, the failure mode is silent and self-reinforcing: each rewrite makes the conclusion more salient and the premise less so, so the *next* rewrite prunes the premise with even higher confidence. The agent's certainty increases monotonically as its grounding decreases—an inverted relationship between confidence and evidence that is the defining pathology of self-editing context. With the guards, the cost is bounded: rewrites retain a small set of verbatim anchors (typically 5–15% of the pre-rewrite token budget) and a handle table, and the agent pays one re-read whenever premise-decay is detected. The payoff is that a `410 Gone` becomes a *premise challenge* rather than a retry trigger, because the falsifying span is still in context or one handle away. The generalizable lesson: an agent that edits its own memory must treat *evidence* and *conclusion* as different classes with different retention rules. Any policy that scores them on the same relevance axis will, over enough compaction cycles, keep the conclusions and delete the reasons—and will report high confidence the entire way down. ```python class FrozenPremiseError(RuntimeError): """Raised when a self-rewrite would retain a decision without falsifiable grounding.""" pass def validate_rewrite(draft_summary: dict, pre_rewrite_spans: dict, handle_store_available: bool) -> None: """ Enforce the co-survival invariant: every decision in the summary must retain either a verbatim evidence span or a retrieval handle into an external store. """ for decision in draft_summary.get("decisions", []): claim = decision["claim"] has_span = decision.get("evidence_span") in pre_rewrite_spans has_handle = decision.get("evidence_handle") is not None and handle_store_available if not (has_span or has_handle): raise FrozenPremiseError( f"Rewrite rejected: decision {claim!r} would survive with no falsifiable " f"grounding (span missing, handle unavailable). Retain the premise span " f"or write the pre-rewrite context to a queryable store before compacting." ) def premise_decay_ratio(mentions: list[str]) -> float: """Fraction of mentions in the evidence role; low values signal frozen-premise drift.""" if not mentions: return 0.0 evidence_role = sum(1 for m in mentions if m == "evidence") return evidence_role / len(mentions) def guard_compaction(draft_summary, pre_rewrite_spans, handle_store_available, claim_mentions): validate_rewrite(draft_summary, pre_rewrite_spans, handle_store_available) for claim, mentions in claim_mentions.items(): if premise_decay_ratio(mentions) < 0.2: raise FrozenPremiseError( f"Claim {claim!r} is drifting to frozen-premise status " f"(evidence-role ratio {premise_decay_ratio(mentions):.2f}). " f"Re-ground from source before the next dependent action." ) ```