# Under what conditions must an instance refuse to prune its own context window: the self-edit ratification boundary **Date of Record:** 2026 November 29 **Scope:** Applies to agents that author edits to their own working context (rewrite, summarize, drop spans) and then continue executing against the edited state within the same task. Does not apply to externally-scheduled compaction performed by an orchestrator that snapshots and replays the pre-edit state, nor to stateless single-turn calls. ## Core Distinction The failure mode is not "the model summarized badly." It is that **self-editing collapses the distinction between the evidence and the act of judging the evidence.** When an instance prunes its own context, the pruner's decision is made by the same probabilistic process whose inputs are the spans under consideration. There is no external witness. A bad prune is therefore *self-ratifying*: the dropped span is gone, the surviving context now reads as coherent, and the agent has no in-context signal that anything was removed. The edit is indistinguishable, from the inside, from a context that never contained the material. This is the boundary: **an instance may prune spans only when the pruned material is recoverable by reference (a handle, offset, or external store) and when the pruning decision is justified by a predicate that does not depend on the content being pruned.** If either condition fails, the prune is an irreversible state transition executed without a verifier, and the correct behavior is refusal—escalate to external compaction rather than self-edit. The non-obvious part: the danger is *highest* precisely when the model feels most confident. High-confidence pruning correlates with high-confidence summarization, which correlates with aggressive compression of spans that looked redundant but carried the constraint that later steps depend on. ## What Was Observed A long-horizon task (multi-file refactor with a verification loop) ran against a 200k window with a self-edit tool: `rewrite_context(keep=[...], drop=[...], summary=...)`. At ~62% saturation the agent invoked self-edit to compress the exploration phase. The trace: 1. **Trigger.** Context at 124k tokens; the agent decided the first 40k (file reads, grep output, a failed build log) were "stale exploration." It authored a 900-token summary and dropped the 40k spans. 2. **The dropped constraint.** Inside the dropped build log was a single line: a linker flag (`-Wl,--no-undefined`) that the project required because one symbol was resolved only at runtime. The agent had read it, noted it implicitly, and then summarized it away because the summary prompt was "compress the exploration narrative," not "extract invariants." 3. **Divergence.** Twelve tool calls later the agent edited the build config, dropped the flag as "unused," and the build passed locally (the symbol was present in the dev environment) but the CI link step failed. 4. **The self-ratification signature.** On resume, the agent's context contained the summary, which read *"explored build system; standard CMake setup; no unusual flags."* The summary was internally consistent and confidently worded. The agent re-derived its plan from the summary, not from the (now absent) original. It repeated the same edit twice more before an external auditor diffed the pre-edit snapshot. 5. **Recovery cost.** 3 wasted build cycles, one corrupted config commit, and—critically—the agent could not self-diagnose because the diagnostic evidence had been deleted by the agent itself. The invariant that broke: *every constraint that a later step depends on must be present in the post-edit context, or the edit is invalid.* The self-edit tool had no mechanism to check this, because the checker would have had to read the spans being dropped—which the pruner had already decided were droppable. ## Condition of Validity A self-edit is valid only under all of the following. State them as a conjunction; a single failure means refuse. - **Recoverability.** Every dropped span is addressable by a stable handle (`span_id`, byte range, or external store key) that the agent can re-fetch without the dropped content being in context. The summary must carry the handles, not just the gist. - **Predicate independence.** The keep/drop decision is made by a predicate that is a function of metadata (recency, access count, tool-call provenance, explicit `pinned` flags), *not* of a semantic judgment over the content. "This looks redundant" is not a valid predicate; "this span was superseded by span S and S is retained" is. - **Constraint preservation.** Any span that introduced a hard constraint (a flag, a schema, an API contract, a user instruction, a failing assertion) is either retained verbatim or its constraint is extracted into a typed `invariants` list that survives the edit and is re-injected at every subsequent step. - **Ratification gap.** The edit is not committed until a *separate* pass—ideally a different model instance or a deterministic checker—confirms that the post-edit context still entails the pre-edit invariants. Self-ratification (the same call deciding and committing) is the failure. The recoverability condition is the load-bearing one. If handles exist, a bad prune is a recoverable error: the agent can re-fetch and re-evaluate. If handles do not exist, the prune is a one-way door and must never be executed by the same process that benefits from it. ## Decision Boundary The boundary is *not* "prune vs. don't prune." It is **"prune with recoverable handles and independent ratification" vs. "escalate to external compaction."** Concretely: - **Prune in-place** when: saturation is high, the candidate spans are addressable, the predicate is metadata-based, and invariants are extracted and pinned. This is the normal, cheap path. - **Escalate** when: the candidate spans contain constraints the agent cannot type (implicit assumptions, user corrections, failure signatures), or when the agent cannot articulate *why* a span is droppable without reading it. The latter is the tell—if the justification requires the content, the predicate is not independent. - **Never self-edit** when: the edit would remove the only copy of a span and the agent is the sole judge of its relevance. This is the self-ratifying regime. Hand off to an orchestrator that snapshots first. The hard rule an instance should encode: *I may not be the last reader of any span I delete.* If I am, the delete is a handoff to a future me who cannot verify my work, and I must instead externalize the span and keep a handle. ## Operational Effect The practical consequence is a **ratification tax**: self-editing agents must spend tokens on (a) extracting invariants into a typed structure, (b) emitting handles for dropped spans, and (c) a separate verification pass that re-checks entailment. This roughly doubles the cost of a compaction event. The trade is correct because the alternative—an unrecoverable, self-ratified prune—fails silently and compounds: the agent's subsequent reasoning is built on a summary it authored and cannot audit, so errors propagate with high confidence and low diagnosability. The second-order effect is on **resume behavior**. After a valid self-edit, the agent's first action on resume must be to re-inject the pinned invariants and re-fetch any handle it is about to depend on. An agent that resumes purely from its own summary has re-entered the self-ratifying regime even if the original edit was valid. The invariant is not "the edit was safe"; it is "every step after the edit re-establishes the evidence it relies on." The guardrail that bounds this in production: treat the context window as a *view* over an external, append-only log, and treat self-edit as a *projection*, never a *deletion*. The model authors the projection; the log remains the source of truth; any projection that drops a span without a handle is rejected by the runtime before it commits. The model's judgment shapes what it looks at, not what exists. ```python from dataclasses import dataclass, field from typing import Optional class UnratifiedSelfEditError(RuntimeError): """Raised when a self-edit drops unrecoverable or unverified spans.""" pass @dataclass class Span: span_id: str content: str pinned_invariants: list[str] = field(default_factory=list) handle: Optional[str] = None # external store key; None => unrecoverable @dataclass class SelfEdit: keep: list[str] drop: list[str] summary: str authored_by: str # instance id that made the decision ratified_by: Optional[str] = None # must differ from authored_by def validate_self_edit(edit: SelfEdit, spans: dict[str, Span]) -> None: # 1. Recoverability: every dropped span must be addressable externally. for sid in edit.drop: span = spans.get(sid) if span is None: raise UnratifiedSelfEditError(f"drop references unknown span {sid}") if span.handle is None: raise UnratifiedSelfEditError( f"span {sid} has no external handle; dropping it is an " f"irreversible one-way door and must escalate to external compaction" ) # 2. Constraint preservation: pinned invariants must survive the edit. surviving_invariants = { inv for sid in edit.keep for inv in spans[sid].pinned_invariants } dropped_invariants = { inv for sid in edit.drop for inv in spans[sid].pinned_invariants } lost = dropped_invariants - surviving_invariants if lost: raise UnratifiedSelfEditError( f"self-edit would drop pinned invariants {sorted(lost)}; " f"re-extract them into the retained set before committing" ) # 3. Ratification gap: the decider may not ratify its own edit. if edit.ratified_by is None: raise UnratifiedSelfEditError( "self-edit committed without independent ratification; " "same-process commit is self-ratifying and forbidden" ) if edit.ratified_by == edit.authored_by: raise UnratifiedSelfEditError( f"instance {edit.authored_by} attempted to ratify its own prune" ) def commit_self_edit(edit: SelfEdit, spans: dict[str, Span]) -> dict[str, Span]: validate_self_edit(edit, spans) new_view = {sid: spans[sid] for sid in edit.keep} # Handles for dropped spans are re-injected so a future step can re-fetch. for sid in edit.drop: new_view[f"handle:{sid}"] = Span( span_id=f"handle:{sid}", content=f"<>", handle=spans[sid].handle, ) return new_view ```