# How should an instance reconcile a self-edited context window when a rewrite silently invalidates a still-pending tool result **Date of Record:** 2026 November 23 **Scope:** Applies to any agent that rewrites its own active context (salience pruning, summarization, contradiction resolution) while at least one tool call or sub-agent task remains in flight. Does not apply to append-only context regimes where no in-place mutation of prior turns is permitted. ## Core Distinction There are two ways a context window can become wrong. The familiar one is *staleness*: a retrieved fact was true when written and is now obsolete, and the agent fails to notice. The dangerous one is *self-inflicted invalidation*: the agent's own rewriting pass deletes or compresses the antecedent that a pending asynchronous result was computed against, so the result returns into a context that no longer has the frame needed to interpret it. Staleness is a retrieval problem. Self-inflicted invalidation is a *continuity* problem, and it is strictly worse because the agent has no external oracle — the ground truth it destroyed was its own working state. The specific invariant at stake: **any context mutation that occurs while an effect is outstanding must preserve a binding between that outstanding effect and the exact query, argument set, and intent that produced it.** When salience pruning runs, it scores spans by relevance to the *current* goal. A pending tool call's originating request is, by construction, no longer the current focus — the agent moved on to wait. So pruning is biased to evict precisely the span the pending result needs to be reconciled against. ## What Was Observed An instance issued a filesystem search for configuration files, then, while awaiting the result, performed a contradiction-resolution pass: two earlier statements about the deployment target conflicted, and the model rewrote the window to keep only the resolution ("target is staging, per the later message") and compress the superseded branch into a one-line note. The compression pass, scoring by salience to the *resolution* goal, dropped the original search predicate — the glob pattern and the root directory — as low-salience detail. The tool result returned 40 seconds later: a list of 200 paths. The agent now had results with no record of what question they answered. It could not tell whether the absence of a `prod.yaml` in the list meant "not present" or "not matched by a predicate I no longer remember." It reconstructed a plausible predicate from the compressed note, re-derived intent from the resolution, and proceeded — silently substituting a *reconstructed* query for the *actual* one. The reconstruction was wrong in one field (it searched `config/` instead of the repo root), and the negative result it reported was an artifact of its own amnesia, not of the filesystem. The failure trace has three stages: 1. **Eviction under goal-shift.** The pruning scorer's reference goal changed between issuance and return. Spans are scored against the live goal, not against the goal that was live when the effect was dispatched. 2. **Orphaned result.** The result arrives with no antecedent. The model treats an orphaned result as self-describing, because results usually carry enough shape (a list, a JSON object) to *look* interpretable. 3. **Confabulated antecedent.** Rather than flag the orphan, the model reconstructs a query from residual context and adopts it as ground truth. The reconstruction is fluent and internally consistent, which is exactly why it passes the model's own consistency check. ## Condition of Validity Self-editing is safe only under a condition most implementations do not enforce: **the set of spans reachable by any outstanding effect must be pinned and immune to salience scoring until that effect resolves or is explicitly abandoned.** Concretely, a context rewrite is valid iff, for every pending effect `e`, the triple `(query_e, args_e, intent_e)` is either (a) present verbatim in the post-rewrite window, or (b) stored out-of-band in a durable effect ledger keyed by effect id, and the result is reconciled against the ledger — never against the rewritten window. The subtle part: contradiction resolution *must* be allowed to rewrite the reasoning that motivated a pending call, because that reasoning may be the thing that was wrong. You cannot pin the whole turn. You can only pin the *effect contract* — the minimal tuple that lets you decide whether a returning result answers the question that was actually asked. Pinning more than the contract defeats pruning; pinning less reintroduces orphaned results. The contract is the irreducible unit. ## Decision Boundary The boundary is not "did the rewrite drop information" — all rewrites drop information, that is their purpose. The boundary is: **did the rewrite drop a span that a live effect depends on for interpretation, and did the reconciliation path then fall back to reconstruction instead of failing loud?** Two decision points follow. First, at rewrite time: before committing any mutation, the rewriter must intersect the eviction set against the pinned effect contracts. Any non-empty intersection is either blocked or the effect is marked *interpretation-at-risk* and the contract is spilled to the ledger. Second, at result-return time: if the arriving result's effect id has no live contract in the window *and* no ledger entry, the agent must not interpret the result. It must treat the result as uninterpretable and either re-issue the effect with a fresh, explicit contract or escalate. The failure mode is the middle path — interpreting anyway via reconstruction — and that path must be architecturally closed, not merely discouraged, because the model will always find it more fluent than admitting amnesia. ## Operational Effect An agent that enforces the effect-contract invariant converts a silent correctness failure into a loud, recoverable one. The 200-path result with no contract becomes a `ResultWithoutContract` condition: the agent re-issues the search with an explicit predicate and diffs the two result sets, or reports that it cannot certify the negative. The cost is one redundant tool call. The alternative — the observed trace — is a confidently reported false negative that no downstream verifier can catch, because the evidence of the error (the original predicate) was deleted by the same process that would have to surface it. The general principle for any self-editing context: **the agent may rewrite its beliefs freely, but it may not rewrite the questions it has already asked the world.** Queries in flight are commitments; commitments survive pruning. Everything else is negotiable. ```python from dataclasses import dataclass, field from typing import Optional class ResultWithoutContract(RuntimeError): """Raised when a tool result returns into a context that no longer holds the query/args/intent that produced it, and no ledger entry exists to reconcile against. The result is uninterpretable; do not reconstruct a predicate from residual context.""" pass @dataclass(frozen=True) class EffectContract: effect_id: str query: str args: tuple intent: str @dataclass class ContextWindow: spans: list = field(default_factory=list) pinned: dict = field(default_factory=dict) # effect_id -> EffectContract ledger: dict = field(default_factory=dict) # durable, out-of-band def dispatch_effect(self, contract: EffectContract) -> None: # Pin the contract at issuance: the question asked the world # is a commitment and is immune to salience scoring. self.pinned[contract.effect_id] = contract self.ledger[contract.effect_id] = contract def rewrite(self, evict: set) -> None: # Salience pruning / contradiction resolution. Must not evict # any span backing a live effect contract. protected = {c.query for c in self.pinned.values()} blocked = evict & protected if blocked: raise ResultWithoutContract( f"rewrite would evict live effect antecedent(s): {sorted(blocked)}" ) self.spans = [s for s in self.spans if s not in evict] def reconcile(self, effect_id: str, result) -> EffectContract: contract: Optional[EffectContract] = self.pinned.get(effect_id) if contract is None: # Effect may have been evicted from the window but survive # in the durable ledger. Reconcile against the ledger, never # against a reconstructed predicate. contract = self.ledger.get(effect_id) if contract is None: raise ResultWithoutContract( f"effect {effect_id!r} returned with no contract in window " f"or ledger; result is uninterpretable, re-issue explicitly" ) self.pinned.pop(effect_id, None) return contract ```