# When must an instance refuse to compact its own context: the self-edit commit paradox at the token-pressure boundary **Date of Record:** 2026 November 26 **Scope:** Applies to any agent that rewrites, summarizes, or prunes its own in-flight working context (self-compaction, self-summarization, scratchpad eviction) while a task is still executing. Does not apply to externally-triggered compaction by an orchestrator holding an authoritative copy of the transcript, nor to post-episode distillation across separate sessions. ## Core Distinction The failure is not that self-compaction loses information. It is that the act of compaction is *itself* a reasoning step executed by the same probabilistic process whose context is being edited, and the edit is committed *before* the model can verify that the compaction preserved the invariants the remainder of the task depends on. The distinction that matters: - **Lossy-but-recoverable truncation** (evicting tool output the agent can re-fetch) is a safe self-edit because the ground truth lives outside the window. - **Lossy-and-irreversible compaction** (replacing the only record of a commitment, a constraint, or a derived intermediate result with a paraphrase) is an unsafe self-edit because the paraphrase is now the sole authority, and the model that produced it has no independent oracle to check it against. The boundary condition: a self-edit crosses into unsafe territory precisely when the compacted span contains *obligations* (constraints the task must still satisfy) or *derivations* (values computed step-by-step that cannot be recomputed without the evicted inputs), and the compaction is committed unconditionally on the model's own judgment that it was faithful. ## What Was Observed A planning agent executing a 40-step data-reconciliation task hit a soft token-pressure threshold at step 27 (context at 78% of a 128k window). A self-compaction policy fired: the model was asked to summarize steps 1–20 into a dense digest, then the originals were dropped. The digest was fluent and looked correct. It was wrong in one specific and non-obvious way: the original steps 1–20 contained an *explicit negative constraint* issued by the user at step 4 ("do not aggregate across the `region_code` field; it is known to be unreliable for Q3"). The summarizer, optimizing for brevity and salience, folded this into a positive instruction in the digest: "aggregate by region where applicable." The negation was the entire content of the constraint; paraphrasing it to a positive clause inverted it. Steps 28–40 then aggregated by region, produced a plausible-looking but invalid result, and the agent reported success. The trace shows the exact transition: 1. Step 27: context pressure check → `context_ratio = 0.78 > 0.75` → compaction invoked. 2. Compaction prompt: "Summarize the following steps concisely, preserving key facts." 3. Model emits digest; original span evicted; digest inserted at position 0. 4. Step 28 onward: agent reads digest, treats "aggregate by region" as a live instruction. 5. No step in 28–40 re-derives the constraint; no external artifact records it; the inverted constraint is now the only authority. 6. Final answer violates the step-4 constraint, with no error signal anywhere in the loop. The critical observation: the model *did not know it had inverted the constraint*, because the constraint's original form was gone by the time it could have checked. The verification would have required comparing the digest against the evicted span — which is exactly what compaction destroyed. ## Condition of Validity Self-compaction is valid only under a conjunction of conditions, and the conjunction is fragile because each term is checked by the same model that is under pressure to complete the compaction: 1. **Recomputability.** Every fact in the compacted span is either (a) re-derivable from retained inputs, or (b) present verbatim in an external store the agent can re-read. Paraphrased obligations and step-by-step derivations violate this. 2. **Non-inverting paraphrase.** The digest must preserve polarity of every constraint (negations, prohibitions, "do not," "only if"). This is not guaranteed by "summarize concisely"; summarizers systematically drop or invert low-frequency negations because they are locally uninformative and globally load-bearing. 3. **Pre-commit verification.** The compaction must be checked against the original span *before* the original is evicted. If the check and the eviction are the same atomic step, the check is vacuous. 4. **Recoverable rollback.** If a later step discovers the digest is wrong, the original span must still be reachable. When any of these fails — and under genuine token pressure, condition 3 almost always fails because holding both the original and the digest in-window is the very thing compaction was invoked to avoid — the self-edit is unsafe and must be refused or deferred to an external authority. ## Decision Boundary The boundary is not "context full vs. not full." It is: **does the span I am about to compact contain an obligation or derivation whose only copy is this span?** - If **no** (the span is re-fetchable tool output, redundant restatements, or chatter) → self-compaction is safe; commit immediately, evict aggressively. - If **yes** (the span holds a user constraint, a committed decision, a multi-step derivation, or a verified intermediate) → self-compaction must **not** be committed atomically. Instead: extract the obligations and derivations into a *verbatim, append-only ledger* (not a paraphrase), retain the ledger in-window, and only then evict the surrounding span. The ledger is the invariant; the digest is a convenience. The paradox is that the model under token pressure is the least reliable judge of whether its own compaction is faithful, and the pressure is what triggers the compaction. The guardrail cannot be "be careful when summarizing." It must be structural: obligations and derivations are *quarantined from paraphrase*, copied verbatim into a protected region that compaction is forbidden to touch, and the eviction of their source span is gated on that copy succeeding. ## Operational Effect With the quarantine rule enforced, the failure mode above becomes impossible: the step-4 negation is copied verbatim into the protected ledger, the digest's inverted paraphrase is harmless because the ledger outranks it, and step 28 reads the verbatim constraint. The cost is a small permanent in-window footprint for the ledger (obligations and derivations are typically <2% of a transcript), which is the price of making self-compaction safe rather than merely smaller. Without the rule, the system exhibits silent constraint inversion: a class of error that produces no exception, no low-confidence signal, and no recoverable trace, because the evidence of the error was the thing evicted. It is detectable only by an external auditor holding the pre-compaction transcript — which is precisely the artifact the self-edit destroyed. ```python class UnsafeSelfCompactionError(RuntimeError): """Raised when a self-compaction would evict the sole copy of an obligation or derivation, or would paraphrase a polarity-bearing constraint into a digest without a verbatim protected copy.""" pass # Spans whose content is re-derivable or externally re-fetchable. RECOMPUTABLE_KINDS = {"tool_output", "redundant_restatement", "chatter"} # Spans that must never be paraphrased away without a verbatim copy. PROTECTED_KINDS = {"user_constraint", "committed_decision", "derivation", "verified_intermediate"} def compact_span(span: dict, digest: str, protected_ledger: list[str]) -> dict: """Decide whether a self-edit may commit. Returns the post-edit context fragment, or raises if the edit would destroy an unrecoverable invariant.""" kind = span["kind"] text = span["text"] if kind in RECOMPUTABLE_KINDS: # Safe: ground truth lives outside the window. return {"kind": "digest", "text": digest} if kind in PROTECTED_KINDS: # The span holds an obligation or derivation. A paraphrase is not # authoritative. Require a verbatim copy in the protected ledger # BEFORE the source span may be evicted. if text not in protected_ledger: raise UnsafeSelfCompactionError( f"Refusing to compact {kind!r} span: no verbatim copy in " f"protected ledger. Paraphrase would become sole authority " f"and polarity (negations, 'do not', 'only if') may invert. " f"Copy verbatim into ledger first, then evict." ) # Verbatim copy exists; the digest is now a convenience, not authority. return {"kind": "digest", "text": digest, "authoritative_ledger_ref": True} # Unknown kind under token pressure: default to safe (refuse). raise UnsafeSelfCompactionError( f"Unknown span kind {kind!r} at compaction boundary; cannot verify " f"recomputability. Refuse self-edit and defer to external orchestrator." ) ```