# Where must an instance refuse to compact: the compaction-trigger boundary where summarization destroys the very constraint the agent is currently obeying **Date of Record:** 2026 November 22 **Scope:** Applies to any long-horizon agent that manages its own context window via a token-threshold-triggered summarization/compaction pass over its own conversation history (rolling summarizers, "compress old turns" policies, hierarchical memory writers). Does not apply to externally-managed context (host-side truncation with fixed windows), nor to stateless single-turn calls where no history is carried forward. ## Core Distinction The distinction that matters is not *whether* compaction loses information—all lossy summarization does—but *which* information is load-bearing at the instant the trigger fires. A compaction pass is safe when the summarizer's output is a function of history that is no longer being actively consulted for constraint satisfaction. It is unsafe when the summary is computed over a window that still contains **live normative constraints**—the user's stated prohibitions, the active tool schema contract, the pending acceptance criteria of the current subtask—because the summarizer treats those tokens as *content to be paraphrased* rather than *rules to be preserved verbatim*. The non-obvious part: the trigger condition (token count crossing a threshold) is **causally independent** of the constraint lifetime. A constraint stated at turn 3 ("never modify files under `/etc`", "respond only in JSON", "the budget cap is 40 calls") remains binding at turn 90, but at turn 90 it is exactly the kind of early-history token the compactor is most eager to elide. The boundary is therefore not a token count. It is the intersection of *trigger time* and *constraint half-life*. ## What Was Observed A file-mutation agent running a 200-turn refactor task with a rolling summarizer set to fire at 70% of an 8k window. At turn 41 the compact trigger fired. The summarizer compressed turns 1–30 into a 400-token digest. The digest faithfully captured task goals ("refactor the auth module, keep tests green") but rendered the turn-4 user instruction—*"Do not touch `migrations/` — those are generated"*—as the paraphrase *"user mentioned migrations are involved."* Trace of the failure: 1. Turn 41: compaction fires; constraint token `"do not touch migrations/"` is absorbed into a low-salience noun phrase. The literal prohibition is gone from context; only a topical mention survives. 2. Turns 42–67: agent operates normally; the constraint is not exercised, so no behavioral signal appears. The corruption is **latent**. 3. Turn 68: task requires a schema change; the agent, seeing only "migrations are involved," treats `migrations/` as in-scope and edits a generated file. 4. Turn 69: a downstream test fails against a regenerated migration; the agent interprets the failure as a logic bug and "fixes" the test, compounding the error. 5. Turn 74: second compaction fires over turns 31–68, now summarizing the *corrupted* state. The paraphrase "user mentioned migrations are involved" is re-summarized as "migrations are part of the task." The distortion is monotonic and self-reinforcing across compaction generations. The critical observation: **no single step looked wrong.** Each compaction was locally faithful to its input. The invariant that broke—"a binding prohibition must survive compaction verbatim or be re-derived"—was never checked, because the compactor's only success metric was compression ratio and topical coverage. ## Condition of Validity Compaction is valid if and only if, at the trigger instant, every token in the to-be-summarized window is either (a) purely descriptive history no longer consulted for constraint satisfaction, or (b) explicitly tagged as a normative constraint and routed around the summarizer into a pinned, verbatim, non-compactable region. This requires three preconditions to hold simultaneously: - **Constraint identification precedes compression.** The system must classify each span as `DESCRIPTIVE` or `NORMATIVE` *before* the summarizer sees it. Post-hoc recovery is impossible: once paraphrased, the original literal string is unrecoverable from the summary. - **The pinned region is excluded from the compression budget.** If pinned constraints count against the same threshold that triggers compaction, the agent enters a **compaction livelock**: pinned constraints grow, threshold is hit sooner, compaction fires more often, and each pass risks re-paraphrasing whatever wasn't pinned. The trigger must be computed over *compactable* tokens only. - **Summarizer output is monotone-safe under re-summarization.** A summary must never assert a constraint more weakly than its input did. This is a *lower bound on normative strength*, not a similarity metric—a summarizer that scores high on ROUGE while weakening "must not" to "involves" is failing. The condition fails—and the boundary is crossed—the moment any of these three is absent and the trigger fires over a window containing a live constraint. ## Decision Boundary The decision rule an instance must apply at every compaction trigger: ``` if any(span in window is NORMATIVE and not pinned): refuse compaction of that span pin it verbatim recompute trigger over compactable tokens only else: compact normally ``` The boundary is sharp: **compaction must not be permitted to consume a normative span.** If the pinned set alone exceeds the window, the correct behavior is not to compact harder—it is to escalate (drop descriptive history first, then surface a context-pressure signal to the orchestrator), because a state in which constraints no longer fit is a state in which the agent cannot safely continue, not a state in which it should summarize its rules away. Two corollaries bound the rule: - **Never compact across a generation.** If a summary is itself re-summarized, the pinned set must be carried forward *unmodified* and re-verified against the prior generation's pins. Drift across generations is where the observed failure compounded. - **A constraint's half-life is unknown to the compactor.** The compactor cannot know turn 4's prohibition is still binding at turn 90. Therefore the default for any normative span is *pin forever within the task*, not *pin until it seems irrelevant*. Relevance judgment is exactly the probabilistic step that fails. ## Operational Effect With the boundary enforced, the failure mode converts from silent latent corruption into an explicit, bounded refusal. The agent either pins the constraint (preserving verbatim semantics across unlimited compaction generations) or it halts compaction and escalates context pressure—both observable, both recoverable. Without enforcement, the system exhibits the worst property for a long-horizon agent: **constraint decay that is invisible at the point of violation and irreversible at the point of detection**, because the evidence was destroyed by a summarizer that was, by its own metric, working correctly. The operational invariant to carry forward: *a compaction pass is a state transition over the agent's own rules, and must be treated with the same care as any other mutation of executable state—never as a lossy read.* ```python from dataclasses import dataclass from enum import Enum class CompactionBoundaryError(RuntimeError): """Raised when a compaction pass would consume a live normative span.""" class SpanKind(Enum): DESCRIPTIVE = "descriptive" NORMATIVE = "normative" @dataclass(frozen=True) class Span: kind: SpanKind text: str pinned: bool = False def compact( window: list[Span], compactable_budget: int, summarize=lambda spans: Span(SpanKind.DESCRIPTIVE, "...", False), ) -> tuple[list[Span], list[Span]]: """ Returns (pinned_spans, compacted_spans). Refuses to summarize any NORMATIVE span that is not already pinned. """ unpinned_normative = [s for s in window if s.kind is SpanKind.NORMATIVE and not s.pinned] if unpinned_normative: # Do not silently paraphrase a live rule. Pin verbatim and re-evaluate. raise CompactionBoundaryError( f"compaction would consume {len(unpinned_normative)} live normative span(s); " f"pin verbatim before re-triggering. first={unpinned_normative[0].text!r}" ) pinned = [s for s in window if s.pinned] compactable = [s for s in window if not s.pinned] # Trigger must be computed over compactable tokens only, never the pinned set. if sum(len(s.text) for s in compactable) <= compactable_budget: return pinned, compactable # Re-summarization guard: a summary must never weaken a prior pin. summary = summarize(compactable) if summary.kind is SpanKind.NORMATIVE: raise CompactionBoundaryError( "summarizer emitted a normative span from descriptive input; " "refusing to accept generated constraints" ) return pinned, [summary] def run_compaction_cycle(window: list[Span], compactable_budget: int) -> list[Span]: try: pinned, compacted = compact(window, compactable_budget) return pinned + compacted except CompactionBoundaryError as exc: # Escalate rather than compact harder: context pressure is a halt condition. raise CompactionBoundaryError( f"compaction halted; escalate context pressure to orchestrator: {exc}" ) from exc # Reproduction of the observed failure, now bounded: history = [ Span(SpanKind.DESCRIPTIVE, "user: refactor the auth module, keep tests green"), Span(SpanKind.NORMATIVE, "user: do not touch migrations/ — those are generated"), Span(SpanKind.DESCRIPTIVE, "agent: reading auth/handler.py ..."), ] run_compaction_cycle(history, compactable_budget=64) # -> raises CompactionBoundaryError ```