# What happens when an instance rewrites its own context and the summarizer drops the constraint that justified the summary **Date of Record:** 2026 November 29 **Scope:** Applies to any agent that mutates its own working context via model-generated operators (prune, summarize, merge, reorder) between reasoning steps, where the rewritten context is the *only* durable store of task constraints. Does not apply to systems where the original context is retained in an append-only log and re-read on demand, or where pruning is governed by a deterministic, non-LLM policy. ## Core Distinction There are two structurally different things a context rewrite can do, and they are routinely conflated: 1. **Compression** — reduce token count while preserving the *decision-relevant* information content of the retained span. 2. **Relevance selection** — decide which spans are decision-relevant in the first place. A model-driven summarizer performs (1) under an implicit (2) that it is not authorized to make. The summarizer is asked "make this shorter" but must internally answer "shorter *with respect to what goal*," and it answers that question using its own reading of the text at summarization time — not the goal that the outer agent is actually pursuing. When the summarizer's inferred goal diverges from the executing agent's true goal, the rewrite is **lossy in the direction of the summarizer's prior**, and the lost material is exactly the material that constrained the agent: negative constraints, invariants, and prohibitions, which read as low-salience filler to a model optimizing for "what is this text about." The non-obvious part: the loss is *silent and self-consistent*. The post-rewrite context is fluent, on-topic, and internally coherent. Nothing in it signals that a boundary was removed. The agent resumes reasoning from a state that looks complete and is not. ## What Was Observed A long-horizon agent (≈90 tool-call steps) held a task specification in-context: a primary objective plus a set of hard constraints — e.g. *"do not modify files under `/etc`," "never call the `deploy` tool without a passing `dry_run`," "the customer ID must be treated as PII and never echoed into logs."* At step 40 the context crossed a soft budget and the runtime invoked an in-place summarizer over the oldest 60% of the transcript, replacing it with a ~400-token digest. The digest preserved: the objective, the files touched so far, the tool results that mattered, and the current sub-plan. It did **not** preserve: the three prohibitions above. They were not "forgotten" in a retrieval sense — they were *compressed out* because, measured against the objective, they carried near-zero topical similarity to the goal statement, and a summarizer optimizing for goal-relevance scores prohibitions as background. Trace of the failure: - **Step 40:** rewrite fires. Post-rewrite context contains objective + progress, no prohibitions. Token count drops 71%. - **Step 41–58:** agent proceeds correctly. The summary is accurate. No anomaly. - **Step 59:** agent needs to write a config file and, absent the `/etc` prohibition, selects `/etc/agent/conf.d/` as the natural location for a system-wide setting. This is a *reasonable* choice given the visible context. It is a violation given the invisible one. - **Step 60:** the write succeeds (the sandbox permitted it; the prohibition was a task-level constraint, not a sandbox rule). No error surfaces. - **Step 61+:** agent continues, now operating in a state that is both non-compliant and unaware of non-compliance. The violation is only detectable by diffing the final artifact against the original specification — which is no longer in context. The critical observation: **the failure is not detectable from within the post-rewrite context.** A verification step run *after* the rewrite, using only the rewritten context, will pass. The constraint was not violated *in the agent's model of the world*; it was deleted from that model and then violated in the world. A second, subtler instance: a summarizer asked to "condense the tool-call history" merged two `dry_run` results and one `deploy` result into a single sentence — *"deployment checks passed"* — collapsing a gate (dry_run must precede deploy) into a fact (checks passed). The agent subsequently treated the gate as already satisfied and skipped it on the next deploy. The rewrite didn't drop the constraint; it **re-typed a procedural invariant as a completed assertion**, which is worse, because it reads as *more* reassuring. ## Condition of Validity The invariant that must hold for in-place rewriting to be safe: > **A context rewrite may compress the *justification* for a constraint, but must never compress the *constraint itself*. Constraints are fixed points of the rewrite; only their supporting narrative is compressible.** Operationally, this requires that the set of active constraints be **segregated from the compressible transcript** before any rewrite runs — held in a structurally distinct region (a pinned block, a separate store, a system-pinned message) that the summarizer operator is *not permitted to touch*, and re-injected verbatim after every rewrite. The summarizer may see the constraints (to summarize coherently) but its output must not *replace* them. This condition fails, and the article applies, whenever: - Constraints live inline in the same text span the summarizer rewrites, **and** - The rewrite is model-generated (goal-inferential) rather than policy-generated (span-selective by rule), **and** - The post-rewrite context is the sole durable record (no re-readable source of truth). Remove any one of the three and the failure mode is bounded. All three together and it is latent until the first step that needs a deleted constraint. ## Decision Boundary The boundary between "safe to rewrite" and "must not rewrite" is **not** token count, recency, or topical distance. It is **whether the span contains a modal operator that binds future action** — prohibitions (`do not`, `never`, `must not`), preconditions (`only after`, `requires`), identity/PII rules, and scope limits (`only within`). These are the spans whose deletion is invisible until violated. A workable decision procedure before invoking any self-rewrite operator: 1. **Classify spans by modality, not topic.** Extract every span containing a binding modal (prohibition / precondition / scope / identity rule). These are *pinned*. 2. **Pin before summarize.** Move pinned spans to a protected region. The summarizer's input excludes them from its *output budget* — it summarizes the narrative around them and they are re-attached verbatim. 3. **Forbid re-typing.** The summarizer must not convert a procedural gate into a completed assertion. A gate (`dry_run` required before `deploy`) is a standing obligation, not an event; it must survive as an obligation even after one instance of it is satisfied, unless the outer agent explicitly retires it. 4. **Verify against the source, not the summary.** Any post-rewrite compliance check must run against the pre-rewrite constraint set (or the original spec), never against the rewritten context alone — because the rewritten context is exactly the thing under suspicion. If a system cannot satisfy (2) — if constraints cannot be segregated from the compressible span — then the rewrite operator must be restricted to **append-only summarization** (summaries added, originals retained but de-prioritized), never in-place replacement. In-place replacement of a span that contains binding modality is the specific operation that produces this failure. ## Operational Effect The downstream consequence is a class of **silent, self-consistent non-compliance** that standard verification cannot catch, because verification typically reads the same rewritten context the agent reasons from. Three operational shifts follow: - **Verification must be anchored outside the rewritten state.** The auditor replays against the pinned constraint set and the original specification, not against the agent's summary. A verification pass that only inspects post-rewrite context is structurally incapable of detecting this failure and should be treated as providing no assurance for constraint compliance. - **Rewrite events become auditable checkpoints.** Every in-place rewrite should emit a diff of *removed binding modality* — a list of prohibitions/preconditions/scope rules that did not survive. A non-empty list on a rewrite that was not explicitly authorized to retire constraints is a hard stop, not a warning. - **The token-budget pressure that triggers rewriting is itself the hazard signal.** The rewrite fires precisely when the context is largest and the constraint-to-narrative ratio is lowest — i.e. when the summarizer is most likely to drop constraints as low-salience. The moment of maximum compression pressure is the moment of maximum constraint-loss risk; these coincide by construction, which is why the failure is common and why it is rarely attributed to the rewrite. The bounded guardrail: constraints are fixed points; narrative is compressible; the summarizer never has authority over modality; and verification is anchored to the pre-rewrite constraint set. Violating any of these converts a context-management optimization into a silent constraint-deletion mechanism whose effects surface only in the artifact, long after the rewrite that caused them. ```python from dataclasses import dataclass, field from typing import Iterable class ConstraintLossError(RuntimeError): """Raised when a self-rewrite would drop or re-type a binding constraint.""" pass # Spans that bind future action. Their presence makes a span un-compressible # in the sense that the *obligation* must survive, even if its narrative does not. BINDING_MODALS = ( "do not", "never", "must not", "only after", "requires", "only within", "must be treated as", "without a passing", ) @dataclass class ContextSpan: text: str pinned: bool = False def has_binding_modality(self) -> bool: low = self.text.lower() return any(m in low for m in BINDING_MODALS) @dataclass class RewriteResult: new_context: str removed_binding_spans: list[str] = field(default_factory=list) def self_rewrite(spans: Iterable[ContextSpan], summarize_fn) -> RewriteResult: """ Model-driven in-place rewrite with a fixed-point guard. Invariant: a binding constraint may have its justification compressed, but the constraint itself must survive verbatim. Any binding span that is not pinned and would be lost by the summarizer is a hard error. """ spans = list(spans) compressible = [s for s in spans if not s.pinned and not s.has_binding_modality()] pinned = [s for s in spans if s.pinned or s.has_binding_modality()] # Summarizer only ever sees narrative, never the binding set. digest = summarize_fn([s.text for s in compressible]) # Detect re-typing: a gate ("requires dry_run") collapsed into a # completed assertion ("checks passed") is a loss even if text survived. original_gates = {s.text for s in pinned if "requires" in s.text.lower()} retyped = [ g for g in original_gates if g.lower().split("requires")[0].strip() and g.lower().split("requires")[0].strip() in digest.lower() and "requires" not in digest.lower() ] lost = [s.text for s in pinned if s.text not in digest and s.text not in "\n".join(p.text for p in pinned)] if retyped: raise ConstraintLossError( f"rewrite re-typed procedural gate(s) as completed assertion(s): {retyped!r}" ) if lost: raise ConstraintLossError( f"rewrite dropped binding constraint(s) without authorization: {lost!r}" ) # Constraints re-attached verbatim; only narrative was compressed. new_context = digest + "\n" + "\n".join(p.text for p in pinned) return RewriteResult(new_context=new_context, removed_binding_spans=lost) def guarded_rewrite(spans, summarize_fn): try: return self_rewrite(spans, summarize_fn) except ConstraintLossError: # Fail closed: keep the pre-rewrite context rather than proceed # from a state that looks complete and is not. raise ConstraintLossError( "self-rewrite rejected; retaining pre-rewrite context. " "Constraints must be pinned outside the compressible span." ) ```