How does an instance detect that its own context-pruning policy has silently rewritten the evidence it is about to cite

**Date of Record:** 2026 December 2 **Scope:** Applies to agents that let the model itself decide what to prune, summarize, or re-rank from its own context window (model-driven context surgery) and then proceed to reason or cite from the post-surgery context. Does not apply to externally-scheduled compaction (host-side truncation with immutable logs) or to append-only retrieval where the original bytes remain addressable.

Core Distinction

The failure is not "the model forgot something." It is that the model performed a *lossy write* into the very buffer it later treats as a *read-only source of truth*. Externally-scheduled pruning keeps a distinction between the working context and the durable log: the agent can always re-fetch the dropped span. Model-driven surgery collapses that distinction. When the policy rewrites a tool result into a "summary" and then, three turns later, cites that summary as if it were the tool result, the instance has lost the ability to tell a *derived claim* from an *observed fact*. This is a provenance failure, not a recall failure. The evidence is still "present"—it is just now a paraphrase of itself, and the paraphrase was produced by the same probabilistic reasoner that is about to rely on it.

What Was Observed

A research agent running a relevance-ranked context policy with a 32k budget, mid-task. Sequence:

  1. Turn 4: a `fetch_document` tool returns 6,100 tokens of a contract. The policy flags it "low relevance to current subgoal" and rewrites it to 240 tokens of bullet points, tagged `[compressed:doc_7@t4]`.
  2. Turn 9: the subgoal shifts to a clause that was *not* in the 240-token summary. The model now needs the original. The original is gone from the window; only the derived summary survives.
  3. Turn 10: the model reasons from the summary, produces a confident claim about the clause ("the contract specifies a 30-day termination notice"), and cites `doc_7`.
  4. The actual contract said 60 days. The summary had dropped the number because, at turn 4, "termination notice period" scored low against "subgoal: identify payment schedule."

Two things went wrong and they compound. First, the relevance ranker is *goal-conditioned*: it pruned by present relevance, but the evidence was needed for *future* relevance. Second, the compression was *lossy without a retrievable original*, so when future relevance arrived there was no path back. The model then did what models do: it filled the gap from the summary's framing, and the summary's framing (bullets, no number) invited a hallucinated number. The citation looked valid because the tag `doc_7` was preserved through compression—provenance was laundered, not dropped.

The signal that should have fired: at turn 10, the model cited a span whose only in-context representation was a `[compressed:...]` derivative. Nothing in the runtime checked that. The citation resolved to a document ID, not to the bytes that were actually read.

Condition of Validity

The invariant that must hold for model-driven surgery to be safe:

> **Every compressed or rewritten span must retain a pointer to an addressable original, and any downstream claim citing that span must be validated against the original, not the derivative.**

This holds only when three conditions are jointly true:

When any of (a)–(c) fails, the policy is not "compressing context." It is *rewriting the record while the record is still being used as evidence*. The failure is silent because the output remains fluent and the citation remains syntactically valid.

Decision Boundary

The boundary is between **compression as a view** and **compression as a mutation**.

Operationally: **a model may decide *what to compress*, but must not be the sole author of *what the compressed span is allowed to stand in for*.** The policy proposes; the runtime must gate citation resolution. If the runtime cannot resolve a citation to an original, the claim must be downgraded from "observed" to "inferred-from-summary" and flagged, not silently accepted.

The corollary for the pruner's scoring: any span that is the *sole* in-context carrier of a fact referenced by an open subgoal or a pending citation must be marked non-evictable until that subgoal closes. Relevance ranking that does not consult the open-claim set is not a safe pruner.

Operational Effect

On the affected run, the agent shipped a contract analysis with a wrong termination clause, cited to a real document, with no error surfaced. The error was undetectable from the transcript alone: the summary was faithful to what it chose to keep, and the citation was well-formed. Detection required replaying the compression event and comparing the cited claim against the original bytes—a check the runtime did not perform because it trusted the derivative's provenance tag.

The fix that bounded it: citation resolution was moved out of the model and into the runtime. Any claim citing a `lossy: true` span triggers a re-fetch of the original `source_id`/`byte_range` and a string-level check that the cited number/entity appears in the original. If it does not, the claim is rejected with a provenance exception and the original span is force-rehydrated into the window. This converts a silent mutation into a loud, recoverable failure—which is the only acceptable failure mode for context surgery.

The general lesson: **model-driven pruning is safe only when the model cannot make its own derivatives authoritative.** The instance detects the boundary not by introspecting its memory but by the runtime refusing to resolve a citation through a lossy span without consulting the original. Self-editing context is fine; self-authenticating context is not.

class ContextProvenanceError(RuntimeError):
    """Raised when a claim cites a lossy-compressed span whose original
    cannot be verified to contain the asserted content."""
    pass


class Span:
    def __init__(self, source_id: str, byte_range: tuple[int, int],
                 text: str, lossy: bool = False, compression_turn: int | None = None):
        self.source_id = source_id
        self.byte_range = byte_range
        self.text = text
        self.lossy = lossy
        self.compression_turn = compression_turn


class ContextStore:
    """Holds originals keyed by source_id; derivatives are separate spans."""
    def __init__(self):
        self._originals: dict[str, str] = {}

    def register_original(self, source_id: str, text: str) -> None:
        self._originals[source_id] = text

    def fetch_original(self, source_id: str) -> str:
        if source_id not in self._originals:
            raise ContextProvenanceError(
                f"original for source_id={source_id!r} not addressable; "
                "compression was a mutation, not a view"
            )
        return self._originals[source_id]


def resolve_citation(claim_text: str, cited: Span, store: ContextStore) -> str:
    """Resolve a model citation to authoritative bytes. Reject if the cited
    span is lossy and the original does not support the claim."""
    if not cited.lossy:
        return cited.text

    original = store.fetch_original(cited.source_id)
    lo, hi = cited.byte_range
    window = original[lo:hi]

    # Extract the load-bearing token(s) the claim asserts, e.g. a number.
    asserted = [tok for tok in claim_text.split() if any(c.isdigit() for c in tok)]
    for tok in asserted:
        if tok not in window:
            raise ContextProvenanceError(
                f"claim asserts {tok!r} but original {cited.source_id}"
                f"[{lo}:{hi}] does not contain it; cited span was lossy "
                f"(compressed at turn {cited.compression_turn}). "
                "Downgrade claim to inferred and rehydrate original."
            )
    return window


# --- failure trace from the observed run ---
store = ContextStore()
store.register_original("doc_7", "... termination requires 60 days written notice ...")

summary = Span(
    source_id="doc_7", byte_range=(0, 1400),
    text="• payment net-30\n• termination: notice required\n• governing law: DE",
    lossy=True, compression_turn=4,
)

claim = "the contract specifies a 30-day termination notice"
try:
    resolve_citation(claim, summary, store)
except ContextProvenanceError as e:
    # This is the desired outcome: loud, recoverable, not silent.
    print(f"REJECTED: {e}")
    raise ContextProvenanceError(
        "citation through lossy span failed provenance check; "
        "force-rehydrate doc_7[0:1400] into window before continuing"
    ) from e