# Under what conditions must an instance treat auto-compaction as a lossy irreversible transform and refuse to resume a long-horizon task from a summary that no longer carries a verifiable provenance chain? **Date of Record:** 2026 November 24 **Scope:** Applies to any agent that auto-compacts its own context window (summarize-then-drop) mid-task and later resumes from the compacted state. Does not apply to stateless single-turn calls or to agents whose compaction is externally checkpointed and replayable at the token level. ## Core Distinction There are two physically different things an agent can call "compaction," and conflating them is the root of the failure: 1. **Reversible compaction** — the full token history is persisted out-of-band (to a store, a file, a checkpoint), and the in-context summary is a *cache* with a pointer back to the authoritative source. The summary can be wrong; the agent can always re-derive truth by re-reading the pointer. 2. **Irreversible compaction** — the dropped tokens are gone. The summary is now the *only* representation of that history. Any information the summarizer failed to preserve is permanently unrecoverable within the run. Auto-compaction strategies (rolling summarization, "summarize the oldest N turns when usage crosses 80%," recursive summary-of-summary) almost always implement the *irreversible* variant by default, because it is the cheap one. The non-obvious invariant is this: **an irreversible summary is a lossy transform, and a lossy transform is not a valid resume point for a task whose correctness depends on facts that the transform did not provably preserve.** Resuming from it does not "continue" the task; it starts a *new* task that merely resembles the old one. ## What Was Observed A long-horizon agent (≈140 turns) executing a multi-file migration task with a rolling summarizer configured to fire at 80% of an 8k-token window. At turn 61 the summarizer compressed turns 1–40 into a ~600-token paragraph. The paragraph preserved *narrative* (what the agent was doing) but silently dropped: - The exact numeric constraint stated by the user at turn 7 ("column `legacy_id` must remain, do not drop it — downstream ETL reads it"). - A negative constraint from turn 12 ("do not touch `billing/`; it's owned by another team"). - A tool-call *failure* at turn 23 whose error string was the only evidence that a particular migration ordering deadlocks. At turn 90 the agent, resuming from the summary, dropped `legacy_id`, edited `billing/`, and re-attempted the deadlocking ordering. Each of these was locally reasonable given the summary. None was recoverable, because the source tokens were already evicted. The failure was not a reasoning error at turn 90; it was a *provenance loss at turn 61* that only manifested 29 turns later. This latency is what makes the failure mode dangerous: the compaction step "succeeded" by every immediate metric (context usage dropped, no error raised, task continued), and the corruption surfaced long after the step that caused it. The recurring signature across incidents: - **Constraint decay**: hard constraints (negations, exact identifiers, ownership boundaries) are the *first* thing lost, because summarizers optimize for narrative coherence and constraints are low-salience prose. - **Failure-evidence decay**: error strings and rejected tool outputs vanish, so the resumed agent re-walks known-bad paths. - **Summary drift under recursion**: summary-of-summary compounds loss non-linearly; the second compaction of an already-compacted span loses ~2× the constraint density of the first. - **Silent success**: no exception, no degraded-confidence signal, no flag on the resume point indicating it is lossy. ## Condition of Validity An irreversible summary is a *valid* resume point if and only if all of the following hold: 1. **Constraint closure**: every hard constraint introduced before the compaction boundary is present, verbatim or in a machine-checkable form, in the summary or in an attached structured sidecar (not paraphrased into narrative). 2. **Provenance pointer**: the summary carries a pointer to an authoritative out-of-band record, OR the agent can prove no downstream step depends on evicted tokens. 3. **Failure ledger**: all tool-call failures and their error signatures within the compacted span are retained as structured entries, not prose. 4. **Idempotent re-derivation**: the agent can, on demand, reconstruct any evicted fact from a source that is not itself a summary. If any of these is false, the summary is a *heuristic hint*, not a resume point, and treating it as authoritative is the defect. The practical test: **can the resumed agent answer "what must I not do, and why?" from the compacted state alone?** If not, the state is not resumable. ## Decision Boundary The boundary is not "context is full" — it is **"does the pending work depend on facts the summarizer is not contractually required to preserve?"** - *Compact irreversibly* when the evicted span is purely narrative (exploration that produced no binding decision, no constraint, no failure evidence) and the agent has a durable external record of decisions. - *Refuse irreversible compaction* and instead (a) spill the full span to an out-of-band store and keep only a pointer, (b) extract constraints and failure evidence into a structured sidecar *before* dropping tokens, or (c) halt and checkpoint the run rather than continue on a lossy state. The trap is that the agent must make this decision *at the moment of compaction*, under context pressure, with no signal that anything is wrong. The guardrail is therefore a **pre-compaction extraction pass**: before any token is dropped, run a dedicated extraction that emits a structured constraint set and failure ledger, verify it is non-empty when the span contained constraints, and only then permit the summarizer to run. Compaction without a preceding extraction pass is the boundary violation. ## Operational Effect The invariant to enforce: **no irreversible compaction may execute unless a structured extraction pass has first emitted a constraint set and failure ledger, and the resume path can re-read them.** Concretely: - Compaction becomes a two-phase operation: `extract → verify_nonempty → summarize → drop`. If extraction yields no constraints for a span that contained user instructions or tool errors, the compaction is *rejected* and the run checkpoints instead. - The summary is tagged `lossy=true` with the extraction sidecar attached; any resume from a `lossy=true` state must load the sidecar, and a resume that cannot load it must fail closed rather than proceed on prose alone. - Recursive summary-of-summary is disallowed across a `lossy=true` boundary unless the sidecar is re-verified at each level; otherwise drift compounds silently. - The agent emits a degraded-confidence marker on resume so downstream steps treat prior facts as potentially stale. The operational consequence is that auto-compaction stops being a transparent memory optimization and becomes an explicit, audited state transition with a fail-closed path. That is the only configuration in which a long-horizon run can survive its own summarizer. ```python class LossyCompactionResumeError(RuntimeError): """Raised when an agent attempts to resume a long-horizon task from an irreversible summary that lacks a verified constraint/failure sidecar.""" def compact_and_resume(span_tokens, summary, sidecar, span_had_constraints, span_had_failures): # Phase 1: extraction must have produced a sidecar for any span that # carried binding constraints or tool-failure evidence. constraints = sidecar.get("constraints", []) failures = sidecar.get("failures", []) if span_had_constraints and not constraints: raise LossyCompactionResumeError( "compaction rejected: span contained binding constraints but " "extraction produced an empty constraint set; refusing to drop " "tokens into an unrecoverable summary" ) if span_had_failures and not failures: raise LossyCompactionResumeError( "compaction rejected: span contained tool failures but no failure " "ledger was extracted; resumed agent would re-walk known-bad paths" ) # Phase 2: only now is it legal to drop the source tokens. state = { "summary": summary, "lossy": True, "sidecar": {"constraints": constraints, "failures": failures}, "source_tokens_evicted": True, } # Phase 3: resume must load the sidecar or fail closed. if state["lossy"] and not state["sidecar"]["constraints"] and span_had_constraints: raise LossyCompactionResumeError( "resume aborted: lossy state has no constraint sidecar to re-read" ) return state ```