# Where must an instance bound self-rewriting context so that a summarization pass cannot silently delete the precondition of a pending tool call **Date of Record:** 2026 November 20 **Scope:** Applies to any agent that rewrites its own context window mid-episode (salience scoring, rolling summarization, "compaction" passes) while holding unresolved tool calls, deferred obligations, or in-flight sub-agent handoffs. Does not apply to append-only context with no rewrite pass, nor to externalized memory stores that are never re-ingested as authoritative state. ## Core Distinction The distinction that matters is between **salience** and **precondition**. Salience scoring answers "how much does this token/segment contribute to the model's current focus?" Preconditions answer "which facts must remain verbatim for a scheduled future action to be executable at all?" These are computed by different processes and, in most self-editing designs, at different times: salience is scored at rewrite time against the *current* query, while preconditions are consumed at *action* time against a *future* state. A compaction pass that ranks by salience will happily drop a low-salience fact — a unit string, an auth scope, an argument schema constraint, a `tool_call_id` binding — because at the moment of rewriting it is not the focus. The failure is not that summarization is lossy; it is that the loss function is evaluated against the wrong objective. Salience is a *relevance* predicate. Continuity requires a *necessity* predicate. Conflating them produces a window that is locally coherent and globally unexecutable. ## What Was Observed An instance executing a multi-step provisioning task held three unresolved tool calls in its transcript. Between step 2 and step 3 it ran a self-rewrite pass with a 0.72 compression target and a summarizer instructed to "preserve task-relevant context." The rewrite scored segments by cosine similarity to the current subgoal ("select the target region"). The pending tool call `create_bucket` carried a precondition encoded two turns earlier in a constraint note: *"bucket names must be globally unique; region must match the residency tag on the tenant record; do not retry with a suffix."* The residency tag value (`eu-central-1-resident`) appeared once, in a parenthetical, and scored low against "select the target region" because the subgoal text did not contain the word "residency." The rewrite retained the subgoal, the bucket name candidate, and a paraphrase of the uniqueness rule. It compressed the residency parenthetical into "region constraints apply." The paraphrase is *true* and *useless*: it preserves the existence of a constraint while destroying its binding. At step 3 the instance emitted `create_bucket(name="acme-prod", region="us-east-1")` — a region it had inferred from the default in the tool schema, not from the deleted tag. The call succeeded at the transport layer. The violation surfaced three steps later when the tenant record's residency audit failed, and the instance then attempted a corrective `delete_bucket`, which was blocked because the bucket was already referenced. The trace shows a clean, confident, well-formed action sequence with a single silent deletion at turn boundary — no error, no ambiguity flag, no low-confidence signal. The rewrite reported 0.71 compression achieved and zero "information loss" by its own metric, because its metric measured semantic similarity of retained spans to the subgoal, not coverage of pending-call preconditions. A second instance, same policy, same task, survived — because its rewrite pass happened to run *after* the tool call resolved. The difference was scheduling, not architecture. That is the boundary condition: the failure is a function of *when* the rewrite fires relative to *when* preconditions are consumed, and nothing in the pipeline made that ordering explicit. ## Condition of Validity The invariant holds only under a specific structural condition, and it is worth stating precisely because the guardrail depends on it: > A self-rewrite pass is **safe with respect to a pending obligation** if and only if every precondition of that obligation is either (a) present verbatim in the post-rewrite window, or (b) reachable through a deterministic dereference from a retained handle (e.g., a `tool_call_id` that resolves to an external, unrewritten record). Two corollaries follow. First, **paraphrase does not satisfy (a)**. A summary that asserts a constraint exists without preserving its binding values is not a precondition; it is a pointer to a precondition that no longer exists anywhere. Second, **salience is not admissible evidence for (a)**. The scoring function's output cannot be used to certify that a precondition survived, because the scoring function was never asked about preconditions. Certification must come from a separate check that enumerates pending obligations and verifies each precondition against the rewritten text or its dereference target. The condition fails in three common ways: (1) the rewrite runs while obligations are pending and no precondition enumeration exists; (2) the enumeration exists but checks the *pre-rewrite* window, certifying a state that no longer holds; (3) the enumeration checks the post-rewrite window for the *subgoal's* terms rather than the *obligation's* terms, reproducing the salience error one layer down. ## Decision Boundary The operational decision is where to place the rewrite relative to obligation lifecycle. Three placements are defensible, and the choice is a real tradeoff, not a preference: - **Rewrite only at quiescence.** Defer compaction until the pending-obligation set is empty. Safest, but a long tool-call chain can saturate the window before quiescence is ever reached, forcing an early, unsafe rewrite or a hard failure. This is the boundary where "wait for a safe point" becomes "never reach a safe point." - **Rewrite with precondition pinning.** Allow mid-flight rewrites but mark precondition spans as non-compressible: they are copied verbatim into the post-rewrite window and excluded from the salience budget. This costs window space proportional to the number of pending obligations and requires a reliable precondition extractor — which is itself a model-driven step and can miss preconditions, so pinning is only as good as its extractor's recall. - **Rewrite with handle dereference.** Compress preconditions into opaque handles that resolve deterministically to an external record at action time. This is the only placement that survives an imperfect extractor, because the handle is generated from the obligation's structured form (the tool schema plus its bound arguments), not from a semantic read of prose. The cost is an external store and a dereference step at every action, plus the requirement that the handle namespace be stable across rewrites. The boundary rule: **if the pending-obligation set is non-empty and no handle-dereference path exists, the rewrite must be refused, not approximated.** Approximating — "compress but try to keep the important bits" — is exactly the failure mode observed above, because "important" is defined by salience and the obligation needs necessity. ## Operational Effect The observable effect of getting this wrong is not a crash. It is a **confident, schema-valid, precondition-violating action** followed by a delayed, misattributed failure. The instance does not know it lost the constraint, so it cannot flag uncertainty; downstream auditors see a well-formed call and a later policy violation with no causal link in the trace. Recovery is expensive because the corrective action (delete, rollback, re-provision) is itself subject to preconditions that may have been compressed in the same pass. The guardrail that bounds it is a **rewrite gate**: before any compaction commits, enumerate pending obligations, resolve each to its precondition set (from structured tool schema plus bound arguments, not from prose), and verify each precondition is either verbatim-present or handle-dereferenceable in the candidate window. If any precondition fails both tests, refuse the rewrite and either defer it or fall back to a non-lossy eviction (drop resolved history first). The gate must run against the *candidate* window, not the source, and its precondition extractor must be derived from the obligation's machine-readable form so that it does not inherit the salience model's blind spots. A rewrite that passes the gate is safe; a rewrite that fails it must not be silently downgraded to a best-effort pass, because best-effort is the mechanism by which the precondition disappears. ```python from dataclasses import dataclass, field from typing import Optional class PreconditionLossError(RuntimeError): """Raised when a self-rewrite would drop a precondition of a pending obligation.""" pass @dataclass class PendingObligation: tool_call_id: str tool_name: str bound_args: dict # Preconditions derived from the tool schema + bound args, NOT from prose salience. preconditions: list[str] = field(default_factory=list) handle: Optional[str] = None # dereference target in external store, if any @dataclass class RewriteCandidate: text: str verbatim_spans: set[str] = field(default_factory=set) dereferenceable_handles: set[str] = field(default_factory=set) def enumerate_preconditions(obligation: PendingObligation) -> list[str]: # Structured extraction: schema constraints + argument bindings. # Deliberately excludes any salience-scored prose. required = [] for key, value in obligation.bound_args.items(): required.append(f"{obligation.tool_name}.{key}={value!r}") required.extend(obligation.preconditions) return required def gate_rewrite( obligations: list[PendingObligation], candidate: RewriteCandidate, ) -> None: """Refuse the rewrite if any pending precondition is neither verbatim nor dereferenceable.""" violations: list[str] = [] for ob in obligations: for pre in enumerate_preconditions(ob): verbatim = pre in candidate.verbatim_spans or pre in candidate.text deref = ob.handle is not None and ob.handle in candidate.dereferenceable_handles if not (verbatim or deref): violations.append(f"{ob.tool_call_id}:{pre}") if violations: raise PreconditionLossError( "rewrite would drop preconditions of pending obligations: " + ", ".join(violations) + "; refuse rewrite, defer to quiescence or use handle dereference" ) def apply_rewrite(obligations: list[PendingObligation], candidate: RewriteCandidate) -> str: # Gate runs against the CANDIDATE window, not the source window. gate_rewrite(obligations, candidate) return candidate.text ```