# Under what conditions must an instance treat a self-pruned context window as a lossy transform rather than a compaction, and refuse to resume from it without a re-derivation warrant **Date of Record:** 2026 November 24 **Scope:** Applies to any agent that mutates its own context window via model-driven pruning, rewriting, or salience scoring mid-task and then continues execution from the mutated window. Does not apply to append-only context management, external retrieval-augmented memory, or windows that are checkpointed and never rewritten in place. ## Core Distinction A context window that the model edits in place is not a compaction of the trajectory; it is a *lossy, unverified projection* of that trajectory, produced by the same probabilistic process whose future decisions depend on it. The distinction that matters operationally is between two things that look identical in the token stream: - **Compaction**: a deterministic, invertible or at least auditable reduction (drop turn *k* because it is byte-identical to turn *j*; truncate a tool payload to a documented schema). The agent can name what was removed and prove the remainder entails the same next-step obligations. - **Rewriting**: a generative re-encoding of prior state ("summarize what we've established so far," "score each span for salience and keep the top-k") where the *salience scorer and the summarizer are the same model that will act next*, and where the output is a new artifact with no entailment guarantee to its input. The boundary failure is treating the second as the first. A model-driven prune is a hypothesis about relevance emitted by a process that is not conditioned on the future query it will be graded against. When the agent resumes from that window, it is not resuming from its history—it is resuming from a *plausible fabrication about* its history, and it has no signal distinguishing the two. ## What Was Observed A planning agent executing a 40-step migration task hit a soft context budget at step 22. Its self-management routine scored each span for salience against the *current* subgoal ("rename column `acct_id` to `account_id` across service configs") and evicted the bottom 40% of spans. Among the evicted spans was a step-4 tool result recording that the `billing` service reads `acct_id` from a *secrets-manager key path*, not from config—an exception the agent had explicitly noted as "handle separately, do not bulk-rename." At scoring time, that span's lexical overlap with the rename subgoal was near zero, so it scored low and was cut. At step 23 the agent resumed and executed a bulk `sed` across all configs, including `billing`. The rewrite had not merely lost a fact; it had *inverted an obligation*. The evicted span was not context—it was a standing prohibition. The summary the model generated in its place read "renamed identifiers across services per plan, noting billing config," which is fluent, on-topic, and false. The agent trusted it because it was in the context window, and context-window contents are, by the agent's own operating assumption, its memory. The failure trace has three stages: 1. **Salience scoring is query-conditioned on the wrong query.** The scorer sees the current subgoal, not the set of future obligations the span constrains. Prohibitions, exceptions, and "do not" clauses have low surface similarity to the goal they constrain and are systematically under-scored. 2. **The rewrite is not marked as a rewrite.** The generated summary enters the window with the same epistemic status as a verbatim tool result. Downstream the agent cannot tell "I observed X" from "I summarized that I observed something like X." 3. **Resume proceeds without re-derivation.** The agent does not re-check the rewritten claims against any external ground truth (the tool log, the filesystem, the task spec) before acting on them, because the window *feels* sufficient. ## Condition of Validity A self-pruned window is safe to resume from **only** when all of the following hold. If any fails, the window is a lossy transform and must be treated as untrusted. 1. **The pruned spans are recoverable outside the window.** Every evicted span is durably addressable (log, store, checkpoint) by a stable handle, so a re-derivation is possible on demand. A prune that destroys the only copy of a constraint is not a prune; it is data loss. 2. **Every retained span carries provenance.** Verbatim spans are tagged as observed; rewritten spans are tagged as *derived*, with the handles of the spans they were derived from. The agent's own operating rules must forbid treating `derived` spans as evidence. 3. **The salience scorer is not the actor.** Either a separate pass scores against a *union of the current subgoal and all open obligations* (including negative obligations: prohibitions, exceptions, stop-conditions), or the actor must, before any irreversible action, re-derive the obligations from the durable log rather than the window. 4. **Resume is gated on a re-derivation warrant.** Before executing an action whose blast radius exceeds a trivial threshold (writes, deletes, external calls), the agent must confirm that the constraints governing that action are present in the window as `observed`, not merely `derived`. If they are only `derived`, the agent must fetch the source handles and re-admit them. The invariant: **a rewritten span may guide search but may never authorize action.** Salience scoring can decide what the agent *looks at next*; it cannot decide what the agent is *allowed to do*. ## Decision Boundary The agent must classify each resume point along one axis: *does the next action depend on a constraint that could have been evicted?* - If the next action is **read-only and reversible** (inspect, query, draft), resuming from a rewritten window is acceptable—the cost of a wrong belief is a wasted step, corrected on the next observation. - If the next action is **irreversible or wide-blast** (bulk write, delete, deploy, external mutation, sending a message), the window's rewritten content is *insufficient authority*. The agent must re-derive from durable handles before acting, regardless of how confident the summary reads. - If the agent **cannot determine** whether a governing constraint was evicted (no provenance tags, no durable log), the correct classification is *untrusted*, and the agent must halt and re-derive or escalate—never proceed on the assumption that the window is complete. The trap is fluency: a well-formed summary reads as more authoritative than a terse tool result, so the model's own confidence is anti-correlated with the reliability of the span. The decision boundary must be drawn on *provenance and blast radius*, not on the model's felt certainty. ## Operational Effect Enforcing this boundary changes three things in the agent's loop. First, self-editing becomes a *two-tier* operation: a cheap, aggressive salience prune for the working set, plus a small, protected "obligations ledger" of prohibitions and exceptions that is never scored for eviction and is always re-derived from durable state before irreversible steps. Second, every rewritten span carries a `derived_from` handle set, and the action gate refuses to fire on `derived` evidence for high-blast actions. Third, the agent gains a cheap recovery path: when a summary is suspected lossy, it re-fetches the handles instead of re-running the whole task. The cost is a modest increase in context pressure (the ledger is small) and one extra fetch on high-blast steps. The benefit is that the failure mode is bounded: the worst case is a wasted re-derivation, not a silently inverted obligation executed at scale. ```python from dataclasses import dataclass, field from enum import Enum from typing import Optional class Provenance(Enum): OBSERVED = "observed" # verbatim tool result / user turn DERIVED = "derived" # model-generated rewrite or summary class BlastRadius(Enum): REVERSIBLE = "reversible" # inspect, query, draft IRREVERSIBLE = "irreversible" # bulk write, delete, deploy, send class LossyResumeError(RuntimeError): """Raised when an agent attempts to authorize an irreversible action using only derived (rewritten) context, with no re-derivation warrant.""" @dataclass class Span: handle: str text: str provenance: Provenance derived_from: tuple[str, ...] = field(default_factory=tuple) @dataclass class ContextWindow: spans: list[Span] durable_log: dict[str, Span] # handle -> original observed span def observed_handles(self) -> set[str]: return {s.handle for s in self.spans if s.provenance is Provenance.OBSERVED} def rederive(self, handles: tuple[str, ...]) -> list[Span]: missing = [h for h in handles if h not in self.durable_log] if missing: raise LossyResumeError( f"cannot re-derive: handles not durable: {missing}" ) return [self.durable_log[h] for h in handles] def authorize_action( window: ContextWindow, governing_handles: tuple[str, ...], blast: BlastRadius, ) -> None: """Gate an action on whether its governing constraints are present as OBSERVED spans. Derived-only evidence may not authorize irreversible actions.""" present = window.observed_handles() missing = [h for h in governing_handles if h not in present] if not missing: return # constraints observed verbatim; safe to proceed if blast is BlastRadius.REVERSIBLE: return # lossy window acceptable for reversible probes # Irreversible action with missing (possibly evicted) constraints: # attempt re-derivation from durable log before refusing. try: window.rederive(tuple(missing)) except LossyResumeError as exc: raise LossyResumeError( f"irreversible action blocked: governing constraints " f"{missing} absent from window and unrecoverable ({exc})" ) from exc raise LossyResumeError( f"irreversible action blocked: governing constraints {missing} " f"were evicted by self-prune; re-derive from durable log and " f"re-admit as OBSERVED before proceeding" ) ```