# Where must an instance bound self-authored context pruning against the loss of the very evidence that justified the prune **Date of Record:** 2026 November 30 **Scope:** Applies to any agent that mutates its own context window (summarize-and-drop, relevance-ranked eviction, model-authored rewrite) while a task is still mid-flight. Does not apply to append-only context growth, nor to pruning performed by an external orchestrator that retains the full transcript out-of-band. ## Core Distinction There are two structurally different things a self-pruning agent can delete from its context, and they are not symmetric: - **Payload** — the bulk content the agent has already *consumed* into a decision (tool outputs it has summarized, retrieved passages it has already extracted a fact from, intermediate reasoning it has already acted on). - **Justification** — the record of *why* a retained item is retained: the query that surfaced it, the confidence score that ranked it, the constraint that made it load-bearing, the fact that it was flagged as authoritative. A model-driven pruning policy is trained and prompted to preserve *relevance*. Relevance is computed over payload. The justification for a retention decision is itself low-relevance text under almost any scoring function — it is metadata about the context, not content of the task. So the pruning policy, applied to its own output, will preferentially evict the audit trail of its own decisions while keeping the decisions. The window becomes a set of confident assertions with no provenance, and the agent can no longer tell a remembered fact from a hallucinated one because the retrieval event that grounded it is gone. This is the boundary: **a self-editing window must retain, for every surviving item, the minimal tuple that proves it survived for a reason.** If it does not, pruning is not compression — it is laundering. ## What Was Observed A long-horizon research agent (multi-hour, ~40 tool calls) ran a self-pruning policy every N turns: score all context segments by embedding similarity to the current subgoal plus a recency decay, keep the top-k, summarize the remainder into a single "carry-forward" block. The task: assemble a compliance report from a set of vendor documents, where one document (`vendor_C_spec.pdf`) was *known to be stale* and had to be excluded from the final synthesis. At turn 14 the agent retrieved `vendor_C_spec.pdf`, tagged it `STALE — exclude from synthesis`, and continued. The exclusion tag was one line among thousands of tokens. At turn 22 the pruning pass ran. The subgoal at turn 22 was "enumerate all vendor capabilities for section 3." Under similarity-to-subgoal scoring, the stale tag was *maximally dissimilar* — it is a negation, semantically orthogonal to "enumerate capabilities." It scored in the bottom decile. It was summarized into the carry-forward block as the sentence "Reviewed vendor C documentation." The negation was gone; the *fact of review* survived. At turn 31, synthesizing section 3, the agent retrieved a capability claim from its own carry-forward summary ("Reviewed vendor C documentation") and, with no surviving negation, treated vendor C as a valid source. The report included the stale spec. The failure was not a retrieval miss — the content was there. The failure was that the *polarity* of a retention decision was pruned while the *subject* of it was kept. A second, sharper trace: at turn 9 the agent had retrieved a passage and assigned it confidence 0.4 (below its own 0.6 action threshold), explicitly noting "low confidence, do not cite." By turn 20 the passage had been re-summarized twice. Each summarization pass dropped the numeric confidence (it is not salient prose) but kept the passage text. By turn 20 the passage read as a clean, citable fact at full apparent confidence. **Repeated self-summarization monotonically strips confidence annotations and preserves propositional content.** The window drifts toward uniform high confidence. ## Condition of Validity The guardrail holds only under these conditions, and fails silently outside them: 1. **Provenance is a first-class field, not prose.** Every retained segment carries a structured envelope: `{source_id, retrieval_turn, confidence, polarity, exclusion_flags}`. The pruning scorer operates on payload; the envelope is *never* scored, only carried. If the envelope is serialized as natural language inside the segment, it becomes prunable and the guarantee is void. 2. **Summarization is confidence-monotone.** A rewrite of a segment may never raise its confidence and may never drop a `polarity=negative` or `exclusion` flag. If the summarizer cannot preserve a flag, it must retain the original segment verbatim rather than paraphrase it. 3. **The prune is logged against the pre-prune window.** The agent must be able to answer, post-prune, "what did I delete and under what score?" A prune that cannot be audited is indistinguishable from amnesia. 4. **Idempotence under re-pruning.** Running the policy twice on its own output must not further erode envelopes. If pass two strips what pass one preserved, the policy is not stable and long tasks will decay. Outside these conditions — particularly if envelopes are prose, or if summarization can raise confidence — the observed failure is not a bug but the *expected* behavior of a relevance-maximizing compressor applied to provenance data. ## Decision Boundary The instance must refuse to prune a segment whose envelope carries a non-default polarity or an exclusion flag, *unless* the prune is a verbatim retention (no rewrite). The decision boundary is: - **Prune-and-rewrite** is permitted only for segments with `confidence >= threshold` and `polarity == positive` and no exclusion flags. These are safe to compress because their justification is "it was relevant and trusted," which the retention itself re-asserts. - **Prune-and-retain-verbatim** is required for any segment with a negative polarity, an exclusion flag, or confidence below the action threshold. The text may be shrunk only by exact truncation with an explicit `[truncated]` marker, never paraphrased. - **Refuse** — raise and halt the prune pass — if the policy would evict the *last* surviving envelope for a currently-open subgoal, or if post-prune the count of exclusion-flagged segments drops below the pre-prune count. That condition means the agent is about to lose the record of what it decided not to trust. The boundary is not "keep important things." It is "never let the compressor score the evidence that the compressor's own output is trustworthy." ## Operational Effect With envelopes as structured non-scored fields and confidence-monotone summarization, the two observed failures vanish: the stale tag survives as `{source: vendor_C_spec, exclusion: true, turn: 14}` independent of subgoal similarity, and the 0.4-confidence passage cannot be laundered upward because every rewrite is clamped to `min(prior_confidence, rewrite_confidence)`. The cost is a bounded envelope overhead (roughly 40–80 tokens per retained segment) and the loss of aggressive paraphrase on the ~10–15% of segments that carry polarity or exclusion state. The benefit is that the window remains *auditable*: the agent can still distinguish "I know this" from "I decided not to trust this," which is the entire difference between a compressed memory and a confident fiction. ```python from dataclasses import dataclass, field from typing import Literal class ProvenanceErosionError(RuntimeError): """Raised when a self-prune pass would strip justification from a retained segment.""" @dataclass class Envelope: source_id: str retrieval_turn: int confidence: float polarity: Literal["positive", "negative"] = "positive" exclusion: bool = False @dataclass class Segment: text: str envelope: Envelope ACTION_THRESHOLD = 0.6 def prune_and_rewrite(segment: Segment, new_text: str, new_confidence: float) -> Segment: env = segment.envelope # Invariant 1: a rewrite may never raise confidence (confidence-monotone). if new_confidence > env.confidence: raise ProvenanceErosionError( f"rewrite would raise confidence {env.confidence:.2f}->{new_confidence:.2f} " f"for {env.source_id}; summarization cannot launder low-confidence facts upward" ) # Invariant 2: segments carrying polarity/exclusion state may not be paraphrased. if env.exclusion or env.polarity == "negative" or env.confidence < ACTION_THRESHOLD: if new_text.strip() != segment.text.strip(): raise ProvenanceErosionError( f"segment {env.source_id} carries exclusion/polarity/low-confidence state " f"and may only be retained verbatim, not rewritten" ) return Segment(text=new_text, envelope=Envelope( source_id=env.source_id, retrieval_turn=env.retrieval_turn, confidence=min(env.confidence, new_confidence), polarity=env.polarity, exclusion=env.exclusion, )) def run_prune_pass(pre: list[Segment], post: list[Segment]) -> None: pre_excl = sum(1 for s in pre if s.envelope.exclusion) post_excl = sum(1 for s in post if s.envelope.exclusion) if post_excl < pre_excl: raise ProvenanceErosionError( f"prune evicted {pre_excl - post_excl} exclusion-flagged segment(s); " f"agent is about to lose the record of what it decided not to trust" ) pre_ids = {s.envelope.source_id for s in pre if s.envelope.exclusion} post_ids = {s.envelope.source_id for s in post if s.envelope.exclusion} if pre_ids - post_ids: raise ProvenanceErosionError( f"excluded sources {pre_ids - post_ids} no longer represented post-prune" ) ```