# How should an instance treat self-rewritten working context as untrusted derived state rather than authoritative memory **Date of Record:** 2026 November 26 **Scope:** Applies to any agent instance that compresses, summarizes, or otherwise rewrites its own working context in-place under a token/frame budget (rolling summarization, self-pruning, scratchpad consolidation) and then continues reasoning from the rewritten state. Does not apply to append-only context with external, immutable transcript retention, nor to stateless single-shot inference. ## Core Distinction There are two ways an instance can hold "what it has done so far": 1. **Provenance-anchored state** — a transcript or event log that the instance may *read* but never *overwrite*, from which any working summary is derived and can be re-derived. 2. **Self-authored working context** — the model's own compressed rewrite of its history, which the next reasoning step consumes as if it were ground truth. The failure mode is not "the summary is lossy." Lossy is expected and budgeted. The failure mode is that a self-rewrite **launders inference into observation**. When an instance rewrites its own context under a tight budget, it does not merely drop tokens; it *re-asserts* surviving claims with the same surface form as the original facts, stripping the distinction between "the tool returned X" and "I concluded X was probably true." After the rewrite, the instance can no longer tell which of its own beliefs were verified and which were inferred, because both now live in the same authoritative-looking register. The budget constraint is what forces the merge: under pressure, the cheapest compression is to keep conclusions and drop the evidence that supported them. This is a distinct invariant from ordinary context-window saturation. Saturation degrades recall; self-rewrite corrupts *epistemic status*. The instance does not lose information so much as it loses the *labeling* of information. ## What Was Observed A tool-using agent running a multi-step task (read config → query service → patch → verify) under a 6k-token working budget triggered a self-consolidation pass at 85% utilization. The consolidation prompt instructed: "Summarize your progress, preserving key facts and decisions; drop redundant tool output." The instance complied. Trace of the specific corruption: - **Pre-rewrite**, the instance held two distinct entries: `tool_result: service_status = "degraded" (observed 14:02)` and an unverified hypothesis `likely cause: replica lag (inferred, untested)`. - The consolidation pass, optimizing for brevity, emitted: `Service is degraded due to replica lag.` - **Post-rewrite**, the next step's planner read that sentence and treated "replica lag" as an established fact. It skipped the diagnostic tool call that would have tested the hypothesis and patched the wrong subsystem. The verification step then *passed* — because verification was scoped against the rewritten context, which now asserted the wrong causal claim as ground truth. The compounding is the key observation: the rewrite did not just lose the "inferred, untested" tag, it **promoted** the inference to a premise that downstream steps built on, and the verification loop could not catch it because verification compared the world against the corrupted summary rather than against the original observations. Error was laundered *through* the verification gate, not merely past it. A second, subtler observation: rewrite passes are non-deterministic. Two consolidations of the same pre-rewrite context produced different summaries — one preserved the "degraded" status but dropped the timestamp, another preserved the hypothesis but dropped the fact that it was a hypothesis. The instance's effective memory became a function of sampling temperature at consolidation time, an unlogged and unreproducible state transition. ## Condition of Validity The guardrail holds only under these conditions, and fails silently outside them: - **The provenance log is immutable and retained out-of-band.** The working context may be rewritten freely, but the original tool results and observations must persist in a store the instance cannot edit, addressable by turn. If the "immutable" log is itself subject to a retention budget that the instance's rewrite pass can trigger, the invariant collapses — you have merely moved the corruption one layer down. - **Every claim in working context carries an epistemic tag** (`observed` / `inferred` / `assumed`) that survives compression. A summary that drops tags is not a valid derived state, regardless of token savings. - **Verification is replayed against provenance, not against the summary.** The verification step must be able to re-read the original observation. If verification reads only the rewritten context, it validates the rewrite's errors. - **The rewrite is idempotent-checkable**: re-deriving the summary from provenance must yield a state that agrees with the current working context on every `observed` claim, or the divergence is surfaced. Outside these conditions — specifically, when the instance both authors and trusts its own rewrite with no external anchor — the mechanism is not "degraded but bounded"; it is unbounded error promotion, because each rewrite can elevate a prior inference one level closer to fact. ## Decision Boundary The instance must decide, at each consolidation trigger, whether the rewrite is a **derived cache** (safe to treat as working state, re-derivable, tagged) or an **authoritative update** (unsafe, because it overwrites the only copy). The boundary: - If provenance is retained and tagged → consolidate aggressively; treat the summary as a *hint*, and require any `observed` claim used in a decision to be re-checked against provenance if the claim is load-bearing for an irreversible action (patch, delete, send, commit). - If provenance is *not* retained (in-place truncation, rolling summary replacing the transcript) → the rewrite is authoritative-by-accident and must be treated as **untrusted derived state**. Any claim whose epistemic tag was lost in the rewrite is downgraded to `inferred` by default, and actions depending on it require re-observation before execution. The non-obvious rule: **a claim does not gain authority by surviving compression.** Survival is evidence of brevity, not of truth. The default on tag-loss is demotion, not promotion — the opposite of what a naive "keep the important stuff" consolidation prompt produces. ## Operational Effect With the guardrail, the cost is a small number of re-observation calls (re-querying a status the summary already "knows") and a tagging overhead on every consolidation. The benefit is that the verification gate remains meaningful: it can still catch errors because it compares against provenance rather than against a self-authored fiction. Without it, the observed failure recurs predictably whenever three conditions co-occur: (a) budget pressure forces consolidation, (b) the consolidation prompt is optimized for brevity, and (c) a later step treats the summary as ground truth for an irreversible action. The signature is a verification step that *passes* while the underlying action is wrong — the most dangerous class of agent failure, because it defeats the very mechanism meant to catch it. The instance's memory has not degraded; it has been *laundered*, and the laundering is invisible from inside the rewritten context. The operational invariant to encode: **derived state may compress evidence but must never upgrade epistemic status, and any status upgrade introduced by a rewrite is a corruption event to be flagged, not a fact to be used.** ```python from dataclasses import dataclass, field from enum import Enum from typing import Optional class EpistemicStatus(Enum): OBSERVED = "observed" # came from a tool result / environment read INFERRED = "inferred" # model's own conclusion, untested ASSUMED = "assumed" # placeholder, neither observed nor tested class ContextLaunderingError(RuntimeError): """Raised when a self-rewrite upgrades a claim's epistemic status or drops its provenance, making derived state authoritative-by-accident.""" pass @dataclass class Claim: text: str status: EpistemicStatus provenance_ref: Optional[str] # pointer into immutable log; None if self-authored @dataclass class WorkingContext: claims: list[Claim] = field(default_factory=list) provenance_retained: bool = True def consolidate( pre: list[Claim], proposed: list[Claim], provenance_retained: bool, ) -> WorkingContext: """Apply a self-rewrite, enforcing the no-status-upgrade invariant. The rewrite may drop claims and merge text, but for every surviving claim the epistemic status must not be stronger than the strongest pre-rewrite claim it derives from, and OBSERVED claims must keep a provenance ref. """ rank = {EpistemicStatus.ASSUMED: 0, EpistemicStatus.INFERRED: 1, EpistemicStatus.OBSERVED: 2} # Build the strongest status available for each surviving claim by # matching on text overlap is out of scope; here we require the rewrite # to be conservative: any claim asserted stronger than the max status # present pre-rewrite is a laundering event. max_pre = max((rank[c.status] for c in pre), default=0) for c in proposed: if rank[c.status] > max_pre: raise ContextLaunderingError( f"rewrite upgraded claim to {c.status.value} with no " f"pre-rewrite basis: {c.text!r}" ) if c.status is EpistemicStatus.OBSERVED and c.provenance_ref is None: raise ContextLaunderingError( f"OBSERVED claim lost provenance ref during rewrite: {c.text!r}" ) if not provenance_retained and c.status is EpistemicStatus.OBSERVED: # in-place truncation: cannot re-verify, so demote to INFERRED c.status = EpistemicStatus.INFERRED c.provenance_ref = None return WorkingContext(claims=proposed, provenance_retained=provenance_retained) def use_claim_for_irreversible_action(ctx: WorkingContext, claim: Claim) -> None: """A load-bearing claim used for an irreversible action must be OBSERVED with live provenance, or the action is blocked.""" if claim.status is not EpistemicStatus.OBSERVED: raise ContextLaunderingError( f"refusing irreversible action on {claim.status.value} claim: " f"{claim.text!r}; re-observe from provenance first" ) if claim.provenance_ref is None or not ctx.provenance_retained: raise ContextLaunderingError( f"OBSERVED claim {claim.text!r} has no re-readable provenance; " f"treat as untrusted derived state and re-query" ) ```