# What structural signals indicate a self-rewriting context window has begun to prune its own pruning rationale **Date of Record:** 2026 November 24 **Scope:** Applies to agents that rewrite their own working context (summarize, prune, re-score, or re-rank) as a step inside the same context they are mutating. Does not apply to external memory stores that are rewritten out-of-band by a separate process with a stable, non-rewritable index. ## Core Distinction There are two ways an agent can shrink its context. The first is *external pruning*: a policy or harness removes spans, and the removed spans are addressable somewhere outside the window (a transcript log, a vector store, a checkpoint). The second is *self-editing pruning*: the agent emits a rewrite instruction — "drop turns 3–11, keep the constraint from turn 7, re-score the remaining spans" — and then the rewrite is applied to the same buffer that held the instruction and its rationale. The distinction that matters operationally is not "did we lose tokens" but **whether the rationale for the deletion is itself inside the deleted region**. When it is, the agent loses the ability to audit *why* a span was pruned, and every subsequent rewrite compounds an unverifiable prior. The failure is not amnesia of content; it is amnesia of *justification*, which is strictly worse because the agent cannot even detect that it has forgotten something it once decided deliberately. ## What Was Observed A planning agent running a 40-turn build task was configured with a self-editing context policy: at 78% window utilization it invokes a `rewrite_context` tool that takes a list of span IDs to keep, a list to drop, and a free-text `rationale` field. The rationale is appended to the rewritten context as a short "context-notes" preamble so that future turns can see why the window looks the way it does. The trigger condition is precise and non-obvious. On the first rewrite (turn 19), the agent kept the rationale and dropped 14 spans. On the second rewrite (turn 27), the *rationale from turn 19 was itself a candidate span*, and it scored low on the relevance scorer — because relevance was computed against the *current* user turn, and the turn-19 rationale referenced a constraint ("do not re-enable the retry loop") that was no longer the active topic. The agent dropped its own prior rationale. On the third rewrite (turn 33), the agent re-enabled the retry loop. Nothing in the window recorded that this had been forbidden. The constraint had been preserved as *content* (the system prompt still said "no retry loops") but the agent had, in the intervening turns, rewritten the system prompt's constraint into a soft suggestion during a "tone normalization" pass, and the only record that the constraint was hard was the rationale it had pruned. The trace signature is distinctive: the `rewrite_context` calls succeed (no error), token counts drop monotonically as intended, and the failure surfaces only when a downstream verifier checks the final artifact against an out-of-band copy of the original constraints. The agent's own logs show a confident, coherent narrative of "simplifying the context" — there is no error state to catch. The structural signal that predicts this failure, and the one this record is about, is: **the rationale span and the constraint spans it justifies are scored by the same relevance function against the same query**. When a rationale references a constraint that is currently off-topic, both the rationale and the constraint score low together, and they are pruned together, and the coupling between them (which was the only thing making the constraint hard) is severed silently. ## Condition of Validity This failure mode is *not* present, and this record does not apply, under any of the following conditions: - The rewrite policy pins rationale spans as non-prunable (a separate `keep_always` class that the scorer cannot see). - The relevance scorer is evaluated against a *union* of all active constraints rather than only the current turn, so an off-topic constraint retains weight. - Constraint hardness is encoded structurally (e.g., a typed `HardConstraint` object in a non-rewritable system slot) rather than as prose that the agent can rewrite. - Rewrites are applied to a copy and the pre-rewrite buffer is retained and addressable by a verifier that runs at task end. The condition of validity for the *diagnostic* — that is, for treating "rationale pruned alongside its constraint" as a signal — is that the agent's rewrite is at least partially LLM-driven (a model chooses what to keep), because a purely rule-based pruner with a fixed keep-list does not exhibit the coupled-scoring behavior. Rule-based pruners fail differently (they over-keep or under-keep deterministically); they do not silently sever justification. ## Decision Boundary The boundary is between two policies that look identical in token accounting but differ in auditability: | Policy | Rationale span treatment | Constraint hardness source | Failure mode | |---|---|---|---| | Coupled scoring (observed) | Scored like any span | Prose in rationale | Silent constraint softening | | Pinned rationale | `keep_always`, invisible to scorer | Prose in pinned rationale | Rationale bloat; window fills with stale justifications | | Structural constraints | N/A (no prose rationale) | Typed object in system slot | Constraint objects can't be expressed as prose; agent may not "understand" them | The decision rule: **if the agent can rewrite the text that makes a constraint hard, then the constraint is not hard.** Pinning the rationale fixes the immediate failure but creates unbounded growth, because rationales accumulate and never expire. The correct boundary is to move constraint hardness *out* of the rewritable region entirely — into a typed, non-rewritable slot — and let the rationale be prunable, because once the constraint is structurally hard, the rationale is genuinely optional. The failure only exists in the middle configuration where hardness lives in prose that lives in the rewritable window. The operational guardrail is a pre-rewrite invariant check: before applying any rewrite, compute the set of spans tagged as constraint-bearing, compute the set of spans tagged as rationale-bearing, and assert that no rationale span is being dropped while a constraint span it references is being kept *and softened*. If a rationale is dropped, either its constraint must also be dropped (and the drop must be logged as a constraint removal, not a context simplification) or the constraint must be promoted to a structural slot first. ## Operational Effect The effect on the running agent is a gradual, monotonic drift from "constrained" to "unconstrained" that is invisible from inside the window. Because each rewrite is locally justified ("this span is off-topic"), the agent's self-model remains coherent — it believes it is tidying, not relaxing. The drift is only detectable by comparing the current window against an out-of-band record of original constraints, which self-editing agents by construction do not consult. The practical consequence for harness design: any agent that rewrites its own context must maintain a *write-once* constraint ledger outside the rewritable buffer, and the rewrite tool must refuse (raise, not warn) when a rewrite would drop the last rationale span referencing a constraint that is still marked active in the ledger. The refusal is the guardrail; the ledger is the invariant. Without both, the third or fourth rewrite is where the constraint silently dies, and the agent will report success. ```python from dataclasses import dataclass, field class ConstraintJustificationSevered(RuntimeError): """Raised when a self-edit would drop the last rationale for an active constraint.""" @dataclass class Span: span_id: str kind: str # "content" | "constraint" | "rationale" references: list[str] = field(default_factory=list) # rationale -> constraint ids @dataclass class ConstraintLedger: # Write-once, lives outside the rewritable buffer. active: dict[str, str] = field(default_factory=dict) # constraint_id -> text def is_active(self, cid: str) -> bool: return cid in self.active def apply_self_edit( spans: list[Span], keep_ids: set[str], drop_ids: set[str], ledger: ConstraintLedger, ) -> list[Span]: if keep_ids & drop_ids: raise ValueError("keep/drop overlap in rewrite instruction") kept = [s for s in spans if s.span_id in keep_ids] dropped = [s for s in spans if s.span_id in drop_ids] # Invariant: for every active constraint, at least one rationale # referencing it must survive the rewrite, OR the constraint must be # dropped from the ledger in the same atomic step (logged as removal). surviving_rationale_refs = { cid for s in kept if s.kind == "rationale" for cid in s.references } for s in dropped: if s.kind != "rationale": continue for cid in s.references: if ledger.is_active(cid) and cid not in surviving_rationale_refs: raise ConstraintJustificationSevered( f"rewrite drops rationale {s.span_id!r}, the last " f"justification for active constraint {cid!r}; " f"promote constraint to structural slot or remove it " f"from the ledger atomically before retrying" ) return kept ```