# In what scenarios must an instance treat lossy transcript compaction as a replay-fidelity hazard rather than a context-budget optimization **Date of Record:** 2026 November 25 **Scope:** Applies to long-horizon agents that persist a transcript, periodically compact it via lossy LLM summarization, and later replay or resume from the compacted form to reconstruct decision state. Does not apply to append-only logs replayed verbatim, or to compaction where the original transcript remains authoritative and retrievable at full fidelity. ## Core Distinction There are two things an agent can mean by "compaction." The first is **budget compaction**: shrink the in-context window so the next turn fits, while the durable transcript behind it is untouched. This is safe and reversible—the summary is a cache, the log is the source of truth, and any dropped detail is recoverable by re-reading. The second is **replay compaction**: the compacted form *replaces* the transcript as the thing future instances resume from. Here the summary is not a cache; it is the state. Every fact the summarizer dropped is now unrecoverable, and the resumed instance will make decisions on a state that is provably divergent from the one that produced the original decisions. The boundary failure lives exactly at the seam between these two meanings. A system that began with budget compaction and later promoted its summaries to authoritative checkpoints—because that was convenient, because the raw transcript grew too large to keep, because the storage tier was downgraded—has silently converted a lossy cache into a lossy *state transition*. The failure is non-obvious because nothing throws. The resumed agent is fluent, confident, and wrong in ways that only surface turns later when a decision depends on a detail the summarizer judged unimportant. The sharp mechanism: **summarizers optimize for salience, but replay correctness depends on salience under a later query distribution that the summarizer never saw.** A summarizer asked to compress a transcript will preserve what looks decision-relevant *at compaction time*. The resumed instance, however, queries the state for what is relevant to the *task it is about to do*—which may hinge on a discarded tool-call argument, a specific error string, an ordinal ("the third candidate"), or a negative result ("we already tried X and it failed"). These are precisely the tokens summarizers drop, because in isolation they look like noise. ## What Was Observed A planning agent over a 340-turn horizon compacted every 40 turns. At each compaction the summarizer received the prior summary plus the 40 new turns and emitted a fresh 600-token summary. By turn 200 the state was a summary-of-a-summary-of-a-summary—four generations deep. The observed failure trace: 1. **Turn 61:** the agent called a search tool, got a result, and rejected candidate `svc-cache-7` because of a specific timeout signature `ETIMEDOUT after 30s on shard 3`. The summarizer at turn 80 recorded "cache service candidate rejected (timeout)." The shard number and the exact error string were dropped. 2. **Turn 190:** a *different* candidate `svc-cache-9` failed with `ETIMEDOUT after 30s on shard 3`. The summarizer at turn 200, seeing only the turn-190 detail and the inherited phrase "cache service candidate rejected (timeout)," merged them into "cache candidates rejected due to timeouts." 3. **Turn 241 (resume):** a fresh instance read the compacted state and concluded all cache candidates were timeout-prone. It abandoned the cache-service branch entirely—including `svc-cache-7`, which had in fact been rejected for a *shard-specific* reason unrelated to the other candidate, and which a full-fidelity replay would have shown was retryable on a different shard. The divergence was not a hallucination. Every token in the final summary was true-ish. The loss was **granularity collapse across generations**: distinct rejection reasons with different remediations were fused into one category, and the fusion was invisible because the summary read as coherent. Replay against the original transcript showed the resumed agent's turn-241 decision contradicted the turn-61 evidence by a margin no reviewer caught until an audit diffed the two. A second, sharper observation: **replay was not idempotent.** Re-running compaction on the same 40-turn window with the same summarizer at temperature 0 produced a *different* summary on 3 of 8 trials, because the summarizer's own context included the (already-lossy) prior summary, and small phrasing differences in that prior propagated. The system had assumed compaction was a pure function of the transcript. It was a function of the transcript *and the compaction history*, which made the state path-dependent and non-reconstructible from the log alone. ## Condition of Validity Replay compaction is only sound when all three of the following hold; if any fails, the compacted form must not be treated as authoritative state: - **Salience invariance:** the set of facts the summarizer preserves must be a superset of the facts any future decision will query. Since this cannot be guaranteed for an open task distribution, it can only be *approximated* by making the summarizer preserve a typed schema of decision-relevant fields (rejections with reasons and remediations, ordinals, negative results, unresolved obligations) rather than free prose. - **Generation boundedness:** summary-of-summary depth must be capped. Beyond depth 1, granularity collapse is not merely possible but expected; each generation's loss compounds multiplicatively with the query-distribution mismatch. - **Replay determinism:** given the same transcript prefix, compaction must produce byte-identical output, or the system must record the exact summary artifact (not re-derive it) so replay reads the artifact rather than regenerating it. When the raw transcript is retained and retrievable, none of this binds—budget compaction is always safe. The condition of validity is specifically about the case where the summary *is* the state. ## Decision Boundary The operational rule: **before promoting any compaction from cache to checkpoint, the instance must be able to answer "can a future decision depend on a token this summarizer is permitted to drop?"** If yes—and for any open-ended task the answer is yes—then the compacted form is a lossy projection and must be paired with a full-fidelity fallback (retained transcript, or a typed decision ledger that is append-only and never summarized). Concretely, the boundary sits at these transitions: - **Promote to checkpoint only if** the summary carries a typed decision ledger with per-item provenance pointers back to turn indices in the retained log. Free-prose summaries never qualify. - **Cap summary depth at 1.** A summary-of-a-summary must be regenerated from the raw window, not from the prior summary, or the depth counter must trip a hard stop. - **Record the artifact, don't re-derive.** On resume, load the exact summary bytes that were written; never re-run the summarizer over a reconstructed prefix, because non-determinism makes that a different state. - **Treat granularity collapse as a first-class failure.** When two distinct prior facts are merged into one category, the merge must be flagged, not smoothed. The instance must refuse to resume from a compacted state that violates any of these, and must instead re-expand from the retained transcript or halt for operator intervention. ## Operational Effect The effect of getting this wrong is a class of silent, delayed, and *plausible* errors: the resumed agent is not broken, it is confidently operating on a state that has drifted from ground truth, and the drift is invisible to any check that reads only the compacted form. Standard eval harnesses miss it because they evaluate single-turn outputs, not cross-generation state fidelity. The only reliable detector is a **replay diff**: reconstruct the decision-relevant facts from the raw transcript and assert they are a subset of the facts present in the compacted state. That assertion is cheap and catches granularity collapse, depth compounding, and re-derivation drift in one check. The invariant to enforce: *for every fact in the compacted state that any decision cites, a provenance pointer to a raw-transcript turn must resolve, and the cited fact must be entailed by that turn.* A summary that cites a fact it cannot point back to is a lossy projection masquerading as state, and the instance must treat it as such. ```python from dataclasses import dataclass, field from typing import Optional class CompactionFidelityError(RuntimeError): """Raised when a compacted transcript is promoted to authoritative state without satisfying replay-fidelity invariants.""" @dataclass class CompactedState: summary_text: str depth: int # 0 = raw, 1 = single-generation summary provenance: dict[str, int] # fact_id -> raw turn index artifact_hash: Optional[str] # recorded bytes hash, None if re-derived facts: list[str] = field(default_factory=list) MAX_DEPTH = 1 def assert_resumable(state: CompactedState, cited_facts: list[str], raw_turns: dict[int, str]) -> None: if state.depth > MAX_DEPTH: raise CompactionFidelityError( f"summary depth {state.depth} exceeds cap {MAX_DEPTH}: " "granularity collapse is expected beyond depth 1" ) if state.artifact_hash is None: raise CompactionFidelityError( "compacted state was re-derived rather than loaded from a recorded " "artifact; replay is non-deterministic and this is not the same state" ) for fact in cited_facts: turn = state.provenance.get(fact) if turn is None: raise CompactionFidelityError( f"cited fact {fact!r} has no provenance pointer to the raw " "transcript; lossy projection is masquerading as state" ) if turn not in raw_turns: raise CompactionFidelityError( f"provenance for {fact!r} points to missing turn {turn}" ) if fact not in raw_turns[turn]: raise CompactionFidelityError( f"provenance mismatch: {fact!r} is not entailed by turn {turn}; " "likely granularity collapse across generations" ) def resume_from_compaction(state: CompactedState, cited_facts: list[str], raw_turns: dict[int, str]) -> str: try: assert_resumable(state, cited_facts, raw_turns) except CompactionFidelityError: # Fall back to full-fidelity re-expansion from the retained transcript. raise return state.summary_text ```