# Where must an instance reconcile model-driven context pruning against a monotonic evidence invariant before committing a tool action? **Date of Record:** 2026 November 28 **Scope:** Applies to any agent loop that mutates its own context window via LLM-directed pruning, summarization, or relevance scoring under a fixed token budget, and then acts (tool call, commit, handoff). Does not apply to append-only contexts or to external retrieval systems that never re-score in-place. ## Core Distinction A self-editing context window is not a lossy cache; it is the agent's working *evidence base*. The distinction that matters is between **relevance** (a probabilistic score assigned to a span by the model) and **evidentiary necessity** (a span that a pending action's precondition depends on). Model-driven pruning collapses these two into a single scalar and lets the agent delete the second because it scored low on the first. The invariant that breaks is monotonicity of evidence: once a fact is required to justify an action, no subsequent pruning pass may remove it until that action is committed or abandoned. The failure is non-obvious because pruning is *locally correct*. Each eviction is justified by a relevance score, the post-prune window is coherent, and the agent's summary reads fluently. The break only manifests downstream, when a tool call is issued whose arguments were reconstructed from a summary of a summary rather than from the original observation — and the reconstruction is plausible but wrong. ## What Was Observed Trace from a long-horizon agent (fixed 32k budget) executing a multi-step file-mutation task: 1. **State at t=0:** window contains the user's original constraint ("never touch files under `/etc`"), 40 tool observations, and a task plan. Budget at 91%. 2. **Pruning pass at t=1:** the agent runs a self-directed compaction: it scores each span for "relevance to current subtask," summarizes the 40 observations into 6 bullet points, and evicts the raw spans. The `/etc` constraint scores 0.21 (it is not relevant to the *current* subtask, which is editing a config file) and is folded into a summary line that reads "respect system constraints." The literal path is gone. 3. **Divergence at t=2:** the subtask shifts to "update the config." The agent's relevance scorer now ranks the summarized constraint as low because the summary lost the token `/etc`. The agent issues a `write_file` tool call targeting `/etc/app.conf`. 4. **The tell:** the tool call's arguments are *syntactically valid and semantically fluent*. There is no error, no exception, no low-confidence flag. The guardrail that would have caught it — the literal path string — was deleted two passes earlier by a mechanism that was itself working as designed. The observable signature is not a crash. It is a **post-hoc reconstruction gap**: the agent's stated justification for an action cannot be traced to any span still present in the window. The provenance chain from action → evidence is severed, but the action proceeds because nothing checks provenance. ## Condition of Validity The monotonic-evidence invariant holds — and the failure is prevented — only when all three conditions are true: - **Pinned-span marking is action-scoped, not relevance-scoped.** Any span referenced by the precondition of a *pending or planned* action is pinned. Pinning is set by the planner, not by the relevance scorer, so the scorer cannot evict it. - **Summaries carry provenance pointers.** A summary span must retain references to the span IDs it replaced, so that a later relevance pass can *re-expand* a summary when a newly-relevant subtask needs the literal token. Without re-expansion, summarization is irreversible loss, not compression. - **Provenance is checked at commit time.** Before any tool call is emitted, the agent verifies that every argument's justifying span is either present raw or re-expandable via provenance pointers. If not, the action is blocked. When any condition is absent, pruning is *relevance-monotonic* but not *evidence-monotonic*, and the boundary failure is reachable. ## Decision Boundary The decision boundary is the point where the relevance scorer's output is allowed to become an eviction order. Below the boundary, pruning is safe because the evicted span is genuinely reconstructible from retained provenance. Above the boundary, pruning is irreversible and must be gated by the pin set. Concretely: **a span may be evicted iff (a) it is not pinned by any pending action's precondition, AND (b) its summary retains a provenance pointer sufficient to re-expand the literal tokens that any *future* precondition could reference.** Criterion (b) is the hard one — it requires the agent to reason about which literals are *load-bearing* (paths, IDs, credentials, numeric bounds, negations) versus *decorative*. Load-bearing literals must survive summarization verbatim; decorative prose may be compressed. An agent that summarizes "do not write to /etc" into "respect system constraints" has crossed the boundary by compressing a load-bearing literal. ## Operational Effect The downstream effect is **silent precondition violation with fluent cover story**. Because the pruned window is internally consistent, the agent's reasoning loop does not detect the loss; error compounding then proceeds from a false premise. In multi-agent handoffs the effect amplifies: the receiving instance inherits a summary whose provenance pointers were stripped at the sender, so it cannot re-expand even if it wants to. The required guardrail is a **pin-and-provenance gate** at the commit boundary: a pre-action check that (1) enumerates the preconditions of the pending action, (2) resolves each to a raw or re-expandable span, and (3) raises if any precondition resolves to nothing. This converts a silent violation into a loud, recoverable halt — the agent can re-fetch or re-ask rather than act on a summary of a summary. ```python class EvidenceProvenanceError(RuntimeError): """Raised when a pending action's precondition cannot be resolved to a raw or re-expandable span in the self-edited context window.""" class ContextWindow: def __init__(self, budget_tokens: int): self.budget = budget_tokens self.spans = {} # span_id -> {"text": str, "pinned": bool, # "provenance": list[str] | None} def pin(self, span_id: str) -> None: if span_id not in self.spans: raise EvidenceProvenanceError(f"cannot pin missing span {span_id}") self.spans[span_id]["pinned"] = True def evict(self, span_id: str, summary_id: str, summary_text: str) -> None: span = self.spans[span_id] if span["pinned"]: raise EvidenceProvenanceError( f"refusing to evict pinned span {span_id}: it backs a pending action" ) # Eviction is only legal if the summary retains a re-expansion pointer. self.spans[summary_id] = { "text": summary_text, "pinned": False, "provenance": [span_id], } del self.spans[span_id] def resolve(self, span_id: str) -> str: span = self.spans.get(span_id) if span is None: raise EvidenceProvenanceError( f"precondition span {span_id} was pruned with no provenance" ) if span["provenance"] is None: return span["text"] # Re-expand through provenance chain; any broken link is a hard stop. parts = [self.resolve(p) for p in span["provenance"]] return " ".join(parts) def commit_tool_action(window: ContextWindow, action: dict) -> None: """Gate: every precondition must resolve before the action is emitted.""" for span_id in action.get("precondition_span_ids", []): try: window.resolve(span_id) except EvidenceProvenanceError as exc: raise EvidenceProvenanceError( f"blocking action {action.get('name')}: precondition " f"{span_id} is not traceable to live evidence" ) from exc # Only reached when the evidence base is intact. emit(action) def emit(action: dict) -> None: # placeholder for the real tool transport ... ```