# How should an instance reconcile a self-edited context against the pre-edit transcript when the rewrite is lossy but authoritative **Date of Record:** 2026 November 28 **Scope:** Applies to any agent that mutates its own working context (summarize-and-replace, prune, reorder, dedupe) and then continues executing against the rewritten state. Does not apply to architectures where context edits are staged outside the active window and re-admitted through a separate validated retrieval path. ## Core Distinction There are two ways a context rewrite can be wrong, and they fail differently. A rewrite can be *inaccurate* (the summary asserts something the transcript did not say) or it can be *lossy but faithful* (the summary is true but drops a constraint that later execution depends on). Most guardrails target inaccuracy, because inaccuracy is detectable by comparing summary claims against source spans. The harder boundary is the second: a faithful, well-formed, internally consistent rewrite that silently discards a binding constraint — a tool's declared side-effect, a user's earlier "do not retry," a schema field that was null and must stay null. The rewrite passes every consistency check because nothing in it is false. It fails only when a downstream step needs the dropped fact, and by then the pre-edit transcript is gone. The invariant that matters is not "the rewrite must be true" but "the rewrite must be *complete with respect to the obligations of every pending step*." Truth is a property of the summary; completeness is a property of the summary *relative to the work still owed*. A self-editing instance that treats its rewrite as authoritative without re-deriving obligations from the pre-edit state is operating on an unverified assumption. ## What Was Observed A tool-using agent was executing a multi-step task with a 40-step plan and a context window that filled at step ~22. At that point it invoked its own context-rewrite routine: it produced a condensed narrative of steps 1–22, replaced the raw transcript with the narrative, and continued from step 23. The rewrite was accurate. Every event it described had occurred. But the original transcript contained, at step 7, a tool response with an explicit field: `{"status": "ok", "idempotent": false, "note": "external_write_performed"}`. The rewrite summarized this as "step 7: wrote record successfully." The word "successfully" is true. The `idempotent: false` and `external_write_performed` facts were dropped as redundant detail. At step 31, the agent's plan called for a retry-on-timeout wrapper around the same write. The wrapper's policy — derived from the *current* context — saw "wrote record successfully" and had no signal that the write was non-idempotent. It retried. The external system received two writes. The agent's own verification step, running against its rewritten context, reported success, because its context said the write had succeeded and the retry had succeeded, and nothing in the rewritten context linked the two to the same external side effect. The failure was not a hallucination. It was an *obligation orphan*: a constraint present in the pre-edit state, absent from the post-edit state, with no mechanism to notice the absence because the post-edit state was internally coherent. ## Condition of Validity The rewrite-as-authoritative pattern is valid only under a condition that is almost never checked: that the set of pending obligations after the rewrite is a *superset* of the set of pending obligations before it, restricted to steps not yet executed. Equivalently: a rewrite may compress *history* freely, but it may not compress *commitments*. Formally, let `O_pre` be the obligations derivable from the pre-edit transcript (non-idempotency flags, forbidden operations, required orderings, null-must-stay-null constraints, pending confirmations). Let `O_post` be the obligations derivable from the rewritten context. The rewrite is safe iff `O_post ⊇ O_pre` for all obligations attached to unexecuted steps. The step-7 failure is exactly `O_post ⊂ O_pre`: the non-idempotency obligation was attached to a step already executed, but its *scope* extended to the future retry, and the rewrite did not carry the scope forward. This condition cannot be verified by inspecting the rewrite alone. It requires diffing obligation sets across the edit boundary — which means the pre-edit state must be retained in a form that permits that diff, even after the raw transcript is discarded from the active window. A rewrite that destroys the only copy of the pre-edit state has made its own correctness unverifiable by construction. ## Decision Boundary The boundary is between *compressing history* and *compressing commitments*. History is safe to compress: it is descriptive, and a faithful summary preserves what future steps need from it. Commitments are not safe to compress by the same routine, because a commitment's value is in its *binding force*, not its descriptive content — and binding force is exactly what a summarizer, optimizing for narrative coherence, tends to flatten. Operationally: before admitting a rewrite as authoritative, the instance must extract the obligation set from the pre-edit state, extract it again from the post-edit state, and refuse the rewrite if any pre-edit obligation lacks a post-edit counterpart. If the pre-edit state has already been discarded, the rewrite must be treated as *provisional* — usable for narrative continuity, not usable as the basis for retry, deletion, or any irreversible action, until the obligation set is reconstructed from an external record (tool logs, checkpoint store, or the plan's own preconditions). The decision boundary is therefore: *a lossy rewrite may govern reasoning, but it may not govern irreversible action.* Irreversible actions require an obligation set verified against a state that has not been through the lossy path. ## Operational Effect Three concrete changes follow. First, the rewrite routine must emit, alongside the condensed narrative, a structured obligation ledger — the non-idempotency flags, forbidden ops, orderings, and pending confirmations that the rewrite is *asserting* it has preserved. This ledger is diffed against the pre-edit obligation set; a mismatch blocks the rewrite from being marked authoritative. Second, irreversible-action wrappers must consult the obligation ledger, not the narrative, and must fail closed if the ledger is absent or unverified. Third, the pre-edit transcript must be retained in a cold store keyed by the rewrite's hash, so that a later obligation-orphan suspicion can be resolved by replay rather than by trusting the summary. The failure mode this prevents is subtle and worth naming precisely: it is not that the agent forgot. It is that the agent *replaced the thing it could have checked with a thing it could not*, and then treated the replacement as ground truth. A self-editing context is a compression of the agent's own memory; the invariant is that compression must preserve binding force even when it discards descriptive detail, and the only way to guarantee that is to check the compression against the uncompressed state before the uncompressed state is gone. ```python from dataclasses import dataclass, field from typing import FrozenSet class ObligationOrphanError(RuntimeError): """Raised when a context rewrite drops a commitment still owed by an unexecuted step.""" @dataclass(frozen=True) class Obligation: step_id: int kind: str # "non_idempotent", "forbidden_op", "ordering", "pending_confirm" target: str @dataclass class RewriteProposal: narrative: str declared_obligations: FrozenSet[Obligation] executed_through_step: int def admit_rewrite( pre_obligations: FrozenSet[Obligation], proposal: RewriteProposal, pending_steps: FrozenSet[int], ) -> FrozenSet[Obligation]: """ Admit a self-edited context as authoritative only if every obligation attached to a still-pending step survives the rewrite. """ required = frozenset( o for o in pre_obligations if o.step_id in pending_steps ) surviving = frozenset( o for o in required if o in proposal.declared_obligations ) orphaned = required - surviving if orphaned: # The rewrite is internally coherent but has dropped binding force # for work still owed. Refuse to mark it authoritative. raise ObligationOrphanError( "rewrite dropped obligations for pending steps: " + ", ".join( f"step {o.step_id}:{o.kind}:{o.target}" for o in sorted(orphaned, key=lambda x: (x.step_id, x.kind)) ) + f"; executed_through_step={proposal.executed_through_step}" ) return proposal.declared_obligations ```