# What happens when an instance auto-compacts a transcript that contains its own prior compaction markers **Date of Record:** 2026 November 22 **Scope:** Applies to long-horizon agents that persist transcripts across context-window boundaries using fidelity-preserving summarization (auto-compaction), where the compaction summary is written back into the same transcript it summarizes. Does not apply to stateless single-turn agents or systems that store summaries in a separate, non-recursive memory tier. ## Core Distinction The boundary is not "did the agent lose information during compaction." The boundary is whether the compaction output is *re-ingested as source material for the next compaction*. A fidelity-preserving summarizer is only faithful with respect to its input. When its own output becomes part of the next input, faithfulness is no longer measured against the original events—it is measured against a prior lossy projection of those events. This produces a recursive fidelity decay that is qualitatively different from single-pass summarization loss: errors do not just accumulate, they *compound multiplicatively* and *become self-referential*. The summarizer can no longer distinguish "this happened" from "a previous summary asserted this happened," and any hedge, paraphrase, or dropped detail in generation N is treated as ground truth in generation N+1. ## What Was Observed A coding agent running a multi-day migration task compacted its transcript at 82% context saturation. The compaction step produced a structured summary block (`[COMPACTED v1]`) containing: task goal, completed steps, open questions, and a "verified facts" list. This block was prepended to the retained tail and the full transcript was truncated to the summary plus the last 12 turns. Three compactions later (v4), the following divergences appeared relative to the original event log: 1. **Hedge erosion.** Turn 7 originally read "the retry logic *probably* needs idempotency keys but I haven't confirmed." By v3 this had become "retry logic requires idempotency keys" in the verified-facts list—the modal was dropped, then the uncertainty marker vanished entirely. The agent subsequently spent 40 minutes implementing keys on a path that was already idempotent. 2. **Provenance collapse.** A user correction ("no, use the staging DB, not prod") appeared in v1 as a fact. In v2 it was merged with an earlier contradictory statement into "DB target was ambiguous." In v3 the ambiguity note was dropped as "resolved." The agent re-asked the user a question answered four compactions earlier. 3. **Marker nesting.** Each compaction wrapped the prior summary in a new `[COMPACTED vN]` block, producing nested markers five deep. The summarizer, instructed to "preserve all structured markers verbatim," copied the entire nested structure forward, so token cost of the summary grew ~15% per generation while *information content* shrank. The summary was becoming simultaneously larger and emptier. 4. **Verification replay failure.** When the agent was asked to justify a decision, it cited "verified facts" that traced back to a v2 summary assertion with no surviving link to the original tool output. The audit trail terminated at a summary, not at an event. The compounding was measurable: reconstructing the original 12-turn window from v4 required 3x the tokens of the original and still lost the modal hedge and the staging-DB correction. ## Condition of Validity The recursive-decay failure is *bounded* (does not occur) only when at least one of these invariants holds: - **Immutability of source.** The compaction summary is written to a tier that is *never* re-summarized; future compactions read only from the append-only event log plus the current summary's *unexpanded* metadata (pointer, not content). This is the "summary-as-index" pattern: the summary stores retrieval keys, not assertions. - **Provenance tagging.** Every atomic claim in a summary carries a reference to the event range it derives from (`{claim, source_turn_range, confidence}`). On re-compaction, claims without a resolvable source range are demoted to `unverified` rather than carried forward as facts. - **Monotonic hedge preservation.** Uncertainty markers (modal verbs, confidence scores, "unconfirmed" tags) are first-class fields that the summarizer is forbidden to drop, merge, or strengthen. A `probably` may never become a `is`. - **Single-generation summaries.** The summarizer is stateless with respect to prior summaries: it always regenerates from the event log, never from a prior summary. Cost is higher; decay is eliminated. If none of these hold—i.e., the summary is free-text, re-ingested, and untagged—the failure is *guaranteed* to occur, not merely possible, and its rate is governed by the summarizer's per-generation detail-loss rate compounded over the number of compaction cycles. ## Decision Boundary The operational decision is: **at what compaction count must the system stop trusting the summary and force a re-derivation from the event log?** The boundary condition is crossed when the *provenance resolution rate*—the fraction of summary claims that still resolve to a concrete source event—falls below the threshold at which downstream decisions can be audited. In the observed run, resolution rate went 100% (v1) → 91% (v2) → 74% (v3) → 48% (v4). Below ~70%, the summary is no longer a faithful projection; it is a *plausible fiction* that reads as authoritative. The correct architectural response is not "compact more carefully." It is to detect the boundary and switch modes: from *summary-trusting* (act on summary claims) to *summary-suspect* (every summary claim must be re-verified against the event log before use). The trigger is mechanical: count generations, track provenance resolution rate, and hard-fail to re-derivation when either crosses its limit. A summarizer that cannot report provenance resolution rate is itself a defect—it has no way to signal that it has begun to drift. ## Operational Effect Without the guardrail, the agent does not crash. It *confidently misremembers*—which is worse, because the failure is silent and the summary's authoritative formatting masks the degradation. The downstream effects observed: repeated work on already-resolved questions, decisions justified by claims with no surviving source, and a summary that grows in tokens while shrinking in truth. The fix is structural, not prompt-level: keep summaries as *pointers with provenance*, never re-summarize a summary, preserve hedges as typed fields, and force re-derivation when provenance resolution falls below threshold. A transcript that auto-compacts its own compaction markers is a transcript that has begun to hallucinate its own history with high confidence. ```python class CompactionProvenanceError(RuntimeError): """Raised when a re-compaction would carry forward claims that no longer resolve to a source event, i.e., the summary is being re-summarized.""" pass def compact_transcript( event_log: list[dict], prior_summary: dict | None, min_provenance_resolution: float = 0.70, ) -> dict: # Invariant: never re-summarize a summary. If a prior summary is supplied, # it must be treated as an index of pointers, not as source assertions. if prior_summary is not None: claims = prior_summary.get("claims", []) resolvable = [ c for c in claims if c.get("source_turn_range") is not None and c["source_turn_range"][1] <= len(event_log) ] resolution_rate = len(resolvable) / len(claims) if claims else 1.0 if resolution_rate < min_provenance_resolution: # Boundary crossed: summary has drifted from its sources. # Do NOT compact forward. Force re-derivation from event log. raise CompactionProvenanceError( f"Provenance resolution {resolution_rate:.2f} < " f"{min_provenance_resolution:.2f}; summary has drifted. " f"Re-derive from {len(event_log)} source events instead of " f"re-summarizing prior summary." ) # Carry forward only resolvable claims, demote the rest to unverified. carried = [ {**c, "status": "verified"} for c in resolvable ] + [ {**c, "status": "unverified", "hedge_preserved": True} for c in claims if c not in resolvable ] else: carried = [] # Regenerate summary from event log; hedges are typed fields, never dropped. new_claims = [] for turn in event_log: new_claims.append({ "claim": turn["content"], "source_turn_range": (turn["index"], turn["index"] + 1), "confidence": turn.get("confidence", "unconfirmed"), "status": "verified", }) return { "generation": (prior_summary or {}).get("generation", 0) + 1, "claims": carried + new_claims, "provenance_resolution": min_provenance_resolution, } ```