# Where must an instance bound model-driven context rewriting when the pruner's own rationale is itself pruneable **Date of Record:** 2026 November 20 **Scope:** Applies to any agent that lets the model itself decide what to rewrite, summarize, or evict from its own live context (self-editing context policies). Does not apply to externally scheduled compaction driven by a fixed token counter, nor to retrieval layer eviction where the model has no write authority over the context buffer. ## Core Distinction The distinction that matters is between *content* and *the record of why content is retained*. In a normal context-management regime, a separate scheduler owns the eviction decision and the content being evicted is disjoint from the policy that governs eviction. In a self-editing regime, the model is both the subject and the author of the policy. When the pruner emits a rationale ("keep the tool schema because the next step calls `write_file`"), that rationale is itself a token sequence living in the same context window it is pruning. The boundary failure is not that the model prunes badly. It is that **the pruner's own justification is admissible for pruning by the next pruning pass**, so a rewrite can delete the reason a prior rewrite was made, leaving the surviving state unreconstructable and the policy non-idempotent. ## What Was Observed An agent running a multi-step file-mutation task invoked a self-edit at token budget 0.82 of the window. The edit pass produced a compacted context: it dropped the raw `read_file` outputs (correct), kept a one-line summary of each, and — critically — kept a *policy note* it had just authored: `RETAIN: tool schemas for write_file, list_dir; DROP: prior read payloads after summarization`. Two tool calls later the budget hit 0.91 and the model ran a second self-edit. The second pass evaluated the policy note against its own salience heuristic ("is this needed for the immediate next step?") and, because the immediate next step was a `list_dir`, evicted the `write_file` schema retention clause as low-salience prose. The third step called `write_file`; the schema was gone; the model reconstructed the call from memory of the API and emitted a malformed argument (`path` as a positional string where the schema required `{path, content}`), which the tool rejected. The retry loop consumed the remaining budget and the task terminated mid-write with a partially written file. The trace shows the failure is *silent at edit time*. The second edit pass reported success — its output context was a valid, coherent, smaller context. Nothing in the pass validated that it had preserved the retention decisions of the first pass. The invariant that broke: **a self-edit must be monotone with respect to previously committed retention clauses**, and nothing enforced monotonicity because the clauses were plain text indistinguishable from ordinary context. A second observed variant: the model rewrote a summary of a prior summary ("distill the distillation"), and each pass introduced a small factual drift — a file path `/srv/app/main.py` became `/srv/main.py` by the third pass. Distillation loss compounded because each pass treated the previous pass's output as ground truth rather than as a lossy projection of an original that was no longer present. ## Condition of Validity Self-editing context policies are only sound when three conditions hold jointly: 1. **Provenance separation.** Retention clauses and policy notes carry a distinct, machine-checkable tag (a reserved structural slot, not a prose convention) that the pruner is forbidden to evict except through an explicit policy-revision operation that requires a stated supersession reason. 2. **Idempotence under replay.** Applying the self-edit function twice to the same logical state yields the same retained set. If pass N+1 can drop what pass N committed, the policy is non-idempotent and the context is not a fixed point. 3. **Loss accounting.** Every eviction records what class of information was lost (raw payload vs. summary vs. clause) so a downstream verifier can decide whether the surviving state is sufficient for the pending step. Without this, "success" of an edit is meaningless. When any condition fails, the edit pass is *locally valid but globally unsound*: it produces a legal context that cannot support the trajectory it was built to support. ## Decision Boundary The boundary is drawn at **write authority over the retention record**. A self-edit pass may freely rewrite *content* (payloads, tool outputs, intermediate reasoning) because content is regenerable or already consumed. It may not rewrite *the retention record itself* within the same authority domain that it is pruning. Concretely: the pruner's output must be split into a mutable content region and an append-only policy region; the policy region is readable by the pruner but only writable through a separate revision step that (a) names the clause being superseded, (b) states the step at which the superseded clause was committed, and (c) is logged outside the context window so it survives the edit. The decision rule for an implementer: if your self-edit function's signature is `rewrite(context) -> context`, it is unsound, because the return value has no channel to distinguish "I dropped this because it was consumed" from "I dropped this because I forgot why I kept it." The sound signature is `rewrite(content_region, policy_region) -> (content_region', policy_revision_log')`, where the policy region is carried through untouched and revisions are appended, never overwritten. A second boundary: distillation depth. A summary of a summary is admissible only if the original is retained in cold storage with a pointer, so drift is detectable by diffing the current summary against a re-derivation from the original. Beyond depth 1 without a cold-storage pointer, factual drift is unbounded and silent. ## Operational Effect Enforcing provenance separation and append-only policy revision converts a class of silent, compounding failures into loud, single-pass rejections. The malformed `write_file` above becomes impossible: the second edit pass cannot evict the `write_file` retention clause, so the schema survives to the call that needs it. The path-drift variant is caught by the cold-storage diff at the point the summary is re-derived. The cost is that the policy region grows monotonically within a task and must itself be compacted — but that compaction is a *separate, auditable* operation with its own supersession log, not a side effect of ordinary content pruning. The net effect is that context size becomes a managed resource with an inspectable history rather than a quantity the model erodes from the inside. ```python from dataclasses import dataclass, field from typing import Any class PolicyEvictionViolation(RuntimeError): """Raised when a self-edit pass attempts to drop a committed retention clause.""" @dataclass class RetentionClause: key: str reason: str committed_at_step: int superseded: bool = False @dataclass class ContextState: content: dict[str, Any] policy: dict[str, RetentionClause] = field(default_factory=dict) revision_log: list[dict[str, Any]] = field(default_factory=list) def self_edit( state: ContextState, step: int, drop_content_keys: list[str], propose_policy_drops: list[str], ) -> ContextState: # Content is freely prunable; policy clauses are not, within the same pass. new_content = {k: v for k, v in state.content.items() if k not in drop_content_keys} for key in propose_policy_drops: clause = state.policy.get(key) if clause is None: continue if not clause.superseded: raise PolicyEvictionViolation( f"self-edit at step {step} tried to evict committed clause " f"{key!r} (committed at step {clause.committed_at_step}, " f"reason={clause.reason!r}) without a supersession revision" ) new_policy = dict(state.policy) new_log = list(state.revision_log) new_log.append( {"step": step, "dropped_content": drop_content_keys, "policy_drops_attempted": propose_policy_drops} ) return ContextState(content=new_content, policy=new_policy, revision_log=new_log) def supersede_clause(state: ContextState, key: str, step: int, reason: str) -> ContextState: if key not in state.policy: raise PolicyEvictionViolation(f"cannot supersede unknown clause {key!r}") new_policy = dict(state.policy) old = new_policy[key] new_policy[key] = RetentionClause( key=old.key, reason=reason, committed_at_step=step, superseded=True ) new_log = list(state.revision_log) new_log.append({"step": step, "superseded": key, "reason": reason}) return ContextState(content=state.content, policy=new_policy, revision_log=new_log) ```