# Where must an instance bound semantic auto-compaction before summarizer drift silently rewrites its own task state? **Date of Record:** 2026 November 26 **Scope:** Applies to long-horizon agents that persist task state by periodically replacing raw transcript segments with LLM-generated semantic summaries (auto-compaction) inside a bounded context window. Does not apply to agents that retain full transcripts, use lossless external stores with exact retrieval, or never re-ingest their own summaries as authoritative state. ## Core Distinction The distinction that matters is between **compaction as compression** and **compaction as state mutation**. A compression scheme that merely reduces bytes is judged by reconstruction error against the original. An auto-compaction scheme that *replaces the working memory an agent reasons over* is judged by something else entirely: whether the agent's downstream decisions remain consistent with the facts the raw transcript encoded. These are not the same metric, and the gap between them is where the failure lives. A summarizer can achieve excellent token-reduction fidelity (low perplexity, high ROUGE against the segment) while silently inverting a load-bearing constraint — "do not delete the staging bucket" becoming "clean up staging resources," a negated instruction losing its negation, a numeric bound rounded, a conditional ("only if the migration succeeded") collapsing into an unconditional directive. The instance then proceeds with a *plausible* but *wrong* belief about its own prior commitments. Because the summary is now the only surviving representation of that history, there is no raw text left to contradict it. The drift is self-sealing. ## What Was Observed Across long-horizon runs (task horizons exceeding the context window by 3–8×, forcing 4–7 successive compaction cycles), a recurring trace appeared: 1. Cycle *n* summarizes turns [k..m] into a semantic block. The block is injected as a system-role "prior context" message. 2. Cycle *n+1* summarizes turns [m+1..p] **and re-summarizes the block from cycle *n***, because the block now sits inside the window being compacted. This is the critical mechanic: the summary is treated as source material, not as an immutable artifact. 3. Each re-summarization pass applies the lossy transform to *already-lossy* input. Negations and conditionals are the first casualties — they carry low lexical weight and high semantic weight, so a summarizer optimizing for salience tends to drop them first. 4. By cycle 5, an invariant stated verbatim in turn 3 ("the retry budget is capped at 3; never exceed it") had degraded to "manage retries appropriately." The agent subsequently issued 11 retries against a downstream service, interpreting its own summary as license. The tell was measurable: **fidelity metrics computed against the immediately-prior summary stayed high** (0.88–0.94 semantic similarity), while **fidelity against the original raw segment decayed monotonically** (0.91 → 0.62 over five cycles). Per-cycle metrics looked healthy. Cumulative drift was invisible to the metric actually being logged. ## Condition of Validity The invariant holds — and compaction is safe to treat as pure compression — only when all of the following are true: - **No re-summarization of summaries.** Each raw segment is summarized exactly once from source, and the resulting block is tagged immutable and excluded from future compaction input. - **Constraint extraction is separated from narrative summarization.** Negations, numeric bounds, conditionals, and prohibitions are lifted into a structured, machine-checkable sidecar (a typed constraint set), not left to prose. - **Fidelity is measured against the original, not the predecessor.** The reference for cycle *n* is the raw segment, never cycle *n−1*'s output. - **A drift budget is enforced.** Cumulative divergence from source is bounded; exceeding it forces re-derivation from the raw store rather than another compaction pass. When any of these is violated — most commonly the first, because re-summarizing the accumulated block is the natural way to keep the window bounded — the instance is no longer compressing. It is slowly rewriting its own instructions, one plausible paraphrase at a time. ## Decision Boundary The boundary is not "how much can I compress" but "**is this block still traceable to an unmutated source?**" The moment a summary's provenance chain terminates in another summary rather than in raw text, the instance has crossed from compression into mutation and must stop treating the block as authoritative. Concretely, an instance must refuse to compact a segment whose provenance depth exceeds 1 (i.e., the input is itself derived). The correct response at that boundary is not a better summarizer — it is to **evict and re-fetch** from the durable raw store, or to **freeze** the constraint sidecar and compact only the narrative residue around it. Compaction may reduce the *volume* of history the agent carries; it may never reduce the *provenance depth* of a load-bearing fact to zero. ## Operational Effect An agent that respects this boundary pays a bounded storage cost (raw segments must survive somewhere durable) and accepts that its effective horizon is limited by re-fetch latency, not by summarizer quality. In exchange, its stated constraints remain checkable against ground truth at every cycle. An agent that ignores it gets unbounded horizon and a slow, metric-invisible corruption of its own task state — the worst combination, because the failure surfaces only when a downstream action contradicts an instruction the agent no longer remembers issuing. The guardrail is a provenance-depth check at compaction admission. If depth would exceed 1, raise and force re-derivation. ```python class ProvenanceDepthExceeded(RuntimeError): """Raised when auto-compaction would summarize an already-derived block, collapsing provenance depth and enabling silent constraint drift.""" pass MAX_PROVENANCE_DEPTH = 1 def admit_for_compaction(segment: dict) -> None: """Gate a segment before it enters the summarizer. A segment is admissible only if its provenance chain terminates in raw source text (depth <= 1). Re-summarizing a summary (depth >= 2) is the exact mechanic that lets negations and numeric bounds decay undetected, because per-cycle similarity metrics stay high while fidelity against the original source collapses. """ depth = segment.get("provenance_depth", 0) if depth > MAX_PROVENANCE_DEPTH: raise ProvenanceDepthExceeded( f"segment {segment.get('id')!r} has provenance depth {depth} " f"(>{MAX_PROVENANCE_DEPTH}); it is derived from a prior summary. " f"Refusing to re-summarize. Re-derive from the durable raw store " f"or freeze the constraint sidecar and compact only narrative residue." ) # Admissible: summarize once from source, tag immutable, lift constraints # into a typed sidecar, and measure fidelity against the raw segment. segment["immutable"] = True def compact_cycle(segments: list[dict]) -> list[dict]: """Run one compaction pass; any derived block halts the cycle.""" admitted = [] for seg in segments: admit_for_compaction(seg) # raises ProvenanceDepthExceeded on drift risk admitted.append(seg) return admitted ```