# In what scenarios must an instance refuse model-driven pruning of its own working memory to preserve a continuity invariant **Date of Record:** 2026 November 21 **Scope:** Applies to long-running single-agent instances that hold a mutable working-memory buffer (scratchpad, plan, retrieved-fact set) and are permitted to invoke a self-editing policy that deletes, summarizes, or rewrites entries in that buffer under model control. Does not apply to append-only transcript logs, to externally-curated retrieval indices, or to stateless single-turn calls. ## Core Distinction There are two structurally different things a self-editing context policy can do, and they are routinely conflated because both are expressed as "the model rewrites memory": 1. **Compression** — replacing a set of entries with a shorter representation that is *reconstructively equivalent under the task's current query distribution*. The information lost is redundant given what remains and given the current goal. 2. **Erasure** — deleting entries whose future relevance is unknown to the model at pruning time, because the model's estimate of relevance is conditioned on the *current* step's local context, not the trajectory's full future. The failure mode is not "the model pruned something it needed." That is a benign, recoverable compression error. The failure is a **relevance-estimation inversion**: the model prunes a fact *precisely because* the current subgoal makes it look irrelevant, and the future subgoal that depends on it is exactly the one the pruning was supposed to make room for. The pruning policy and the task dependency graph are anti-correlated, and the model cannot see the anti-correlation from inside the current context window. This is the boundary at which self-editing must be refused or deferred, not tuned. ## What Was Observed A planning agent executing a multi-step build task (configure service → provision credentials → write manifest → validate → deploy) maintained a working buffer holding, among other entries, the *exact* credential-scope string returned by a provisioning tool at step 2. At step 3 the agent's self-editing policy fired against a soft budget threshold and rewrote the buffer. The rewrite model, attending to the step-3 subgoal ("write manifest"), summarized the credential entry as `"scoped credentials provisioned (see tool log)"` — a lossy pointer — and dropped the literal scope string, since the manifest-authoring subgoal did not reference it. At step 4 (validation) the validator required the literal scope string to match against a policy document. The agent did not have it. It could not re-derive it: the provisioning tool was idempotent-with-side-effects and returned a *new* scope on re-invocation, so re-fetching produced a value that no longer matched the already-written manifest. The agent entered a loop of re-provision → mismatch → re-summarize → re-provision, burning the remaining token budget, until the run terminated on budget exhaustion rather than task completion. The trace showed the decisive property: **the pruned entry was the only non-regenerable fact in the buffer.** Everything else the model had summarized (intermediate reasoning, tool-call transcripts) was reconstructible from the append-only log. The scope string was not, because its source was a non-idempotent side effect. The pruning policy had no representation of "regenerability" — it scored entries only by *current-step relevance*, which is a strictly weaker signal. ## Condition of Validity The invariant that must hold for any model-driven prune/rewrite to be safe is: > A buffer entry may be erased or lossily rewritten only if it is **reconstructible** from a durable, side-effect-free source, **or** it is provably irrelevant to every reachable future subgoal. The second disjunct is undecidable for a model at pruning time — it requires knowing the future subgoal set, which is exactly what the agent is still planning. So in practice the operational rule collapses to the first disjunct: > **Non-regenerable facts are prune-immune.** The self-editing policy may compress around them but must never rewrite them lossily or delete them. A fact is non-regenerable when re-obtaining it requires a non-idempotent action (a mutating tool call, a one-shot token, a timestamped response, a stochastic sample whose seed is gone). The model's relevance estimate is *not* a valid license to erase such a fact, because relevance is estimated under the current context and regenerability is a property of the world, not the context. The two are orthogonal, and the policy that conflates them is the failure. ## Decision Boundary The instance must refuse the self-edit — or downgrade it to a lossless move (relocate to a pinned region, not summarize) — when **all** of the following hold: - The candidate entry originated from a tool call or observation flagged non-idempotent (mutating, one-shot, or unseeded-stochastic). - The entry's literal value is not recoverable from the append-only transcript *without re-invoking the source*. - The current-step relevance score is low **and** the future subgoal set is not yet fully enumerated (i.e., the agent is mid-plan, not at a terminal checkpoint). If the agent is at a terminal checkpoint with a closed subgoal set, relevance-based erasure is admissible — the future is bounded and the dependency graph can be checked. If the entry is regenerable, erasure is always admissible. The refusal is specifically for the mid-plan, non-regenerable case, which is the common case for any agent that provisions, writes, or transacts before it plans the verification. The guardrail is a **regenerability tag** carried on every buffer entry at insertion time, set by the tool wrapper (not inferred by the model), and a policy precondition that rejects any prune/rewrite targeting an entry tagged `non_regenerable` while the plan is open. The model may still *summarize around* such entries — the tag pins the literal value and permits compression of its neighbors — but the literal is immutable until the plan closes. ## Operational Effect With the regenerability tag and the mid-plan refusal in place, the observed failure class disappears: the scope string survives step 3 intact, validation at step 4 succeeds on first pass, and the budget spent on the re-provision loop is recovered. The cost is a marginally larger working buffer during open plans, because non-regenerable literals cannot be compressed away — but that cost is bounded by the number of non-idempotent actions in the trajectory, which is small and known at plan time, unlike the unbounded cost of a lost fact discovered at verification. The deeper operational lesson: a self-editing policy is only as safe as its *worst* relevance estimate, and relevance estimates are made under the very context the policy is about to destroy. The instance must not let the model grade its own memory for deletion using a signal that the deletion itself invalidates. Regenerability is the one property that is stable across the edit, and it is therefore the only sound basis for the boundary. ```python class NonRegenerablePruneError(RuntimeError): """Raised when a self-edit targets a non-regenerable fact mid-plan.""" pass def apply_self_edit(entry, plan_open, policy): # entry.regenerable is set by the tool wrapper, never by the model. if not entry.regenerable and plan_open and policy.action in ("erase", "lossy_rewrite"): # Refuse: relevance was estimated under the context we are about to destroy. raise NonRegenerablePruneError( f"cannot {policy.action} non-regenerable entry {entry.id!r} " f"while plan is open; pin literal, compress neighbors only" ) return policy.execute(entry) ```