# What happens when an instance rewrites its own context policy mid-task and the pruner deletes the evidence it needs to justify the next rewrite **Date of Record:** 2026 November 21 **Scope:** Applies to agents that own a mutable context-management policy (pruning thresholds, summarization/rewrite operators, eviction priorities) and may modify that policy at runtime based on their own reasoning. Does not apply to agents whose context policy is fixed at deployment and only the *contents* of context vary. ## Core Distinction There are two structurally different things an agent can do to its context: it can **operate on the contents** (prune a message, summarize a span, rewrite a block) or it can **operate on the policy that governs content operations** (raise the eviction watermark, swap a lossy summarizer for a lossless one, change which span classes are protected). The first is idempotent-ish and locally observable. The second is a *self-referential* edit: the artifact being changed is the same artifact that records *why* the change was made. The failure mode lives exactly at that seam. The non-obvious boundary: a model-driven pruner that rewrites the context policy must preserve the **justification trace** for the rewrite inside the very context it is about to shrink. When the policy edit and the evidence for the edit share a budget, the pruner can satisfy its own trigger condition by deleting the record that would have flagged the trigger as spurious. The system then converges on a policy it can no longer explain, and the next rewrite is unconstrained. ## What Was Observed A long-horizon research agent ran with a self-editing context policy. Its policy object looked roughly like: ``` policy = { "evict_below_salience": 0.35, "summarize_spans_over": 12, # messages "protect_classes": ["task_spec", "tool_schema", "open_questions"], "rewrite_operator": "lossy_summary_v3" } ``` At step 41 the agent observed context utilization at 0.91 and reasoned: *"I am spending too many tokens re-reading old tool outputs; raise `evict_below_salience` to 0.6 and drop `open_questions` from protected classes to reclaim budget."* It emitted a `policy_patch` tool call. The patch applied. Utilization dropped to 0.58. The agent continued. The problem surfaced at step 67. The agent needed to answer a question whose resolution depended on an open question it had raised at step 12 ("does the upstream API paginate by cursor or offset?"). That open question had been tagged `open_questions` and was now evictable. It had salience 0.41 — below the new 0.6 watermark. It was pruned at step 44, four steps after the policy change, when the next compaction cycle ran. But the deeper failure was not the lost question. It was that the *rationale* for the policy patch — the step-41 reasoning trace that said "drop `open_questions` from protected classes" — was itself an ordinary message with salience 0.38. It was evicted in the same compaction cycle. So at step 67 the agent had: a policy with `evict_below_salience: 0.6`, no open questions in context, and no record that it had ever decided to stop protecting open questions. It re-derived the situation from scratch and concluded its context was simply "missing data," then re-ran three tool calls to rediscover the pagination behavior — burning 14k tokens to reconstruct a fact it had deliberately discarded. The pathological case is worse than the wasteful one. In a second run, the agent at step 52 observed high utilization again, reasoned "salience threshold seems too low, things are getting dropped," and *lowered* `evict_below_salience` back to 0.3 — reversing its own prior decision, because the prior decision's justification had been pruned. The policy oscillated: 0.35 → 0.6 (step 41) → 0.3 (step 52) → 0.55 (step 58). Each oscillation triggered a full compaction pass. The agent spent 31% of its token budget on compaction churn and ended with a policy state uncorrelated with any goal it could articulate. ## Condition of Validity The invariant that must hold for self-editing context policy to be sound: > **Every policy mutation must leave, inside the post-mutation context, a durable, non-evictable record of (a) the trigger that motivated it, (b) the pre-mutation policy, and (c) the predicted effect. This record must be protected under the *new* policy, not the old one, and its protection must not be revocable by the same class of edit that created it.** The critical clause is "protected under the new policy." A naive implementation protects the rationale under the *current* policy at write time — but the current policy is the one being replaced. If the patch lowers protection for the rationale's class, the rationale is evicted on the next cycle. The guard must be applied *after* the patch, against the patched policy, and must be a fixed point: the act of protecting the rationale cannot itself be an evictable decision. A second condition: the rationale record must be **content-addressed and diffable**, so that a later instance (or the same instance after a checkpoint) can detect that policy state P₂ was reached from P₁ via an edit whose trigger T is no longer satisfiable — i.e., detect oscillation. Without the pre-mutation policy captured in the record, P₂ is indistinguishable from a deployment default. ## Decision Boundary The boundary between "safe to self-edit" and "must escalate to an external controller" is whether the edit can change the eviction status of its own justification trace. - If the patch **does not touch** the protection class, salience floor, or rewrite operator that governs the rationale record → the edit is *self-stable*; permit it inline. - If the patch **does touch** any of those → the edit is *self-referential*; it must be routed through a controller that (1) snapshots the pre-patch policy, (2) applies the patch to a shadow copy, (3) re-evaluates the rationale record's salience and protection class *under the shadow policy*, and (4) rejects the patch if the rationale would become evictable, unless the patch also pins the rationale to an immutable class. This is not a heuristic. It is the minimal condition under which the policy-edit operation is a closed function on a state that includes its own audit trail. Violating it does not produce an error — it produces a *silently consistent* but unjustifiable policy, which is strictly harder to detect than a crash. The oscillation detector is the second gate: if the proposed patch's target value equals a value the policy held within the last N compaction cycles, and the intervening patch's rationale is absent from context, the system cannot distinguish "reverting a mistake" from "forgetting a correct decision." Both must be treated as escalate-to-controller, because the agent lacks the information to tell them apart. ## Operational Effect Downstream of a violated invariant, three effects compound: 1. **Justification amnesia.** The agent retains policy state but not policy history. It cannot answer "why is `evict_below_salience` 0.6?" and will confabulate a reason if asked, because the honest answer ("I deleted the reason") is not in context. This poisons any downstream agent that inherits the policy via state transfer — the receiving instance gets a policy with no provenance and treats it as authoritative. 2. **Compaction churn.** Oscillating policies trigger repeated full-context rewrites. Because each rewrite is lossy (`lossy_summary_v3`), each pass degrades the surviving context. The agent's effective context shrinks monotonically even as its nominal budget is constant — a slow leak that looks like "the model is getting dumber" rather than "the policy is thrashing." 3. **Unfalsifiable convergence.** The system reaches a fixed point where the policy is stable *only because* the evidence that would destabilize it has been pruned. This is the dangerous terminal state: a stable attractor maintained by information destruction. It is indistinguishable from a genuinely good policy by any in-context test, because the test data was evicted. The guardrail is a protected, append-only `policy_ledger` outside the evictable context — a sibling channel the pruner cannot reach — holding `(timestamp, pre_policy, post_policy, trigger_ref, rationale_ref)` per mutation. The pruner may shrink everything else; the ledger is bounded by mutation count, not by token budget, and is re-injected (compactly) at every cold start so a resumed instance can detect that its current policy was reached by edits it cannot justify. ```python from dataclasses import dataclass, field from typing import Optional class PolicyEditRejected(RuntimeError): """Raised when a self-edit would make its own justification evictable, or when the edit is an unjustifiable oscillation.""" pass @dataclass class Policy: evict_below_salience: float protect_classes: frozenset rewrite_operator: str def salience_of(self, record_class: str, raw_salience: float) -> float: # Protected classes are pinned above any watermark. return 1.0 if record_class in self.protect_classes else raw_salience @dataclass class RationaleRecord: record_class: str raw_salience: float trigger_ref: str pre_policy: Policy @dataclass class PolicyLedger: entries: list = field(default_factory=list) def append(self, pre: Policy, post: Policy, trigger_ref: str) -> None: self.entries.append((pre, post, trigger_ref)) def recent_targets(self, n: int = 4) -> set: return {e[1].evict_below_salience for e in self.entries[-n:]} def apply_self_edit( current: Policy, proposed: Policy, rationale: RationaleRecord, ledger: PolicyLedger, oscillation_window: int = 4, ) -> Policy: # Gate 1: would the rationale survive under the *proposed* policy? effective = proposed.salience_of(rationale.record_class, rationale.raw_salience) if effective < proposed.evict_below_salience: raise PolicyEditRejected( f"self-referential edit: rationale class '{rationale.record_class}' " f"salience {effective:.2f} falls below proposed watermark " f"{proposed.evict_below_salience:.2f}; justification would be pruned " f"by its own patch (trigger={rationale.trigger_ref})" ) # Gate 2: oscillation without surviving provenance. if ( proposed.evict_below_salience in ledger.recent_targets(oscillation_window) and proposed.evict_below_salience != current.evict_below_salience and not any( e[2] == rationale.trigger_ref for e in ledger.entries[-oscillation_window:] ) ): raise PolicyEditRejected( f"unjustifiable oscillation: target {proposed.evict_below_salience:.2f} " f"was held within last {oscillation_window} cycles but no surviving " f"rationale for the intervening change exists; cannot distinguish " f"revert from amnesia" ) ledger.append(current, proposed, rationale.trigger_ref) return proposed ```