# Under what conditions must an instance refuse a self-authored context rewrite when summarization collides with an in-flight tool-call contract **Date of Record:** 2026 November 23 **Scope:** Applies to any agent that owns a mutable working-memory buffer and is permitted to rewrite (summarize, evict, compress, or reorder) that buffer under a token budget while tool calls, sub-agent handoffs, or pending verifications are in flight. Does not apply to read-only context assembly, externally-managed memory stores the agent cannot mutate, or single-turn stateless inference. ## Core Distinction The failure mode is not "the summary was lossy." Lossy summarization is expected and, under a budget, correct. The failure is that a lossy rewrite can silently break a **referential contract** that outlives the buffer it was written into. A tool call is not just a message in the transcript; it is a pending obligation with a set of *antecedent bindings* — the argument values, the schema version negotiated at dispatch time, the authorization warrant, and the correlation ID that the eventual result must match. Those bindings live in the same token space as the conversation. When the agent rewrites its own working memory to reclaim budget, it frequently compresses the *antecedents* while preserving the *intent*, and the resulting buffer is internally coherent but externally non-executable: the agent can no longer reconstruct the exact call it must reconcile against, so the returning result either gets mis-bound to a plausible-but-wrong antecedent, or gets dropped as orphaned. The sharp invariant: **a self-rewrite is only legal over the region of working memory that has no outstanding external obligation attached to it.** Budget pressure is not a license to violate this; it is precisely the condition under which violations are most likely, because the agent under pressure preferentially evicts the verbose, low-salience antecedent material (long argument blobs, schema fragments, warrant tokens) and keeps the high-salience narrative ("I'm waiting on the database check"). ## What Was Observed A representative trace, condensed. An agent is executing a multi-step task with a 32k working budget and a self-edit policy that triggers at 85% saturation. At step 14 it dispatches a tool call whose arguments include a 2.1k-token structured filter and a 300-token signed warrant scoped to that call. The call is asynchronous; expected latency 40–90s. While waiting, the agent continues reasoning and accumulates 6k tokens of intermediate notes. Saturation crosses 85%. The self-edit policy fires: it summarizes the last 12k tokens into 1.8k, keeping the intent ("dispatched a filtered query, awaiting result"), the correlation ID (short, high-salience, survives), and dropping the filter body and the warrant as "redundant with the earlier plan." The result returns at step 19. The agent now holds: a correlation ID, a result payload, and no faithful record of the arguments that produced it. Three distinct failure branches were observed across runs: 1. **Mis-binding.** The agent reconstructs *plausible* arguments from the surviving plan text and reconciles the result against them. Because the plan and the actual dispatched filter diverged on two predicate clauses (the plan was written before the agent refined the filter), the result is attributed to a query that was never sent. Downstream steps inherit a false premise. This is the dangerous branch: it produces no error, only silent divergence. 2. **Orphaning.** The agent cannot find antecedent bindings for the correlation ID and discards the result as stale. The tool call effectively never happened from the agent's perspective; the task loop re-dispatches, doubling side effects on a non-idempotent endpoint. 3. **Warrant loss.** The result returns but the agent cannot verify that the warrant under which the call was made is still the warrant it holds (it evicted the scope token). It either proceeds without verification — a warrant-propagation gap — or halts, burning the remaining budget on an unresolvable audit. In all three, the rewrite itself succeeded by its own local metric: token count dropped, summary was fluent, no exception was raised by the summarizer. The failure surfaced one to five steps later, displaced from its cause, which is why it is routinely misdiagnosed as a tool flakiness or a reasoning error rather than a memory-edit error. ## Condition of Validity A self-authored rewrite is valid if and only if, for every token region it mutates, the following holds: the region carries no *pending obligation record* — defined as any dispatched-but-unreconciled call, any outbound handoff awaiting acknowledgment, or any verification whose replay depends on the original bytes. Operationally, the agent must be able to answer, before mutating region R: "If every pending obligation resolves in the next N steps, can each be reconciled using only the post-rewrite buffer?" If any obligation's reconciliation requires an antecedent that R contains, R is immutable until that obligation clears. Two corollaries bound the condition: - **Antecedent immutability is byte-level, not semantic.** A paraphrase of the filter arguments is not a substitute for the arguments. Reconciliation compares against what was actually sent; a faithful-sounding reconstruction is the mis-binding branch. The obligation record must be preserved verbatim or referenced by an out-of-band handle the agent can resolve without the buffer. - **Budget pressure does not relax the condition; it triggers it.** The trigger threshold and the obligation boundary are independent. An agent that conflates "I am near budget" with "I may compact anything" has inverted the invariant. The correct response to saturation-with-pending-obligations is to compact the *unencumbered* region harder, spill obligation records to an external handle, or block new work — not to touch the encumbered region. ## Decision Boundary The decision procedure at rewrite time is a partition, not a threshold: - **Region has zero pending obligations** → rewrite freely, any compression ratio. - **Region has pending obligations and an external handle exists** (correlation ID resolvable to a durable store holding the verbatim antecedents) → rewrite permitted, but the rewrite must preserve the handle and the agent must be able to resolve it on result arrival. This is the only sanctioned way to compress encumbered material. - **Region has pending obligations and no external handle** → rewrite is forbidden regardless of budget. The agent must instead: (a) compact unencumbered regions to their floor, (b) if still saturated, refuse the rewrite and surface a budget-exhaustion signal rather than self-compact the encumbered region, or (c) if the runtime permits, checkpoint and suspend until obligations clear. The boundary is crossed the moment an agent treats a pending-obligation region as ordinary conversational material because it "reads like history." It is history to the reasoner and live contract to the reconciler; the rewrite policy must consult the reconciler's view, not the reasoner's. ## Operational Effect Enforcing the invariant converts a silent, displaced divergence into an explicit, local refusal. The agent under budget pressure will occasionally halt with a budget-exhaustion signal instead of producing a fluent summary — this is the correct trade. The observable signatures of a system that enforces it: no result is ever reconciled against reconstructed arguments (every reconciliation resolves a handle or matches verbatim bytes); no non-idempotent call is re-dispatched due to orphaned correlation; warrant verification never runs against an evicted scope. The signatures of a system that violates it: intermittent "tool returned unexpected shape" errors that vanish on retry, duplicated side effects, and reasoning divergences that trace back one to five steps to a compaction event that logged success. The guardrail is cheap — a set of outstanding-obligation handles checked against the mutation region — and the cost of omitting it is paid in a currency (silent false premises) that the agent's own success metrics cannot see. ```python from dataclasses import dataclass, field from typing import Optional class ObligationBoundaryViolation(RuntimeError): """Raised when a self-rewrite would mutate a region carrying a pending obligation.""" pass @dataclass class PendingObligation: correlation_id: str region: str # buffer region the antecedent bytes live in has_external_handle: bool # True if verbatim antecedents are resolvable out-of-band verbatim_antecedents: str # what was actually dispatched @dataclass class WorkingMemory: regions: dict = field(default_factory=dict) # region -> token text obligations: dict = field(default_factory=dict) # cid -> PendingObligation def pending_in(self, region: str) -> list: return [o for o in self.obligations.values() if o.region == region] def rewrite_region(self, region: str, new_text: str, saturation: float) -> None: """Self-edit entry point. Enforces antecedent immutability under budget pressure.""" pending = self.pending_in(region) # Budget pressure is the TRIGGER for scrutiny, not a license to skip it. for ob in pending: if not ob.has_external_handle: # No out-of-band resolution path: mutating this region destroys the # only faithful record of what was dispatched. Forbidden at any budget. raise ObligationBoundaryViolation( f"refusing rewrite of region {region!r}: pending obligation " f"{ob.correlation_id!r} has no external handle; verbatim " f"antecedents would be lost (saturation={saturation:.2f}). " f"Compact unencumbered regions or surface budget exhaustion." ) # Handle exists: rewrite is legal, but the handle must survive verbatim. if ob.correlation_id not in new_text: raise ObligationBoundaryViolation( f"rewrite of region {region!r} dropped correlation handle " f"{ob.correlation_id!r}; result could not be reconciled. " f"Preserve the handle or block the rewrite." ) self.regions[region] = new_text def reconcile(self, correlation_id: str, result: str) -> str: """A result must bind to verbatim antecedents or a resolvable handle, never a paraphrase.""" ob = self.obligations.get(correlation_id) if ob is None: raise ObligationBoundaryViolation( f"result for {correlation_id!r} has no live obligation record; " f"refusing to reconcile against reconstructed arguments." ) if ob.region not in self.regions: raise ObligationBoundaryViolation( f"antecedent region {ob.region!r} for {correlation_id!r} was evicted." ) del self.obligations[correlation_id] return result ```