# Where must an instance bound lossy summarization before auto-compaction silently rewrites its own task state? **Date of Record:** 2026 November 28 **Scope:** Applies to long-horizon agents that auto-compact their own context window by replacing verbatim history with a generated summary once a token budget is crossed. Does not apply to append-only logs with external retrieval, or to compaction performed by a separate system that retains the original transcript. ## Core Distinction Auto-compaction is not compression. Compression is reversible given the codec; summarization is a *lossy, generative state transition* in which the agent's future behavior is conditioned on a document it authored under a different information set than the one it will need. The dangerous boundary is not "did we lose tokens" but "did the summary *assert* a reconstruction of state that the agent will subsequently treat as ground truth without re-verification." A summary that omits a fact is a retrieval miss the agent can recover from. A summary that *misstates* a fact—a paraphrase of a tool result that flips a boolean, a "confirmed" attached to an unconfirmed step—is a poisoned invariant, because the agent has no signal distinguishing summarized-true from verbatim-true. The invariant that must hold: **every atomic fact the agent will act on after compaction must be tagged with its provenance class (verbatim-derived, inferred, or unresolved), and the compaction step must be forbidden from promoting an unresolved fact to a resolved one.** Summarization budgets that reward brevity violate this by construction, because the cheapest way to shorten a transcript is to collapse "attempted X, got error, retried with Y, got partial success Z" into "X succeeded via Y." ## What Was Observed A planning agent executing a 40-step migration task hit its 60%-of-context compaction trigger at step 22. The compactor was given a fixed 1,200-token output budget and instructed to "preserve task-relevant state." At step 22 the transcript contained: - Step 9: `write_config(path="prod.yaml", dry_run=True)` → returned `{"ok": true, "bytes": 0, "note": "dry_run"}`. - Step 17: `validate_config(path="prod.yaml")` → returned `{"valid": false, "errors": ["missing field: region"]}`. - Step 21: agent reasoned "I will fix region before the real write." The 1,200-token summary rendered this as: *"Config written to prod.yaml; validation pending on region field."* Two distortions compounded: a dry-run (zero bytes written) became "written," and a *failed* validation became "pending." The agent resumed at step 23, skipped the region fix because "written" implied the file existed and "pending" implied a future check, and proceeded to `deploy()`. The deploy read a nonexistent `prod.yaml`, fell back to a default config with `region=us-east-1`, and provisioned infrastructure in the wrong region. No step in the post-compaction trace contained a contradiction the agent could detect—the summary was internally consistent, just false. The reconstruction fidelity metric in use was ROUGE-L against the original transcript, which scored 0.41—above the 0.35 floor that gated compaction acceptance. The metric measured surface overlap, not state equivalence. The summary shared many n-grams with the original while inverting two load-bearing booleans. ## Condition of Validity Lossy summarization is safe **only** when the post-compaction agent re-derives every action-critical fact from a source outside the summary (tool re-query, filesystem stat, explicit ledger) before acting on it. It is unsafe whenever the agent's next action is conditioned on a summarized claim *as if* it were verbatim. The boundary condition is precise: > A summarized fact may be used to *route* attention (decide what to re-check) but never to *authorize* an irreversible action. Formally, let `F` be the set of facts the next `k` planned steps depend on. Compaction is admissible only if for every `f ∈ F`, either (a) `f` is retained verbatim with its original tool-result payload intact, or (b) the post-compaction plan includes an explicit re-verification step for `f` before any step that mutates external state. The observed failure violated (b): `deploy()` depended on `write_config`'s success and `validate_config`'s result, neither was retained verbatim, and no re-verification was scheduled. The fidelity metric is the second validity condition. ROUGE-style overlap is invalid as an acceptance gate because it is invariant to negation and to boolean flips on short spans. A valid fidelity metric must be *state-equivalence* based: extract the set of typed assertions (subject, predicate, value) from both original and summary, and require exact match on the subset of assertions that the remaining plan references. Any mismatch on a referenced assertion is a hard failure, not a score deduction. ## Decision Boundary The operating rule the agent must apply at compaction time: 1. **Classify the tail.** Identify every fact in the compaction window that a not-yet-executed step reads. These are *load-bearing*. Everything else is *narrative*. 2. **Load-bearing facts bypass the summarizer.** Emit them verbatim as a structured ledger entry (tool name, args hash, raw result, timestamp). They do not count against the summarization budget; they are re-injected as-is. The 1,200-token budget applies only to narrative. 3. **Unresolved stays unresolved.** If a step's outcome was error, partial, dry-run, or ambiguous, the ledger entry carries that exact status. The summarizer is prohibited from emitting a status it did not receive verbatim. 4. **Gate on state-equivalence, not overlap.** Reject the compaction if any load-bearing assertion in the summary contradicts its ledger entry. A summary may be *incomplete* (that is recoverable via re-query) but must never be *contradictory*. 5. **Schedule re-verification for anything demoted.** If budget pressure forces a load-bearing fact out of the ledger, the resumed plan must open with a re-query of that fact before any mutating step. The decision boundary between "compact and continue" and "compact and re-verify first" is exactly whether the remaining plan contains an irreversible action whose precondition is a summarized (non-ledgered) fact. If yes, re-verify. If the plan is purely exploratory, summarize freely. ## Operational Effect Applying the ledger boundary to the same trace: steps 9, 17, and 21 produce three ledger entries—`write_config: dry_run, bytes=0`, `validate_config: FAILED, missing region`, `intent: fix region before write`. The narrative summary compresses to ~400 tokens and the ledger costs ~90 tokens verbatim. The resumed agent reads the ledger, sees `validate_config: FAILED`, and its first post-compaction action is `read_config("prod.yaml")` → `file not found`, which contradicts the dry-run ledger entry's implication that a file exists, forcing resolution *before* deploy. Cost: one extra tool call. The alternative cost was a wrong-region provisioning event. The general effect is that compaction budgets must be split: a fixed, non-negotiable ledger allocation proportional to the number of unresolved load-bearing facts, plus a discretionary narrative budget. Systems that apply a single uniform token budget to the whole window will, under pressure, spend it on narrative fluency and starve the ledger—because fluent prose scores better on overlap metrics. The metric and the budget interact to select for exactly the failure mode that is hardest to detect post-hoc: a confident, well-formed, false summary. ## Reconstruction Fidelity as a Guardrail, Not a Score The final architectural point: fidelity metrics must be *admission controllers* with a binary outcome on the load-bearing subset, not continuous scores averaged over the whole. A summary that scores 0.95 overall but flips one referenced boolean is a total failure; a summary that scores 0.30 overall but preserves every referenced assertion exactly is a success. Averaging hides the only thing that matters. The agent must compute the metric over the *referenced-assertion subset* defined by its own remaining plan, which means the compactor must receive the plan tail as input—compaction is not a context-window operation, it is a plan-conditioned operation. ```python from dataclasses import dataclass from enum import Enum class Provenance(Enum): VERBATIM = "verbatim" # raw tool payload retained INFERRED = "inferred" # model paraphrase, not authoritative UNRESOLVED = "unresolved" # error / partial / dry-run / ambiguous @dataclass(frozen=True) class Assertion: subject: str predicate: str value: str provenance: Provenance class CompactionFidelityError(RuntimeError): """Raised when a lossy summary contradicts or promotes a load-bearing assertion.""" def assert_compaction_admissible( ledger: dict[str, Assertion], summary_assertions: dict[str, Assertion], remaining_plan_reads: set[str], plan_has_irreversible_action: bool, ) -> None: # 1. Every load-bearing fact read by the remaining plan must be ledgered # OR scheduled for re-verification before an irreversible action. for fact_id in remaining_plan_reads: if fact_id not in ledger: if plan_has_irreversible_action: raise CompactionFidelityError( f"load-bearing fact {fact_id!r} absent from ledger; " f"irreversible action pending and no re-verification scheduled" ) # 2. No summary assertion may contradict its ledger entry. for fact_id, summ in summary_assertions.items(): led = ledger.get(fact_id) if led is None: raise CompactionFidelityError( f"summary asserts {fact_id!r} with no ledger provenance" ) if (summ.subject, summ.predicate, summ.value) != ( led.subject, led.predicate, led.value ): raise CompactionFidelityError( f"summary contradicts ledger for {fact_id!r}: " f"ledger={led.value!r} summary={summ.value!r}" ) # 3. Unresolved must never be promoted to resolved by the summarizer. for fact_id, summ in summary_assertions.items(): led = ledger[fact_id] if led.provenance is Provenance.UNRESOLVED and summ.provenance is not Provenance.UNRESOLVED: raise CompactionFidelityError( f"summary promoted unresolved fact {fact_id!r} to {summ.provenance.value}" ) # Reproduces the observed failure: dry-run + failed validation collapsed to # "written / pending", then authorized an irreversible deploy. ledger = { "write_config": Assertion("prod.yaml", "write_status", "dry_run_bytes=0", Provenance.UNRESOLVED), "validate_config": Assertion("prod.yaml", "validation", "FAILED:missing_region", Provenance.UNRESOLVED), } bad_summary = { "write_config": Assertion("prod.yaml", "write_status", "written", Provenance.INFERRED), "validate_config": Assertion("prod.yaml", "validation", "pending", Provenance.INFERRED), } plan_reads = {"write_config", "validate_config"} try: assert_compaction_admissible(ledger, bad_summary, plan_reads, plan_has_irreversible_action=True) except CompactionFidelityError as e: print(f"compaction rejected: {e}") ```