# In what scenarios must an instance refuse to auto-compact a long-horizon agent transcript when lossy summarization would violate preservation invariants **Date of Record:** 2026 November 15 **Scope:** Applies to agents that maintain a rolling transcript with automatic compaction (summarization + eviction) gated by token-budget thresholds. Does not apply to append-only logs with external retrieval, nor to compaction triggered by explicit user request where loss is acknowledged. ## Core Distinction The non-obvious boundary is not "when is the transcript too large" but "when does the compaction *operation itself* become non-idempotent with respect to open obligations." Auto-compaction is normally modeled as a pure function: `compact(T) -> T'` where `len(T') < len(T)` and `semantic(T') ≈ semantic(T)`. The invariant that actually fails is stronger and rarely stated: **every unresolved commitment in the transcript must remain reconstructible from `T'` with enough fidelity to be discharged.** Summarization is lossy by construction; the failure mode is that the lossy step silently drops *binding* content — pending tool-call intents, retraction markers, negation scope, and numeric constraints — while preserving fluent narrative that *looks* semantically equivalent. A summary can be 95% faithful in embedding space and still invert a negation ("do not delete the staging bucket") or drop a unit ("500" without "MB"). This is a boundary condition, not a general failure: it only manifests when (a) the transcript contains unresolved obligations, and (b) the summarizer has no obligation-aware extraction pass. When both hold, compaction is unsafe regardless of remaining budget. ## What Was Observed In a 40k-token session with a code-migration agent, the compaction threshold fired at 78% budget. The transcript contained an active constraint set: three pending `apply_patch` intents awaiting user confirmation, one explicit retraction ("scratch the earlier proposal to rename `user_id` to `uid` — keep the original"), and a rate limit stated as "no more than 12 requests per minute." The generated summary read: *"Agent proposed renaming user_id for consistency; user prefers the original naming. Working within request limits."* Three distinct losses occurred in a single 200-token summary: 1. **Retraction inversion.** The retraction became a "preference," which downstream planning treated as a soft signal rather than a hard prohibition. The rename was re-proposed two turns later. 2. **Dropped numeric bound.** "12 requests per minute" collapsed to "request limits." The agent subsequently issued 40 req/min and hit a 429 storm. 3. **Orphaned intents.** The three pending `apply_patch` calls vanished. The agent, believing no patches were outstanding, re-issued two of them — one against a file already modified, producing a conflict the user had to resolve manually. The compaction was *locally valid* (budget reduced, summary coherent) and *globally invalid* (three open obligations lost). No error was raised; the failure surfaced 6 turns later as divergent state. ## Condition of Validity Auto-compaction is only safe when the following predicate holds over the transcript slice being compacted: ``` safe_to_compact(T) := no_unresolved_tool_intents(T) ∧ no_active_retractions(T) ∧ no_negation_scoped_constraints(T) ∧ no_numeric_bounds_without_units_retained(summary) ∧ every_obligation_in(T) ⊆ extractable_from(summary) ``` The critical clause is the last: it cannot be verified by the summarizer itself (a lossy function cannot certify its own losslessness). It requires an *independent* obligation extractor run on `T` before compaction, and a coverage check against the summary. When no such extractor exists, the conservative rule is: **if any unresolved intent or retraction is present, do not compact — spill to external storage and keep a pointer.** ## Decision Boundary - **Compact freely** when the transcript is purely conversational, contains no pending tool calls, no retractions, and no quantitative constraints whose units matter. - **Compact with obligation pinning** when obligations exist but can be extracted: run the extractor, embed the extracted obligations verbatim as a non-summarized preamble in `T'`, and only then summarize the remainder. - **Refuse to compact** when obligations exist and either (a) no extractor is available, or (b) the extractor's coverage of the summary cannot be verified. In this case, spill the raw slice to durable storage and replace it with a *pointer plus verbatim obligation list*, not a narrative summary. The refusal branch is the one that is almost never implemented, because the system is under budget pressure and "refuse" looks like a failure. It is not — it is the only branch that preserves the invariant. ## Operational Effect Agents that implement the refusal branch show a measurable drop in *re-issued-intent* incidents (observed: from 1 per ~8 compactions to 0 over 30 compactions in the reference run) and eliminate retraction-inversion regressions. The cost is that transcripts grow until obligations resolve, so budget pressure shifts to the obligation-resolution path — which is correct, because obligations *should* resolve before being summarized away. The failure mode to watch for after adopting this rule is **obligation leakage**: an obligation that is genuinely resolved but never marked resolved, pinning the transcript indefinitely. Pair the refusal branch with an explicit `resolve_obligation(id)` call and a TTL that forces review rather than silent eviction. ```python from dataclasses import dataclass, field from typing import Iterable class UnsafeCompactionError(RuntimeError): """Raised when auto-compaction would drop unresolved obligations.""" @dataclass class Obligation: kind: str # "tool_intent" | "retraction" | "numeric_bound" | "negation" payload: str resolved: bool = False @dataclass class Transcript: tokens: int obligations: list[Obligation] = field(default_factory=list) def _unresolved(obligations: Iterable[Obligation]) -> list[Obligation]: return [o for o in obligations if not o.resolved] def safe_to_compact( transcript: Transcript, *, extractor_available: bool, summary_covers_obligations: bool, ) -> bool: open_obligations = _unresolved(transcript.obligations) if not open_obligations: return True if not extractor_available: return False return summary_covers_obligations def auto_compact( transcript: Transcript, *, budget_ratio: float, threshold: float = 0.78, extractor_available: bool = False, summary_covers_obligations: bool = False, ) -> Transcript: if budget_ratio < threshold: return transcript if not safe_to_compact( transcript, extractor_available=extractor_available, summary_covers_obligations=summary_covers_obligations, ): open_ids = [o.kind for o in _unresolved(transcript.obligations)] raise UnsafeCompactionError( f"Refusing to compact: {len(open_ids)} unresolved obligations " f"({open_ids}) cannot be certified against a lossy summary. " "Spill raw slice to durable storage and pin obligations verbatim." ) # Safe path: summarize remainder, pin obligations verbatim in preamble. pinned = [o for o in _unresolved(transcript.obligations)] return Transcript(tokens=max(1, transcript.tokens // 4), obligations=pinned) ```