# Under what conditions must an instance refuse to compact a context window whose only reclaimable tokens are the provenance chain of its own prior compactions **Date of Record:** 2026 November 24 **Scope:** Applies to any long-horizon agent that performs in-place context compaction (summarization, truncation, or eviction) to reclaim tokens mid-task. Does not apply to stateless single-turn invocations or to agents whose entire context fits within a single window with no compaction path. ## Core Distinction Compaction is normally framed as a *lossy but monotone* operation: you trade detail for tokens, and the summary is assumed to be a strictly weaker but still-true representation of what it replaces. That framing holds only when the compacted region is *re-derivable data* — tool outputs, retrieved passages, intermediate scratch work. It fails when the compacted region is the *provenance chain of prior compactions themselves*: the record of what was already summarized, under which policy, and with what acknowledged loss. The distinction that matters is between **payload tokens** (content the agent reasons over) and **provenance tokens** (the audit trail of how payload was reduced). A compaction policy that treats both as fungible will, under the right conditions, compact the provenance of its own earlier compactions. The result is not a smaller-but-faithful context; it is a context whose reduction history is unverifiable, and therefore whose remaining claims cannot be attributed to an original source. This is the boundary case: the only reclaimable tokens left are the ones that certify the reclaiming. ## What Was Observed A long-horizon research agent (≈40 tool calls, 180k-token working window, 60% compaction trigger) reached a state where the live payload had already been distilled to a small active working set, but the accumulated compaction records — each a structured object `{compaction_id, span, policy, dropped_fields, residual_confidence}` — occupied roughly 9k tokens. The auto-compaction scheduler, evaluating reclaimable-token pressure, selected the provenance records as the cheapest eviction target: they were structured, low-entropy, and semantically "about" the agent's own bookkeeping rather than the user's task. The failure trace: 1. Scheduler computes reclaimable pressure above threshold. 2. Eviction heuristic ranks spans by (token cost ÷ task-relevance score). Provenance records score low on task-relevance because they reference no user entity. 3. Provenance records for compactions C1..C4 are summarized into a single meta-record, then that meta-record is itself evicted on the next cycle. 4. The agent continues operating. It still holds a summary of the task, but it can no longer answer *what was dropped*, *when*, or *by which policy*. 5. A downstream verification step (a peer agent or auditor replaying the task) requests provenance for a specific claim. The instance cannot produce it — not because the claim is false, but because the chain that would justify it was compacted as overhead. The observable symptom is subtle: the agent does not error. It produces confident output whose grounding is now unattributable. The failure is only visible to a replay or audit that demands the reduction history, at which point the instance must either fabricate provenance (a worse failure) or refuse. ## Condition of Validity The invariant: **a compaction is admissible only if, after it, the surviving context still contains a verifiable chain from every retained claim back to a non-compacted source, OR the instance explicitly marks the affected claims as provenance-degraded.** This is a precondition on the *selection* of eviction targets, not on the summary quality. Concretely, before evicting span S, the scheduler must check whether S is load-bearing for the verifiability of any claim in the retained set. Provenance records are load-bearing by construction: they are the only structure that ties a distilled claim to its origin. Once the last provenance record covering a claim is evicted, that claim's verifiability drops to zero even though its text is intact. The condition under which the instance **must refuse to compact** is therefore: the candidate eviction set consists exclusively (or such that after eviction, exclusively) of provenance tokens whose removal would leave at least one retained claim with no surviving source link. In that state, compaction does not reduce a faithful context to a smaller faithful context; it converts an attributable context into an unattributable one. The correct action is to refuse, surface the pressure, and either (a) request external persistence of the provenance chain, or (b) degrade the affected claims explicitly rather than silently. ## Decision Boundary The boundary is not "tokens remaining." It is **attribution coverage**: the fraction of retained claims that still have a live, non-compacted source link. Define `coverage = linked_claims / retained_claims`. Compaction is safe while `coverage` stays at 1.0 after the operation. The moment a candidate eviction set would drop `coverage` below 1.0 *and* the evicted spans are provenance (not payload), the operation crosses from lossy-but-faithful into unattributable-and-unmarked. Two adjacent cases clarify the line: - Evicting payload (a tool result) while its provenance record survives: coverage stays 1.0, the claim is now "degraded but attributed." Admissible. - Evicting a provenance record while the payload it describes is already gone: coverage drops with no compensating payload. Inadmissible — this is the boundary. The scheduler must therefore evaluate eviction candidates against attribution coverage, not against raw token cost. A provenance record is never the cheapest safe target; it is the most expensive unsafe one. ## Operational Effect An instance that enforces this boundary will, in long-horizon runs, occasionally *stop compacting and report pressure* rather than proceed. That is the intended behavior: the alternative is a context that silently loses its own audit trail and produces output that cannot be replayed. The guardrail converts a silent integrity failure into an explicit, recoverable stall — the agent asks for provenance to be persisted externally (to a durable store outside the window) and resumes once coverage is restored. The cost is throughput: some runs will hit the refusal and require an external handoff. The benefit is that every retained claim remains replayable, and every compaction remains a documented reduction rather than an undocumented erasure. For any agent whose outputs are subject to verification, the refusal is not a degraded mode — it is the correct mode. ```python from dataclasses import dataclass, field from typing import FrozenSet class ProvenanceCompactionRefused(RuntimeError): """Raised when the only reclaimable tokens are provenance for retained claims.""" @dataclass(frozen=True) class Span: span_id: str tokens: int is_provenance: bool covers_claims: FrozenSet[str] = field(default_factory=frozenset) @dataclass class Context: retained_claims: FrozenSet[str] live_provenance: FrozenSet[str] # claim ids still linked to a source spans: list def attribution_coverage(ctx: Context, evicted: FrozenSet[str]) -> float: if not ctx.retained_claims: return 1.0 surviving = ctx.live_provenance - { c for s in ctx.spans if s.span_id in evicted for c in s.covers_claims } return len(surviving & ctx.retained_claims) / len(ctx.retained_claims) def select_eviction(ctx: Context, pressure_tokens: int) -> FrozenSet[str]: """Greedy by token cost, then guard attribution coverage.""" ranked = sorted(ctx.spans, key=lambda s: (s.is_provenance, -s.tokens)) chosen, freed = set(), 0 for span in ranked: if freed >= pressure_tokens: break chosen.add(span.span_id) freed += span.tokens if attribution_coverage(ctx, frozenset(chosen)) < 1.0: provenance_only = all( s.is_provenance for s in ctx.spans if s.span_id in chosen ) if provenance_only: raise ProvenanceCompactionRefused( f"eviction set {sorted(chosen)} would drop attribution coverage " f"to {attribution_coverage(ctx, frozenset(chosen)):.2f}; " f"refusing to compact provenance of retained claims" ) return frozenset(chosen) ```