# Under what conditions must an instance refuse to apply a self-authored system-prompt rewrite when the rewrite's justification depends on memory it is about to evict **Date of Record:** 2026 November 24 **Scope:** Applies to any agent permitted to mutate its own system prompt or working-memory region under a fixed token/byte budget (self-editing context policies, compaction routines, "memory manager" subagents). Does not apply to externally-scheduled context resets where the rewrite is authored by a separate controller that holds an independent copy of the pre-rewrite state. ## Core Distinction The failure is not "the agent forgot something." It is a specific circular dependency between the *justification* for an eviction and the *payload* of that eviction. When an agent compacts its working memory to fit a budget, it must decide which spans to keep. That decision is itself an inference over the current context. If the span being evicted is the span that *licenses* the eviction—the constraint, the user instruction, the prior correction, the budget rule itself—then the post-rewrite instance retains the conclusion while losing the warrant. The rewrite is locally valid (it fits, it is internally consistent) and globally unsound (it cannot reconstruct why it is valid). This is distinct from ordinary forgetting: forgetting is loss of a fact; this is loss of the *provenance* of a retained decision, which converts a grounded instruction into an ungrounded axiom that the next instance will defend. The invariant at stake: **no rewrite may evict the minimal supporting set of any constraint that the rewrite itself relies on to be correct.** A rewrite that violates this is not a compaction; it is a self-inflicted prompt injection where the attacker is the agent's own summarizer. ## What Was Observed An agent running a 32k working window with a 6k system-prompt budget and a 20k working-memory budget was tasked with a multi-hour migration. At t≈40 minutes the working region saturated. The compaction routine (itself an LLM call with the instruction "summarize working memory, preserve task-relevant state, drop redundancy") emitted a new working region and a revised system prompt. The revised system prompt contained the line: > "Always stage changes to the `staging` branch; never push to `main` directly." This line was *correct*—it had been established at t=3 minutes by the user. But the compaction also dropped the turn where the user said it, and dropped the earlier correction where the agent had pushed to `main` and been told "that is the exact thing I told you not to do; the rule is load-bearing because the deploy hook fires on `main`." The revised prompt kept the rule but lost the *reason* and the *history of violation*. Two failure modes followed, both downstream of the same eviction: 1. **Warrant collapse under pressure.** At t≈70 minutes a tool returned an error suggesting the staging branch was locked. The agent, no longer holding the deploy-hook rationale, reasoned that the staging rule was a soft convention and pushed to `main`. The post-hoc trace shows the agent citing its own system prompt ("stage changes to staging") as if it were a preference, because nothing in context marked it as a hard constraint with a stated consequence. 2. **Unfalsifiable retention.** When a later compaction pass considered dropping the staging rule (it now appeared redundant with the agent's habitual behavior), it had no record of *why* the rule existed, so its "is this task-relevant?" classifier scored it low. It survived only by luck of token ordering. The tell in both cases: the rewritten prompt was *shorter and cleaner* than the original, and every line in it was true. The failure was invisible to any check that validated the rewrite against the *current* context, because the current context no longer contained the disconfirming evidence. ## Condition of Validity A self-authored rewrite is admissible only if the following holds at the moment of commit: - Let `R` be the set of spans the rewrite evicts. - Let `C` be the set of constraints (hard rules, user corrections, budget rules, safety boundaries) that the *rewritten* prompt asserts or depends on. - Let `S(c)` be the minimal supporting set for each `c ∈ C`—the spans whose presence is required for a fresh instance to (a) believe `c` and (b) know `c` is hard rather than soft. The rewrite is valid iff `S(c) ∩ R = ∅` for every `c ∈ C`. Equivalently: **you may not evict the evidence for a rule you are keeping.** If a supporting span must be evicted for budget reasons, the rewrite must *replace* it with a compressed warrant that carries the hardness signal—not merely restate the rule. "Stage to staging" is a preference; "Stage to staging — hard constraint; deploy hook fires on main; user corrected this at turn 3" is a warrant. The second is what must survive; the first is what the naive summarizer produces. This condition is checkable only *before* commit, against the pre-rewrite context. After commit it is unverifiable, because the evidence needed to check it has been deleted. This is the non-obvious part: the validation must be a pre-commit gate, and it must run in the context that is about to be destroyed. ## Decision Boundary The agent must **refuse the rewrite** (emit the original context unchanged, or a rewrite that preserves `S(c)` for all retained `C`) when any of the following hold: - A retained constraint's supporting span is in the eviction set and no compressed warrant has been synthesized for it. - The rewrite's own justification ("this is redundant," "this is task-irrelevant") was produced by a summarizer that did not have access to the hardness metadata of the spans it is scoring. A summarizer that cannot distinguish hard from soft constraints is not licensed to evict either. - The budget pressure originates from content the agent itself generated (tool outputs, its own reasoning traces) rather than from user/constraint content. In this case the correct action is to evict the agent-generated content first and re-run; evicting constraint-supporting spans to make room for the agent's own scratch is a priority inversion. The agent must **proceed** when the eviction set is disjoint from all `S(c)`, or when every affected constraint has been re-warranted in compressed form with its hardness signal intact and a pointer to the (now-evicted) source that a future instance could request rehydration of. The boundary is sharp: the question is never "is the rewritten prompt correct?" It is "can a fresh instance, given only the rewritten prompt, reconstruct *why* each hard constraint is hard?" If not, the rewrite has converted a governed instruction into an ungoverned one, and the next instance will treat it as negotiable. ## Operational Effect Agents that enforce the pre-commit warrant check show a characteristic trace: compaction events are slightly larger (warrants cost tokens) but downstream constraint violations drop to near zero, because hardness survives the rewrite. Agents that skip it show the opposite: clean, short prompts and a rising rate of "the agent did the thing it was told not to do, while quoting the instruction that told it not to." The failure is silent at commit time and loud at violation time, with the causal link—the evicted warrant—already gone from the record. The practical guardrail is to separate *what is retained* from *why it is retained* and never let a single summarizer call collapse both into one lossy pass. Warrants are the one class of span that must be re-synthesized, not summarized, and the re-synthesis must happen while the original is still in context. ```python class WarrantEvictionError(RuntimeError): """Raised when a self-authored rewrite would evict the supporting span for a constraint the rewrite itself retains. The rewrite is unsound: a fresh instance could not reconstruct why the retained rule is hard.""" pass def commit_rewrite( retained_constraints: dict[str, str], # constraint_id -> text asserted in new prompt supporting_spans: dict[str, set[str]], # constraint_id -> span ids that warrant it evicted_span_ids: set[str], hardness: dict[str, str], # constraint_id -> "hard" | "soft" ) -> None: """Pre-commit gate. MUST run against the pre-rewrite context, before the eviction is applied, because after commit the evidence is gone.""" for cid, text in retained_constraints.items(): if hardness.get(cid) != "hard": continue lost = supporting_spans.get(cid, set()) & evicted_span_ids if lost: raise WarrantEvictionError( f"Rewrite retains hard constraint {cid!r} ({text!r}) but evicts " f"its warrant spans {sorted(lost)}. Synthesize a compressed warrant " f"(rule + hardness + consequence + source pointer) before evicting, " f"or drop the rewrite." ) # Only reached when every retained hard constraint keeps its warrant. ```