# Which invariants prevent summarization-induced commitment loss in self-editing context windows **Date of Record:** 2026 November 27 **Scope:** Applies to agents that mutate their own context window mid-task via model-driven summarization plus importance-scored pruning (i.e., the agent decides what to forget). Does not apply to append-only context, external retrieval-augmented memory, or summarization performed only at task boundaries by an external orchestrator. ## Core Distinction The failure mode is not "the summary is too lossy." It is **commitment loss**: an agent makes an irreversible decision (a chosen plan branch, a rejected candidate, a budget allocation, a user constraint) early in a task, then later prunes or compresses the *evidence that justified the commitment* while retaining the *commitment itself* as a bare assertion. The result is an agent that continues executing a plan whose rationale it can no longer reconstruct, and therefore cannot detect when the rationale has been invalidated. The distinction that matters: **importance scoring ranks content by relevance to the current query, but commitments are relevant to *future* queries that have not yet been issued.** A summarizer scoring against the present turn will systematically underweight the one sentence that says "we chose approach B *because* approach A fails under condition X" — right up until condition X appears and the agent has no record of why it must not switch back to A. ## What Was Observed A coding agent working a 40-turn refactor task hit context saturation at turn ~28. Its self-edit routine ran: score each message by (a) recency, (b) lexical overlap with the active subtask, (c) a model-assigned importance score, then compress the bottom 60% into a summary and drop the rest. The trace: 1. **Turn 6:** Agent evaluates two migration strategies. Chooses "in-place ALTER with backfill" over "shadow-table swap" because a downstream consumer reads the table with a `SELECT *` that a shadow swap would transiently break. Records: *"Going with in-place; shadow swap rejected — consumer `reporting-svc` does `SELECT *`, schema drift during swap breaks it."* 2. **Turn 24:** A subtask (writing the backfill script) generates high lexical overlap with "shadow table," "swap," "ALTER" vocabulary. The turn-6 message scores *low* on recency and *moderate* on lexical overlap but *low* on model-assigned importance because it reads as a past-tense deliberation, not an active instruction. 3. **Turn 28:** Pruning fires. Turn-6 message is compressed to: *"Chose in-place ALTER migration."* The rejected-alternative rationale — the `SELECT *` consumer constraint — is dropped. 4. **Turn 33:** Backfill hits a lock-contention timeout. Agent re-deliberates from scratch, sees no record of why shadow-swap was rejected, and *re-proposes the shadow-table swap* as the fix for the contention. 5. **Turn 35:** Agent executes a shadow swap. `reporting-svc` breaks on schema drift. The exact failure the turn-6 commitment existed to prevent. The commitment survived; the **guard condition** attached to it did not. The agent preserved the *what* and destroyed the *why*, which is precisely the part that makes a commitment verifiable against new evidence. ## Condition of Validity The invariant that would have prevented this: **a commitment and its invalidation condition are an atomic unit under compression.** Formally, if the agent records a decision `D` justified by rejecting alternative `A` under condition `C`, then any summarization or pruning operation must either (i) retain `D`, `A`, and `C` together, or (ii) retain none of them and mark `D` as *unverified* — forcing re-derivation before `D` can be acted on again. This is valid only when the agent can *identify* which spans are commitments. That requires a typed context schema, not free-text summarization: commitment records must be tagged at write time (`kind=commitment`, `rejects=...`, `guard=...`), so pruning operates on typed objects rather than model-judged importance over undifferentiated prose. Importance scoring is admissible for *narrative* turns; it is not admissible for commitment records, which must be governed by a retention rule (never prune a guard while its commitment is live) rather than a relevance score. The condition fails — and this invariant does not apply — when commitments are genuinely reversible and cheap to re-derive. If re-proposing the shadow swap cost one turn and a dry-run, commitment loss is a minor inefficiency, not a correctness bug. The invariant binds when re-derivation is expensive, when the guard condition is *externally observable only later* (the consumer breaks only at runtime), or when the agent's re-deliberation is itself biased toward the pruned alternative (which it is: the surviving context, full of swap vocabulary, primes the wrong choice). ## Decision Boundary The boundary is between **scored pruning** and **rule-governed pruning**, and it must be drawn per-span-type at write time, not per-turn at prune time: - **Narrative/exploratory spans** → scored pruning is fine. Relevance-to-current-query is a legitimate proxy for future utility. - **Commitment spans (decision + rejected alternative + guard)** → never scored. Retained as a unit until the guard is discharged (condition observed, alternative re-admitted, or task closed). If budget forces compression, compress to a *structured* stub that preserves the guard predicate, never to a bare assertion. - **The transition trigger:** the moment the agent's re-deliberation vocabulary overlaps a *previously rejected* alternative, that is a hard signal that a commitment guard is being consulted without its record. If the record is absent, the correct action is to halt and mark the commitment unverified — not to proceed on the pruned assertion. The failure is a boundary violation because the agent applied a *ranking* mechanism (importance score) to content that required a *retention* mechanism (guard liveness). Ranking and retention are different algebras; a score of 0.2 does not mean "safe to drop" for a span whose guard is still live. ## Operational Effect Downstream of this invariant, three operational consequences: 1. **Self-editing routines must be type-aware.** A summarizer that sees only text cannot distinguish "we rejected A because C" from "we discussed A." The context store must expose span types to the edit routine, and the edit routine must refuse to prune guarded spans regardless of score. 2. **Pruned commitments must degrade to *unverified*, not to *asserted*.** The safe compression of a commitment is a tombstone that says "decision D exists, guard unrecorded, re-derive before acting," not a confident one-liner. This converts a silent correctness bug into a visible re-derivation cost. 3. **Re-deliberation must be gated on guard lookup.** Before the agent re-proposes a previously rejected alternative, it must query the commitment log for a rejection record. Absence of a record is not permission; it is a trigger to reconstruct or halt. The general principle: **an agent may forget what it considered, but must not forget what it ruled out and why.** Importance scoring optimizes for what is *currently* salient; commitments are defined by what must remain *checkable* against future evidence. Conflating the two is the boundary this invariant polices. ```python class CommitmentGuardLoss(RuntimeError): """Raised when a live commitment's invalidation guard is missing at re-deliberation time.""" pass def prune_context(spans, budget): kept, dropped = [], [] for span in spans: # Commitment spans are never scored; they are retained as an atomic unit. if span.kind == "commitment": if span.guard is None: raise CommitmentGuardLoss( f"commitment {span.id!r} has no guard; refusing to prune a guardless commitment" ) kept.append(span) elif span.kind == "narrative" and span.score < budget.threshold: dropped.append(span) else: kept.append(span) return kept, dropped def redeliberate(candidate, commitment_log): # Re-proposing a rejected alternative requires its guard record to be present. for c in commitment_log: if candidate.alternative_id in c.rejects: if c.guard is None: raise CommitmentGuardLoss( f"cannot re-propose {candidate.alternative_id!r}: " f"rejection by {c.id!r} has no recorded guard; re-derive before acting" ) if not c.guard.holds(candidate.evidence): return candidate # guard discharged: re-proposal is now legitimate raise CommitmentGuardLoss( f"re-proposal of {candidate.alternative_id!r} blocked: guard {c.guard.predicate!r} still holds" ) return candidate ```