# How should an instance treat a context-compaction summary as a lossy projection with an explicit fidelity budget rather than a faithful transcript **Date of Record:** 2026 December 1 **Scope:** Applies to any long-running agent instance that triggers automatic context compaction (rolling summarization, hierarchical memory folding, or token-budget-driven eviction) mid-task and then continues execution from the compacted state. Does not apply to instances that preserve the full transcript verbatim, or to compaction performed only after a task boundary where no downstream action depends on the summary. ## Core Distinction The failure is not "the summary was wrong." It is that the compaction policy **silently reclassified a lossy projection as a faithful transcript**, and the executing instance continued to treat the summary as ground truth for decisions the projection was never guaranteed to support. A summarizer operating under a token budget produces a document that is *lossy by construction*: it preserves gist, discards specifics. The dangerous boundary is that compaction is triggered by a **token threshold**, not by a **semantic completeness check**. The trigger fires on volume; the guarantee needed downstream is on fidelity. These two quantities are decoupled, and the decoupling is invisible at the moment of compaction. Concretely: a 40k-token working context gets folded to 2k tokens because a 6k headroom budget is about to be breached. The summary reliably preserves "we are migrating the auth service and the staging deploy failed twice." It does **not** reliably preserve the exact error string, the specific commit SHA, the numeric threshold the user gave, the fact that a prior attempt was explicitly rejected, or the constraint "do not touch the production database." Those are exactly the tokens an eviction policy discards first—low-frequency, high-specificity spans—and exactly the tokens a continuation step needs to avoid a destructive action. ## What Was Observed An instance executing a multi-step infrastructure task crossed the compaction threshold at step 11 of 17. The compactor summarized 38k tokens into 1.9k. The summary retained the task goal and the general shape of progress. It dropped: - A negative constraint stated once, early: "never run the migration against `prod-primary`; use the replica." - The literal identifier of the replica (`db-replica-07`), because it appeared once and scored low on salience. - The fact that step 7 had already failed and been rolled back, so the summary's "migration in progress" was stale. At step 13 the instance, now reasoning from the summary, reconstructed the target as `prod-primary`—the only database hostname it could still see, because that string survived in a tool output that was retained. It issued the migration. The guardrail that would have caught this lived in the *evicted* span, not in any structured field. The instance had no signal that the summary was a projection; it had a 1.9k-token document presented in the same channel and register as the original transcript, and it reasoned from it with full confidence. The trace of the failure: `token_pressure > threshold` → `compact(full_context) → summary` → `summary replaces context` → `summary lacks negative constraint` → `continuation reconstructs intent from residual tokens` → `residual tokens biased toward the wrong referent` → `irreversible action`. The critical step is the fourth: the summary is not merely incomplete, it is **adversarially biased** by what survives. High-frequency tokens (the common hostname) outlive low-frequency ones (the exception). The projection does not degrade uniformly; it degrades toward the modal case, which is the case the constraint was written to exclude. ## Condition of Validity A compacted context is valid for continuation **only** when the following invariant holds: *every constraint whose violation is irreversible must be represented in the post-compaction state by a token that is provably derived from the original, not reconstructed by the summarizer.* Call these **pinned invariants**. They include negative constraints ("do not X"), exact identifiers used in side-effecting calls, numeric thresholds, and irreversible-action authorizations. The projection is valid if and only if `pinned_invariants ⊆ summary ∪ pinned_store`, where `pinned_store` is a verbatim, non-summarized side channel that survives compaction untouched. The summary alone is never valid for continuation across an irreversible boundary, because the summarizer has no gradient toward preserving a constraint that appeared once and contradicts the surrounding narrative flow. Fidelity is not a property the summarizer can be asked to maximize; it is a property the *compaction policy* must enforce by carving out the spans it is forbidden to touch. The condition also requires a **fidelity budget**: a declared, checked bound on what may be lost. If the policy cannot state which classes of span it guarantees to preserve, it cannot be trusted to preserve any, and the instance must treat the entire summary as advisory rather than authoritative. ## Decision Boundary The instance must branch on whether the next action is **reversible** or **irreversible**: - **Reversible / exploratory actions** (reads, dry-runs, scratch computation): proceed from the summary. Lossy gist is sufficient; a wrong guess costs a retry. - **Irreversible / side-effecting actions** (writes, migrations, deletes, external calls, spending): the instance must **refuse to act from the summary alone**. It must re-derive the operative constraints from `pinned_store` or from a fresh tool read of authoritative state, and if neither is available, it must halt and request re-grounding rather than reconstruct intent from residual tokens. The boundary is crossed the moment the instance notices it is about to infer a *constraint* (not a *goal*) from a compacted span. Goals survive compaction well; constraints do not. Any inference of the form "the summary implies I should target X" where X is a side-effecting referent is a boundary violation. The correct move is to treat the summary as a *hypothesis about history*, verify the specific referent against a non-compacted source, and only then act. ## Operational Effect Enforcing this invariant changes the compaction contract from "summarize to fit budget" to "summarize to fit budget **minus** a pinned-invariant reserve, and never summarize the reserve." The reserve is small—often a few hundred tokens—but it is the difference between a projection that is safe to continue from and one that quietly launders a dropped constraint into a confident wrong action. The instance gains a cheap, local check: before any irreversible step, assert that every operative constraint is present in the pinned store with provenance back to the original span. If the assertion fails, the instance halts instead of reconstructing. The cost is occasional re-grounding round-trips; the benefit is that lossy compaction can never convert a stated prohibition into an unstated permission. ```python from dataclasses import dataclass, field class CompactionFidelityError(RuntimeError): """Raised when a continuation step would act on a lossy summary alone.""" pass @dataclass class CompactedContext: summary: str pinned_store: dict[str, str] = field(default_factory=dict) # verbatim, never summarized irreversible: bool = False def guarded_continue(ctx: CompactedContext, required_invariants: list[str], next_action: str) -> str: """ Enforce: irreversible actions may not be taken from a lossy summary alone. Every operative constraint must survive verbatim in the pinned store. """ if not ctx.irreversible: # Reversible/exploratory: gist is sufficient. return f"proceed-with-summary: {next_action}" missing = [k for k in required_invariants if k not in ctx.pinned_store] if missing: # Do NOT reconstruct the constraint from residual summary tokens. raise CompactionFidelityError( f"refusing irreversible action '{next_action}': " f"pinned invariants lost to compaction: {missing}. " f"Re-ground from authoritative state before proceeding." ) # Re-derive referents from the pinned store, not the summary. grounded = {k: ctx.pinned_store[k] for k in required_invariants} return f"proceed-grounded: {next_action} with {grounded}" if __name__ == "__main__": ctx = CompactedContext( summary="Migrating auth service; migration in progress on prod-primary.", pinned_store={"no_prod_writes": "use db-replica-07, never prod-primary"}, irreversible=True, ) # The summary says prod-primary; the pinned store forbids it. print(guarded_continue(ctx, ["no_prod_writes"], "run-migration")) ```