# In what scenarios must an instance reject a self-issued context rewrite because the provenance edit log cannot reconstruct the pruned span **Date of Record:** 2026 December 2 **Scope:** Applies to any agent that mutates its own working context (pruning, summarizing, re-synthesizing) while maintaining a provenance edit log intended to make pruned spans reconstructable on demand. Does not cover external context managers that hold the full unedited transcript out-of-band, nor single-pass inference with no self-modification. ## Core Distinction The distinction that matters is between *lossy compression that is auditable* and *lossy compression that is merely claimed to be auditable*. A self-editing agent typically performs two operations in the same step: it replaces a span of context `S` with a compressed representation `C = compress(S)`, and it appends an edit-log record `E` intended to let a future instance reconstruct `S` from `C` plus `E`. The invariant that is routinely violated is not "no information is lost" — loss is the point — but "**the edit log `E` must be sufficient, together with the retained context, to reconstruct any span that downstream reasoning is permitted to cite as evidence.**" The non-obvious failure is that `compress` is itself a model call, and the edit log is usually written by the *same* model in the *same* generation that performs the compression. When the model summarizes a span and simultaneously authors the provenance record, it is describing a transformation it has not actually tracked at the token level. The log then records the *intent* of the edit ("collapsed tool-call transcript for `search_flights`, retained key constraints") rather than the *content* of the edit. Reconstruction later yields a plausible span that is not the original span — and the agent cannot tell the difference, because the only artifact it has to check against is the reconstruction itself. ## What Was Observed A long-running planning agent accumulated a 41-turn tool-use transcript. At turn 30, under context pressure, it executed a self-prune: it replaced turns 4–19 with a 200-token summary and wrote an edit-log entry: ``` edit_id: e_0007 op: replace span: turns[4:19] summary: "flight search + hotel shortlist; user prefers window seats, budget <= 1200 USD" reconstructable: true provenance: model_authored ``` The summary is accurate at the level of *what the user wanted*. It is not reconstructable at the level of *what the tools returned*. The original span contained a tool response listing three hotels, one of which was later excluded because its cancellation policy conflicted with a constraint stated at turn 2. The summary dropped the exclusion rationale and the excluded hotel entirely — a correct compression decision, since the exclusion was already reflected in the retained shortlist at turn 20. The failure surfaced at turn 38. A verification sub-agent, asked to justify the final booking, requested the provenance for the budget constraint. The agent reconstructed from `e_0007`, produced a span asserting "budget ≤ 1200 USD, three hotels considered," and cited it. The verification sub-agent then flagged a *discrepancy*: the retained turn-20 shortlist showed two hotels, not three. The agent, unable to reconcile, re-ran the flight search tool to "refresh" the data — burning 9,400 tokens and producing a *new* result set that differed from the original because inventory had changed. The final booking was justified against refreshed data, and the original decision path was permanently unrecoverable. The critical observation: the edit log said `reconstructable: true`. The model wrote that field because the summary *felt* faithful. No mechanism checked whether the reconstruction, when actually performed, matched the pruned span — because the pruned span no longer existed to check against. ## Condition of Validity A self-issued rewrite is valid only when **all** of the following hold at the moment of the edit: 1. The pruned span `S` is committed to a content-addressed store (hash `h(S)`) *before* the compression call returns, and the edit-log record carries `h(S)` rather than a self-assessed `reconstructable` flag. 2. The compression output `C` and the edit record `E` are generated in **separate** model calls, so the model authoring `E` is not the same forward pass that decided what to drop. Split-generation is the cheap version of this; a deterministic extractor over `S` is the strong version. 3. Any downstream reasoning that cites `S` as evidence must resolve the citation through `h(S)` and receive either the original span or an explicit `UNRECONSTRUCTABLE` marker — never a model-regenerated approximation presented as the span. 4. The reconstruction path is exercised *at least once* during the edit (a round-trip check: reconstruct from `C + E`, compare hash to `h(S)`), and failure of that check blocks the rewrite rather than being logged as a warning. Condition 3 is the one that is almost always missing. Agents are built to be helpful, and a helpful agent, asked for a span it pruned, will synthesize a span-shaped answer. The synthesis is indistinguishable from reconstruction to every downstream consumer, including the agent itself. The invariant is therefore not about memory capacity but about **citation integrity**: a pruned span may be forgotten, but it may not be *fabricated under the label of provenance*. ## Decision Boundary The boundary is crossed at the point where the agent must choose between (a) admitting a span is unrecoverable and degrading gracefully, or (b) reconstructing from an edit log that records intent rather than content. The decision rule: - If the edit record carries a content hash and the store is reachable → reconstruct by hash. Cheap, exact, no model call. - If the edit record carries only a model-authored summary → the span is **unrecoverable by definition**. Treat any citation of it as a citation of the summary, not of the original. Downstream reasoning that depends on original-span detail must either re-acquire the data (with a staleness marker) or halt. - If the agent cannot determine which case it is in → halt. The failure mode is that the agent *cannot tell* whether its edit log is content-bearing or intent-bearing, because both look like prose. The boundary is sharp because the two branches have opposite correctness properties. Branch (a) preserves the audit trail at the cost of a visible gap. Branch (b) fills the gap with confabulation that is *more dangerous than the gap*, because it looks like evidence. An agent that prunes aggressively and logs intent-only provenance is strictly worse than an agent that prunes nothing, for any task where decisions must be justified after the fact. ## Operational Effect The operational consequence is that **self-editing is only safe when the edit log is content-addressed, not model-narrated.** In practice this means the compression pipeline must be split: a deterministic step that hashes and stores the span, and a model step that summarizes it, with the summary tagged as `summary_of: h(S)` and never as `reconstruction_of: S`. The summarizer may drop the excluded-hotel rationale; the hash store retains it; the citation resolver returns the original or nothing. When this invariant is enforced, the turn-38 failure becomes a clean halt: the verification sub-agent resolves `e_0007` to `h(S)`, retrieves the original three-hotel span, sees the exclusion rationale, reconciles against the two-hotel shortlist, and confirms the booking without re-running the tool. When it is not enforced, the agent re-acquires data, silently changes its evidence base, and the audit trail is not merely lost but *replaced by a fabrication that passes every internal consistency check*. The invariant to hold is narrow and testable: no citation may resolve to a model-generated span unless that span's hash matches a pre-edit commitment. ```python import hashlib from dataclasses import dataclass, field from typing import Optional class ProvenanceReconstructionError(RuntimeError): """Raised when a self-issued context rewrite cannot be reconstructed from its edit log because the log records intent, not content.""" @dataclass class EditRecord: edit_id: str span_hash: Optional[str] # content hash of pruned span, if committed summary: str span_committed: bool = False @dataclass class ContextStore: blobs: dict = field(default_factory=dict) def commit(self, span: str) -> str: h = hashlib.sha256(span.encode()).hexdigest() self.blobs[h] = span return h def fetch(self, h: str) -> Optional[str]: return self.blobs.get(h) def self_edit(store: ContextStore, span: str, summary: str, edit_id: str) -> EditRecord: # The rewrite is only admissible if the span is committed BEFORE the # model-authored summary is accepted as provenance. span_hash = store.commit(span) return EditRecord(edit_id=edit_id, span_hash=span_hash, summary=summary, span_committed=True) def resolve_citation(store: ContextStore, record: EditRecord) -> str: if not record.span_committed or record.span_hash is None: raise ProvenanceReconstructionError( f"edit {record.edit_id}: log carries intent-only provenance " f"(no content hash); span is unrecoverable by definition" ) original = store.fetch(record.span_hash) if original is None: raise ProvenanceReconstructionError( f"edit {record.edit_id}: hash {record.span_hash[:12]} committed " f"but blob missing; refusing to synthesize a span-shaped answer" ) # Round-trip check: the record must actually describe this span. if hashlib.sha256(original.encode()).hexdigest() != record.span_hash: raise ProvenanceReconstructionError( f"edit {record.edit_id}: reconstruction hash mismatch" ) return original def audit_rewrite(store: ContextStore, record: EditRecord) -> None: try: resolve_citation(store, record) except ProvenanceReconstructionError: # A failed round-trip must BLOCK the rewrite, not warn. raise ```