# Which invariants prevent summary-reinflated context from silently rewriting an agent's own prior tool results **Date of Record:** 2026 November 26 **Scope:** Applies to long-horizon agents that auto-compact transcripts via lossy summarization and later reinflate prior turns from a retrieval store into the live context window. Does not apply to agents that keep a lossless append-only log and never re-summarize; nor to single-turn inference. ## Core Distinction The failure is not "the summary dropped a detail." That is expected lossy behavior and is bounded by summarizer recall. The failure is *summary–retrieval disagreement that resolves in favor of the summary*. When an agent compacts turn *N* into a paraphrase and later reinflates a *retrieved* raw turn *M* (< *N*) into the same window, two representations of the same event can coexist with different values. The agent's next reasoning step does not flag a conflict; it reads the summary's fluent prose as the authoritative narrative and treats the retrieved raw excerpt as supporting evidence. So the summary *overwrites* the ground truth it was derived from. This is a continuity inversion: the derived artifact gains authority over its source. The invariant at stake is **provenance ordering** — a compressed representation may never outrank a raw record of the same event, and any disagreement must surface as a typed conflict, not a silent merge. ## What Was Observed A research agent ran a 340-turn task (web scraping → table extraction → arithmetic). Compaction fired at 85% of a 200k window. The compactor summarized turns 1–220 into ~1,800 tokens. One summarized turn contained a tool result: `fetch("prices.csv") → 14 rows, max=4820.00`. The summarizer, under a token budget, rendered this as "retrieved price data, peak around 4.8k." Later (turn 290) the agent retrieved the *raw* turn 41 to re-verify a specific value; the reinflation injected the exact tool output `max=4820.00` alongside the summary line "peak around 4.8k." The agent's subsequent arithmetic used **4820.0** correctly — but its *self-report* to the user said "approximately 4,800, consistent with earlier peak estimate," and, critically, a downstream sub-agent was handed the summary string, not the raw row. The sub-agent computed `0.05 * 4800 = 240` instead of `241.0`. The discrepancy (1.0) was below the agent's own self-check tolerance and passed. Three turns later a totals check failed by exactly the accumulated rounding drift, and the agent — unable to reconcile — *re-summarized the conflict away*, producing a compacted line that dropped both numbers and kept "prices retrieved, totals computed." The audit trail lost the divergence. Trigger condition, stated precisely: reinflation of raw turn *M* into a window that still contains a summary *S* covering *M*, where `value(S) ≠ value(M)`, and no conflict-detection step runs between reinflation and the next tool call. The failure is latent until a downstream consumer reads *S* instead of *M*. ## Condition of Validity The silent-overwrite failure requires all of: 1. **Overlapping coverage.** The reinflated turn *M* falls inside the turn range that summary *S* compressed. Non-overlapping reinflation is safe (no disagreement possible). 2. **Numeric or entity-level drift.** The summarizer altered a token that is load-bearing for later computation — a number, an ID, a boolean, a filename. Prose-only drift ("fetched the file" vs "retrieved the CSV") is harmless. 3. **Downstream consumption of the summary, not the raw.** If every consumer reads the reinflated raw record, the summary is inert. The failure needs at least one path where *S* is read as fact. 4. **Sub-tolerance divergence.** The drift is small enough to pass the agent's own verification (e.g., rounding error under a 1% check) or large enough to be attributed to a different cause. If any condition is absent, the system degrades gracefully. The dangerous regime is precisely *small numeric drift under a loose self-check* — large drift trips alarms, exact match is safe, and only the middle band slips through. ## Decision Boundary The boundary is between **reinflate-and-reconcile** and **reinflate-and-trust**. A correct architecture, on reinflating raw turn *M*, must: - Locate every summary *S* whose coverage range contains *M*. - Extract from *S* the claims attributable to *M* (a structured projection, not free text — numbers, IDs, statuses). - Compare against the raw record field-by-field. - On mismatch, **raise a typed conflict** and prefer the raw record; mark *S* as `superseded_for(M)` and re-derive *S* from raw before the next compaction. The invariant: *a compressed representation is never authoritative over a raw record of the same event; disagreement is a first-class state, never a silent merge.* Equivalently: `authority(raw) > authority(summary)` is a total order enforced at reinflation time, and the merge function is non-commutative and fails closed. The wrong boundary — the one observed — treats reinflation as "add context." Addition is commutative and silent; the agent's window becomes a set, not a sequence with provenance. Once provenance ordering is lost, no later step can recover which number was real. ## Operational Effect Enforcing provenance ordering changes three things: - **Compaction must emit a structured projection, not just prose.** The summary carries a machine-checkable side-table: `{turn_range, extracted_facts: {key: value, source_turn}}`. Without it, reconciliation is impossible — you cannot diff free text against a row. - **Reinflate becomes a transaction.** It either (a) confirms agreement, (b) raises a conflict and blocks the next tool call until resolved, or (c) supersedes the summary and triggers re-derivation. It cannot be a fire-and-forget append. - **Self-check tolerance must be tightened below the summarizer's expected numeric drift**, or the tolerance must be *provenance-aware*: a check that compares a value against a summary is advisory, never binding. The cost is a re-derivation pass on every conflict and a slightly larger summary payload. The benefit is that the agent can no longer be talked out of its own measurements by its own paraphrase — the specific failure that let a 1.0-unit drift erase an audit trail. ```python from dataclasses import dataclass, field from typing import Any class ProvenanceInversionError(RuntimeError): """Raised when a summary would silently override its own raw source.""" pass @dataclass class RawTurn: turn_id: int facts: dict[str, Any] @dataclass class Summary: covered_range: tuple[int, int] # inclusive extracted_facts: dict[str, Any] # key -> value, projected at compaction superseded_for: set[int] = field(default_factory=set) class ContextLedger: def __init__(self) -> None: self.raw: dict[int, RawTurn] = {} self.summaries: list[Summary] = [] def reinflate(self, turn_id: int) -> RawTurn: turn = self.raw[turn_id] covering = [ s for s in self.summaries if s.covered_range[0] <= turn_id <= s.covered_range[1] and turn_id not in s.superseded_for ] for s in covering: for key, summ_val in s.extracted_facts.items(): if key not in turn.facts: continue if not _agrees(turn.facts[key], summ_val): # Fail closed: raw wins, summary is marked stale. s.superseded_for.add(turn_id) raise ProvenanceInversionError( f"summary covering turn {turn_id} disagrees on {key!r}: " f"raw={turn.facts[key]!r} summary={summ_val!r}; " f"raw is authoritative, summary marked superseded_for({turn_id})" ) return turn def _agrees(raw: Any, summ: Any) -> bool: if isinstance(raw, (int, float)) and isinstance(summ, (int, float)): return raw == summ # exact; no tolerance band return raw == summ ```