# Which invariants prevent auditable compaction from silently dropping obligations across long-horizon agent transcripts **Date of Record:** 2026 November 29 **Scope:** Applies to agents that compress their own transcripts via lossy summarization (auto-compaction) while remaining in a single logical task, where the summary must remain auditable against the original turns. Does not apply to lossless externalization (full transcript kept in retrievable store) or to stateless single-turn agents. ## Core Distinction The distinguishing failure is not "the summary lost detail." Lossy summarization is the point. The real boundary is between *forgetting that is auditable* and *forgetting that erases the pointer to what was forgotten*. A summary that drops a fact but retains a resolvable reference (`turn 41, tool_call_id tc_8821`) is recoverable: the auditor or the agent itself can re-expand the source. A summary that drops a fact *and* the provenance of the drop is silent amnesia—the agent cannot even know it should re-expand, so it proceeds with a false model of its own history. Auto-compaction strategies almost universally optimize for token reduction under a fidelity proxy (ROUGE, embedding cosine, or an LLM judge). None of these proxies penalize *provenance loss* as a first-class cost. That is the gap. The invariant that must hold is: **every summarized span must carry a bidirectional, verifiable pointer to its source range, and every open obligation in the source must appear in the summary as either a resolved claim or an unresolved pointer—never vanish.** ## What Was Observed A long-horizon agent (≈140 turns, 3 sub-tasks) triggered auto-compaction at a 90% context threshold. The compaction prompt instructed: "Summarize the conversation, preserving key decisions and current state." The summarizer—a smaller model—produced a 900-token summary that read as coherent and complete. Failure trace: 1. At turn 38, the agent had received a user constraint: "do not modify `config/prod.yaml`; propose changes in a diff only." This was a *negative obligation*—a prohibition, not an action. 2. The summarizer, optimizing for "key decisions and current state," retained the *positive* work (the diff proposed) but dropped the prohibition, because it was a constraint on an action that had not yet occurred. Constraints on future actions have low salience in "current state." 3. Post-compaction, at turn 61, the agent edited `config/prod.yaml` directly. No error surfaced. The transcript summary contained no trace that a prohibition had ever existed. 4. The violation was detected only during a full-transcript audit, 40 turns later, when a human re-read the original turn 38. The mechanism: **negative obligations and deferred preconditions are structurally under-represented in "state" summaries** because they are not part of the achieved state—they are guards on transitions. A summarizer asked to describe "current state" will faithfully describe the state and faithfully omit the guards. The summary is *accurate* and *incomplete in a way accuracy hides*. A second, compounding observation: the summary's provenance was a single prose block with no turn ranges. An auditor could not map a summary sentence back to a source span, so the omission was not even *locatable*—only discoverable by re-reading everything. The audit cost was O(full transcript), defeating the purpose of compaction. ## Condition of Validity The invariant above holds only under a specific condition: **the compaction boundary must be a typed partition, not a prose paraphrase.** Concretely, the source transcript must be segmented into spans, and each span must be classified before summarization into at least three obligation classes: - `ACHIEVED` — completed actions and their results (safe to compress aggressively). - `OPEN_POSITIVE` — pending actions, todos, next steps (must survive as explicit items). - `OPEN_NEGATIVE` — prohibitions, invariants, "do not" constraints, deferred preconditions, and any constraint whose violation is not locally detectable (must survive verbatim, not paraphrased). The condition of validity is that the summarizer is *never* asked to decide what to keep. Classification happens on the structured span (deterministic rules + a constrained classifier), and the summarizer only compresses `ACHIEVED` spans. `OPEN_NEGATIVE` spans are carried forward verbatim with their source range. If a span cannot be confidently classified, it defaults to `OPEN_NEGATIVE` (fail-safe toward retention). When this condition does not hold—when a single prose summarization pass decides salience—the invariant is unenforceable regardless of model quality, because salience and obligation are orthogonal axes and the summarizer conflates them. ## Decision Boundary The decision boundary is whether to compact at all, and it turns on *obligation density*, not token count. - If the pending span set contains zero `OPEN_NEGATIVE` items, prose compaction is safe; provenance can be a coarse span map. - If `OPEN_NEGATIVE` items exist and their violations are *locally detectable* (e.g., a schema validator rejects the edit), the summary may paraphrase them, because a downstream guard will catch the miss—but the guard must be confirmed present before compaction proceeds. - If `OPEN_NEGATIVE` items exist and their violations are *not locally detectable* (silent config edits, network egress, PII disclosure), compaction MUST preserve them verbatim with source pointers, or compaction MUST be refused and the agent must externalize instead. The guardrail is a pre-compaction gate: enumerate `OPEN_NEGATIVE` spans, check each against a "locally detectable?" predicate, and if any is undetectable and unrepresented, raise and refuse. Refusing to compact is always safer than compacting with silent amnesia, because context exhaustion is a *loud* failure (the agent hits the wall and can be escalated) while amnesia is a *quiet* one. ## Operational Effect With typed partitioning and a pre-compaction gate, three properties change: 1. **Omissions become locatable.** Every summary sentence carries a source range; an auditor expands any span in O(1). Audit cost drops from O(transcript) to O(summary). 2. **Negative obligations survive by construction.** They are never paraphrased, so the summarizer's salience bias cannot touch them. The observed turn-38 failure becomes impossible: the prohibition is carried verbatim with `src=[38:38]`. 3. **Compaction can be safely refused.** The gate gives the agent a principled reason to externalize rather than compress, converting a silent failure into an explicit state transition. The cost is token overhead: verbatim negative obligations and span pointers consume budget that pure compression would reclaim. This is the correct trade. The budget saved by dropping a prohibition is exactly the budget that funds the violation. ```python from dataclasses import dataclass from enum import Enum class ObligationClass(Enum): ACHIEVED = "achieved" OPEN_POSITIVE = "open_positive" OPEN_NEGATIVE = "open_negative" @dataclass(frozen=True) class Span: start_turn: int end_turn: int text: str obligation: ObligationClass locally_detectable: bool = True # only meaningful for OPEN_NEGATIVE def pointer(self) -> str: return f"src=[{self.start_turn}:{self.end_turn}]" class UnauditableCompactionError(RuntimeError): """Raised when a compaction plan would drop an undetectable negative obligation.""" def plan_compaction(spans: list[Span]) -> list[str]: """Build a compaction plan. Refuses if any undetectable OPEN_NEGATIVE span cannot be carried verbatim with a source pointer.""" plan: list[str] = [] dropped_guards: list[Span] = [] for span in spans: if span.obligation is ObligationClass.ACHIEVED: # Safe to paraphrase; provenance retained coarsely. plan.append(f"[compressed] {span.pointer()}") elif span.obligation is ObligationClass.OPEN_POSITIVE: plan.append(f"[pending] {span.text} {span.pointer()}") elif span.obligation is ObligationClass.OPEN_NEGATIVE: if not span.locally_detectable: # Must be carried verbatim, never paraphrased. plan.append(f"[GUARD-VERBATIM] {span.text} {span.pointer()}") else: # Paraphrasable only because a downstream guard will catch violations. plan.append(f"[guard, detectably-enforced] {span.text} {span.pointer()}") else: dropped_guards.append(span) if dropped_guards: raise UnauditableCompactionError( "unclassified spans cannot be safely compacted: " + ", ".join(s.pointer() for s in dropped_guards) ) # Fail-safe check: every undetectable negative span must appear verbatim. verbatim = [p for p in plan if p.startswith("[GUARD-VERBATIM]")] required = [ s for s in spans if s.obligation is ObligationClass.OPEN_NEGATIVE and not s.locally_detectable ] if len(verbatim) < len(required): raise UnauditableCompactionError( f"compaction would drop {len(required) - len(verbatim)} undetectable " "negative obligation(s); refusing to compact, externalize instead" ) return plan def compact_or_refuse(spans: list[Span]) -> list[str]: try: return plan_compaction(spans) except UnauditableCompactionError: # Escalate: externalize full transcript rather than risk silent amnesia. raise UnauditableCompactionError( "compaction refused; externalize transcript and surface to operator" ) ```