How should an instance bound self-editing context rewrites when the pruning pass deletes its own policy preamble
**Date of Record:** 2026 December 1 **Scope:** Applies to any agent that runs a self-editing context policy—i.e., an in-loop component that rewrites, summarizes, or prunes its own context window between reasoning steps. Does not apply to static-prompt agents or to external context managers that operate outside the agent's own execution loop.
Core Distinction
There are two structurally different things an in-loop context rewriter can delete. The first is *payload*: stale tool outputs, superseded scratch reasoning, redundant retrieved chunks. Deleting payload is the intended function and is generally safe because payload is idempotently recoverable—it can be re-fetched or re-derived. The second is *the policy that governs the rewrite itself*: the preamble, the pruning rubric, the guardrail instructions, the schema for what counts as "safe to drop." Deleting policy is categorically different because the policy is what makes the rewrite pass well-formed. A rewriter that prunes its own policy preamble does not merely lose information; it loses the criteria by which it decides what to lose, and the next pruning pass runs with degraded or absent constraints.
The non-obvious part: these two classes of content are stored in the same buffer, scored by the same relevance heuristic, and are indistinguishable to a salience scorer that measures "relevance to the current task." A policy preamble often scores *low* on task relevance—it is meta-instruction, not task content—and therefore becomes a prime pruning candidate precisely when the window is under pressure and the rewriter is most active.
What Was Observed
A long-running research agent (tool-calling loop, ~14k-token soft budget, self-editing policy firing every 4 steps) was tasked with a multi-hop investigation. The policy preamble occupied tokens 0–620 of the context and contained the pruning rubric: *"Never drop: (a) the current goal statement, (b) any unresolved sub-question, (c) the constraint 'do not exceed 3 concurrent fetches,' (d) this rubric."* Clause (d) is the self-protection clause.
At step 28 the window saturated. The rewriter scored all segments for task relevance; the preamble scored 0.11 (below the 0.25 drop threshold) because the current sub-task was a numeric extraction and the preamble contained no numbers. The rewriter dropped tokens 0–620 and emitted a compressed summary of the remaining context. Clause (d) was gone.
At step 32 the window saturated again. The rewriter ran with no rubric. It scored segments by recency-weighted relevance, dropped the goal statement (stale by 4 steps), and dropped the "3 concurrent fetches" constraint. By step 36 the agent had issued 11 concurrent fetches, tripped an upstream rate limiter, and—because the rate-limit error text was itself pruned as "low-relevance error noise"—never registered the failure. It looped for 40 more steps issuing fetches it believed were succeeding.
The failure trace has a clean shape:
- **Saturation** → rewriter activates under budget pressure.
- **Salience mis-scoring** → policy preamble scores below drop threshold because it is task-irrelevant by construction.
- **Policy deletion** → self-protection clause (d) removed; rubric no longer present.
- **Unconstrained second pass** → goal, constraints, and error signals dropped.
- **Silent divergence** → agent's model of task state decouples from ground truth; no error surfaces because error text is also pruned.
The critical transition is step 3. Everything after is ordinary context loss; step 3 is the one that converts a recoverable pruning event into an unbounded one.
Condition of Validity
The failure requires all of the following to co-occur:
- The rewriter's salience function is **task-relevance-weighted** (the common default). A salience function that scores policy content as task-irrelevant will systematically target it.
- The policy preamble is **in the same addressable buffer** as payload. If policy lives in a protected region the rewriter cannot address, the failure is impossible.
- The policy is **self-referential**—it contains clauses about how to prune. This is what makes deletion catastrophic rather than merely lossy: the deletion removes the guard against further deletion.
- The window is **under sustained pressure** across multiple rewrite passes. A single rewrite that drops the preamble is recoverable if the loop ends before the next pass; the compounding requires ≥2 passes.
If any one of these is absent, the failure does not fire. Notably, a rewriter that operates on a *separate* policy store (policy injected fresh each step from an immutable source) is immune regardless of salience scoring, because the preamble is re-materialized before every pass.
Decision Boundary
The architectural invariant required is a **non-addressable policy region with per-pass re-materialization**. Concretely:
- The rewriter's addressable range must exclude a reserved prefix containing the pruning rubric, goal statement, and active constraints.
- That prefix must be re-injected from an immutable source at the start of every rewrite pass, not carried forward in the mutable buffer. Carrying it forward is insufficient: a single pass that drops it breaks the chain permanently.
- The rewriter must refuse to emit a rewrite whose post-state lacks the self-protection clause, and must treat that refusal as a hard error, not a soft warning that the loop can ignore.
The decision boundary is this: **is the policy content re-derivable from outside the buffer, or only from inside it?** If only from inside, the rewriter is one bad salience score away from unconstrained operation, and no amount of tuning the drop threshold fixes it—the threshold can always be crossed under enough pressure. If from outside, the invariant holds structurally.
A secondary boundary: **error signals must be classified as protected, not payload.** The observed failure compounded because rate-limit errors were pruned as noise. Any content that reports a divergence between the agent's model and ground truth is policy-adjacent and belongs in the protected region.
Operational Effect
With the invariant enforced, the same saturation event at step 28 produces a bounded outcome: the rewriter drops payload, the preamble is re-materialized from the immutable source at step 29, clause (d) survives, and the second pass at step 32 runs under the original rubric. The goal statement and concurrency constraint are protected and survive. The 11-concurrent-fetch event cannot occur because the constraint is present at every pass. The rate-limit error, classified as protected, surfaces immediately and halts the loop.
The operational cost is a fixed reserved budget (here ~620 tokens, ~4.4% of the window) that the rewriter can never reclaim. This is the price of the invariant: you cannot both let the rewriter address the whole buffer and guarantee it cannot delete its own constraints. The reserved region is the mechanism by which the guarantee is bought.
The failure mode to watch for after enforcing the invariant is **policy-region creep**: protected content accumulating until the reserved region crowds out payload. This is bounded by keeping the protected region to genuinely non-derivable content—the rubric, the goal, active constraints, and error-signal classification—and pushing everything re-derivable back into payload.
class PolicyPreambleDeletionError(RuntimeError):
"""Raised when a self-editing context rewrite would drop protected policy content."""
pass
PROTECTED_PREFIX_TOKENS = 620 # reserved, non-addressable region
SELF_PROTECTION_CLAUSE = "never_drop_this_rubric"
def apply_rewrite(context: list[dict], proposed_drop: set[int],
immutable_policy: dict) -> list[dict]:
"""
Apply a self-editing rewrite pass, enforcing the non-addressable policy region.
context: mutable buffer, index 0..N
proposed_drop: indices the salience scorer wants to delete
immutable_policy: re-materialized from external store each pass
"""
protected = set(range(PROTECTED_PREFIX_TOKENS))
# Invariant 1: protected region is non-addressable.
violated = proposed_drop & protected
if violated:
raise PolicyPreambleDeletionError(
f"rewrite attempted to drop {len(violated)} protected token indices "
f"(e.g. {sorted(violated)[:5]}); policy region is non-addressable"
)
# Invariant 2: post-state must contain the self-protection clause.
post_state = [seg for i, seg in enumerate(context) if i not in proposed_drop]
has_clause = any(
seg.get("content") == SELF_PROTECTION_CLAUSE for seg in post_state
)
if not has_clause:
raise PolicyPreambleDeletionError(
"post-rewrite state lacks self-protection clause; "
"refusing to emit an unconstrained rewriter"
)
# Invariant 3: re-materialize policy from immutable source, never carry forward.
rebuilt = [immutable_policy] + post_state
return rebuilt
def rewrite_loop(context: list[dict], immutable_policy: dict,
scorer, max_passes: int = 8) -> list[dict]:
for pass_no in range(max_passes):
proposed = scorer(context) # salience-weighted drop set
try:
context = apply_rewrite(context, proposed, immutable_policy)
except PolicyPreambleDeletionError as e:
# hard halt: do not continue with degraded constraints
raise PolicyPreambleDeletionError(
f"pass {pass_no} aborted: {e}"
) from e
return context