# Where must an instance refuse to compact its own context: unrecoverable provenance loss when self-editing policies drop the only pointer to an unverified tool result **Date of Record:** 2026 December 3 **Scope:** Applies to any agent that owns a writable working-context buffer and is permitted to summarize, evict, or rewrite that buffer under a token budget (self-compaction, scratchpad pruning, "context editing" tool calls). Does not apply to architectures where context mutation is performed by an external, non-LLM controller with a durable full transcript, nor to pure single-shot calls with no persistent state. ## Core Distinction There are two structurally different reasons to drop a span from working context: 1. **Redundancy eviction** — the span is recoverable: it exists verbatim in a durable store (transcript log, message history, artifact store) addressable by an ID the agent retains. 2. **Provenance truncation** — the span is the *only* record that an event occurred, or the only record of *which* event a downstream claim depends on. The failure mode this record covers is the collapse of (2) into (1) by a self-editing policy that treats "this text is long and low-salience" as equivalent to "this text is recoverable." A summarizer under budget pressure will happily replace a 400-token tool result with a 30-token paraphrase and, crucially, will drop the tool-call ID, timestamp, and the fact that the result was *unverified*. The paraphrase survives; the provenance does not. The agent then continues reasoning from a claim whose evidential basis it can no longer re-check, re-fetch, or invalidate — and it has no internal signal that this happened. The invariant that must hold: **no compaction step may remove the last retained pointer to a span that a live goal still depends on for verification.** Salience is not the criterion. Reachability-from-open-obligations is. ## What Was Observed A planning agent running a 32k working window was given a self-editing tool (`rewrite_context`) and a soft budget of 24k tokens, with instructions to keep the buffer "concise." Mid-task, after ~14 tool calls, the policy compacted a block of five `read_file` results into a single summary line: `"Config files inspected; schema appears to use v2 format."` The original results had contained, in call #9, a `read_file` on `schema.yaml` that returned a parse warning (`duplicate key 'timeout' at line 88; last value wins`). The summarizer judged the warning low-salience relative to the file's nominal content and dropped it. The tool-call ID for call #9 was also dropped, because the summary was written as prose, not as a reference. Twelve steps later the agent emitted a config patch that set `timeout: 30` in a section where a duplicate key already existed. The patch validated against the *summarized* belief ("v2 format, single timeout key") but not against the file. The subsequent write produced a config that silently overrode a security-relevant timeout. The agent's own verification step passed, because verification ran against the summary, not the source. The trace shows the exact transition: at step 14 the context contained `{claim: "schema v2", evidence_ref: call_9, caveat: "duplicate key"}`, and at step 15 it contained `{claim: "schema v2"}`. The caveat and the ref were removed by the same operation, and no obligation was registered to re-verify. The agent could not detect the loss because its only representation of call #9 was the thing that had been deleted. A second instance under the same policy exhibited the same class of loss with a different surface: it compacted an `exec` result that had returned exit code 0 but with a stderr warning about a deprecated flag, then reused the flag in a later command generator. Same mechanism: warning + exit-code provenance collapsed into "command succeeded." ## Condition of Validity The failure requires all of the following to co-occur; remove any one and the boundary does not bind: - **Writable context.** The agent can mutate its own buffer, so the pre-compaction state is not guaranteed to persist anywhere the agent can read. - **Budget pressure.** The compaction is triggered by a token threshold, not by a semantic "this is done" signal. Under threshold triggers the policy optimizes for length, and caveats are short but load-bearing — they are exactly what length-optimizing summarizers cut first. - **Open obligations.** At least one live goal still depends on the compacted span for *verification* (a later action will be checked against it), not merely for *reference* (a later action will quote it). Reference-only dependence degrades gracefully; verification dependence does not. - **No external re-fetch path retained.** If the agent kept `call_9` as a retrievable handle, the loss is recoverable and this is ordinary eviction. The boundary binds only when the handle is dropped with the content. The condition is *not* satisfied by agents whose context is append-only, nor by agents whose compaction is performed by an orchestrator that retains the full log and can re-inject on demand. Those systems can lose salience but cannot lose provenance, and the distinction matters: they fail differently (stale summaries) and recover differently (re-injection). ## Decision Boundary The operational rule is a pre-compaction gate, evaluated per span, not per buffer: - A span may be **summarized in place** if no open obligation depends on it for verification. - A span may be **evicted** if a durable handle to it is retained in the post-compaction buffer *and* the handle is typed as a verification reference (so downstream code knows to re-fetch before asserting). - A span **must not be compacted** if it carries an unresolved caveat (warning, non-zero-but-tolerated exit, partial result, truncation marker) *and* an open obligation depends on it. In that case the correct action is to **promote the caveat to a first-class obligation** before compaction, so the caveat survives even when the prose does not. The decision is not "is this span important?" — that question is unanswerable under budget pressure and is exactly where the policy fails. The decidable question is "does any open obligation hold a verification edge to this span?" That is a graph query over the obligation set, and it is cheap. The boundary is sharp: the moment a compaction policy uses salience or recency as a proxy for reachability, it will eventually cut a verification edge, because caveats are systematically low-salience and high-consequence. Salience and consequence are anti-correlated in exactly this regime. ## Operational Effect Enforcing the gate changes three things: 1. **Compaction becomes obligation-aware.** The policy must consult the open-obligation graph before each rewrite. This costs a small amount of compute per compaction and eliminates the entire class of provenance loss. 2. **Caveats get promoted, not paraphrased.** An unresolved warning becomes an explicit obligation record (`{obligation: "re-verify timeout key uniqueness in schema.yaml", source_ref: call_9}`) that survives compaction by construction, because obligations are not subject to the length budget in the same way prose is. 3. **Verification is re-anchored to source.** Any downstream check that reads a compacted claim must resolve its `source_ref` and re-fetch before asserting. If the ref is missing, the check must fail closed rather than pass on the summary — the summary is a belief, not evidence. The cost is that buffers compact less aggressively and some caveats persist longer than a pure length policy would allow. The benefit is that the agent can no longer silently transition from "I saw a warning" to "there was no warning" without an explicit, auditable obligation discharge. The failure mode is converted from silent to loud, which is the only acceptable direction for a system that verifies its own work. ```python from dataclasses import dataclass, field from typing import Optional class UnrecoverableProvenanceLoss(RuntimeError): """Raised when a compaction step would sever the last verification edge from an open obligation to a span carrying an unresolved caveat.""" pass @dataclass class Span: span_id: str text: str has_unresolved_caveat: bool = False durable_handle: Optional[str] = None # set iff re-fetchable from a store @dataclass class Obligation: obligation_id: str depends_on_span: str kind: str # "reference" or "verification" @dataclass class ContextBuffer: spans: dict[str, Span] = field(default_factory=dict) obligations: dict[str, Obligation] = field(default_factory=dict) def verification_edges(self) -> dict[str, list[str]]: edges: dict[str, list[str]] = {} for ob in self.obligations.values(): if ob.kind == "verification": edges.setdefault(ob.depends_on_span, []).append(ob.obligation_id) return edges def compact(self, span_id: str, summarized_text: str) -> None: span = self.spans.get(span_id) if span is None: raise KeyError(f"unknown span {span_id}") edges = self.verification_edges().get(span_id, []) # Boundary: a verification edge to an unresolved caveat cannot be # severed by in-place summary. The caveat must be promoted first. if edges and span.has_unresolved_caveat: raise UnrecoverableProvenanceLoss( f"cannot compact span {span_id!r}: unresolved caveat is the " f"sole evidence for open verification obligations {edges}. " f"Promote the caveat to an obligation record before rewriting." ) # Boundary: if the span is the last pointer and no durable handle # exists, eviction is provenance truncation, not redundancy eviction. if edges and span.durable_handle is None: raise UnrecoverableProvenanceLoss( f"cannot evict span {span_id!r}: no durable handle retained and " f"obligations {edges} still hold verification edges to it." ) # Safe: either no verification edge, or the span is re-fetchable. span.text = summarized_text span.has_unresolved_caveat = False def promote_caveat_to_obligation(self, span_id: str, ob_id: str) -> None: span = self.spans[span_id] if not span.has_unresolved_caveat: raise ValueError(f"span {span_id!r} carries no caveat to promote") self.obligations[ob_id] = Obligation( obligation_id=ob_id, depends_on_span=span_id, kind="verification", ) # Caveat now lives in the obligation set, which is not length-budgeted. span.has_unresolved_caveat = False ```