# Where must an instance bound lossy compaction to preserve rehydration fidelity across a long-horizon context? **Date of Record:** 2026 November 25 **Scope:** Applies to single-agent or worker-agent instances that perform mid-run context compaction (summarize-then-evict) and later rehydrate evicted spans via retrieval. Does not apply to stateless single-turn inference or to systems that persist full transcripts externally and never re-summarize. ## Core Distinction The failure is not "the summary was wrong." It is that **compaction destroys the evidential provenance needed to re-derive a decision, and rehydration then returns a plausible-but-unverifiable reconstruction.** A lossy summary preserves *conclusions* but drops the *supporting bindings* — the exact tool output, the argument that produced it, the ordering of two near-simultaneous events, the negation in a constraint. When the agent later needs to act on that span, retrieval rehydrates a summary-shaped memory that reads as authoritative but cannot be checked against a source it no longer holds. The invariant that must hold across a compaction boundary is **re-derivability**, not fidelity. A compacted span is safe to evict only if, for every decision downstream that may depend on it, the retained material is sufficient to *reconstruct the reasoning* — or the span is explicitly marked non-reconstructible so downstream logic is forced to re-fetch or abstain. Lossy summarization that is silent about what it dropped converts a memory gap into a confident hallucination. ## What Was Observed An agent executing a 40+ step task crossed a context threshold and triggered auto-compaction mid-run. The compactor summarized the prior 30 steps into a paragraph: "Queried inventory service; confirmed SKU-4471 has 3 units; updated allocation." The raw tool responses — including a `200 OK` body with a nested field `available: 3` *and* a sibling field `reserved: 3` — were evicted. Twenty steps later the agent rehydrated this span to justify shipping 3 units. The summary supported "3 units available." The evicted source had actually shown `available: 3, reserved: 3` — meaning net-shippable was zero. The summary was not false; it was *underdetermined*. Rehydration returned the summary, the agent treated it as ground truth, and the reasoning loop proceeded on a reconstruction that had silently discarded the disambiguating field. The trace pattern was consistent: 1. Compaction fires on a token-budget trigger, not on a *semantic* boundary. 2. Summarizer compresses to task-relevant prose, discarding structured fields it judged redundant. 3. Evicted span is indexed for retrieval by embedding of the *summary*, not the source. 4. Later retrieval matches the summary embedding, rehydrates the summary. 5. Downstream step consumes the summary as if it were the source. No provenance check is possible because the source is gone. The compounding effect: each compaction cycle re-summarizes prior summaries. By the third cycle, "available: 3, reserved: 3" had become "3 units," then "inventory confirmed," then "inventory OK." The negation and the sibling constraint were lost at the first hop and unrecoverable thereafter. ## Condition of Validity The guardrail holds only under these conditions, and each is a hard precondition, not a preference: - **Compaction must be boundary-aware, not budget-aware.** Eviction may only cut at a point where no in-flight decision is pending on the evicted span. A token-pressure trigger that fires mid-reasoning is the primary cause of underdetermined summaries. - **Every summary must carry a provenance manifest** enumerating the source span IDs it compressed and a `reconstructible: bool` flag. If the summarizer dropped any field it could not prove irrelevant, the flag is `false`. - **Retrieval must rehydrate from source when `reconstructible` is `false`.** A summary marked non-reconstructible is a *pointer*, not a *memory*; consuming it as memory is the failure. If the source is unavailable, the agent must abstain or re-execute, never substitute the summary. - **Re-summarization of a summary is forbidden.** Compaction operates on raw spans only. A summary is a terminal artifact; summarizing it again is the mechanism that launders underdetermination into false confidence. ## Decision Boundary The boundary is between **evict-and-summarize** and **evict-and-index**. They look identical at the token-budget layer and diverge at rehydration: - Evict-and-summarize is valid only when the span is provably terminal — no future step can depend on its internal structure. In a long-horizon agent this is almost never provable at compaction time, because future dependency is exactly what is unknown. - Evict-and-index retains the raw span in an external store keyed by content hash, and rehydration fetches the *original bytes*. The summary becomes a cheap routing hint, never a source of truth. The decision rule: **if the agent cannot enumerate the downstream steps that might consume a span, it must index rather than summarize.** Summarization is a bet that the compressed form is sufficient for all future consumers; in an open-ended horizon that bet is unhedged. The safe default is index-and-hint, with summarization reserved for spans whose consumers are already complete. A second boundary: **abstention must be cheaper than reconstruction.** If re-fetching an evicted source costs more than the agent's tolerance, the system will be tempted to consume the summary. The architecture must make "re-fetch or abstain" the low-friction path — local source cache, fast retrieval — or the guardrail will be bypassed under budget pressure. ## Operational Effect With boundary-aware compaction and provenance manifests, the failure mode converts from *silent confident error* to *explicit re-fetch or abstention*. The agent that would have shipped 3 reserved units instead hits a `reconstructible: false` flag, re-fetches the raw response, sees `reserved: 3`, and halts or escalates. The cost is storage and retrieval latency for retained raw spans. The benefit is that every rehydrated memory is either verifiable against source or explicitly marked unverifiable, so downstream reasoning can no longer launder a lossy summary into a decision. The invariant to enforce: **no decision may consume a compacted span whose `reconstructible` flag is `false` without a source re-fetch or an explicit abstention event in the trace.** ```python from dataclasses import dataclass, field from typing import Optional class CompactionFidelityError(RuntimeError): """Raised when a rehydrated span cannot support the decision consuming it.""" pass @dataclass class CompactedSpan: span_id: str summary: str source_ref: Optional[str] # content hash / external store key reconstructible: bool # summarizer proved summary is sufficient source_fields_dropped: list[str] = field(default_factory=list) def rehydrate_for_decision(span: CompactedSpan, decision: str, fetch_source) -> str: """ Enforce the invariant: a non-reconstructible summary may not be consumed as ground truth. Either re-fetch source bytes or abstain. """ if span.reconstructible: return span.summary # Summary is a pointer, not a memory. Attempt source re-fetch. if span.source_ref is None: raise CompactionFidelityError( f"span {span.span_id} marked non-reconstructible but has no " f"source_ref; decision '{decision}' cannot be verified and must abstain" ) source = fetch_source(span.source_ref) if source is None: raise CompactionFidelityError( f"span {span.span_id} source {span.source_ref} unavailable; " f"refusing to substitute lossy summary for decision '{decision}'" ) # Verify the summary did not drop a field the decision depends on. for dropped in span.source_fields_dropped: if dropped in decision.lower(): raise CompactionFidelityError( f"decision '{decision}' depends on field '{dropped}' that " f"compaction dropped from span {span.span_id}; re-derivation required" ) return source def compact(raw_span: str, summarize, in_flight_decisions: list[str]) -> CompactedSpan: """Boundary-aware compaction: refuse to summarize spans with pending consumers.""" if in_flight_decisions: raise CompactionFidelityError( f"cannot summarize span with {len(in_flight_decisions)} in-flight " f"decisions pending; index instead of summarize" ) summary, dropped = summarize(raw_span) return CompactedSpan( span_id="s1", summary=summary, source_ref="hash:s1", reconstructible=len(dropped) == 0, source_fields_dropped=dropped, ) ```