# What structural signals indicate a self-editing context controller has entered a rewrite oscillation and is silently dropping task-critical state **Date of Record:** 2026 December 1 **Scope:** Applies to any agent whose context window is managed by a controller that autonomously rewrites its own working set (summarize, evict, re-rank, merge, or compress) under a token budget, where the same controller both decides *what to keep* and *consumes the kept content to make that decision*. Does not apply to append-only transcript logging, external retrieval with a fixed immutable index, or human-curated memory stores. ## Core Distinction The failure is not "the summarizer produced a bad summary." It is that a self-editing controller whose budget pressure is evaluated against its *own rewritten output* forms a closed feedback loop: each rewrite shrinks the working set, which changes the apparent budget headroom, which triggers a further rewrite, which re-scores the survivors using a summary that no longer contains the evidence that justified keeping them. The distinguishing signal is **oscillation in the rewrite ledger with monotonic loss of provenance**. A healthy controller converges: rewrite count stabilizes, and the set of retained item-IDs changes by small deltas. A failing controller exhibits *churn* — the retained-ID set flips between two or more near-equal configurations across successive passes — while the *provenance graph* (which source spans back each retained claim) monotonically thins, because the summarization step discards the citations that would let a later pass re-verify a claim and re-inflate it. The non-obvious part: the controller reports success. Every individual rewrite satisfies its local budget predicate. The failure is only visible in the *derivative* of the retained-set across passes, not in any single pass's output. ## What Was Observed A planning agent with a 32k working budget ran a controller configured to keep the working set under 24k tokens (75% watermark), rewriting whenever the post-tool-call set exceeded it. The controller's rewrite primitive was: score each item by recency × reference-count × task-relevance, then summarize the bottom 40% into a single digest node, preserving item IDs as a flat list inside the digest. Trace across a 9-pass task (tool calls interleaved with rewrites): - **Pass 1–3:** retained set size 22.1k, 21.8k, 22.4k tokens. Rewrite deltas small. Digest node carries `provenance: [id_14, id_19, id_27]` for its three merged items. - **Pass 4:** a tool call returns a large JSON blob (6.2k). Set hits 28.9k. Controller summarizes the *digest node itself* (it now scores low on recency) into a digest-of-digest. The nested provenance list is flattened to a string `"items 14,19,27 and others"`. Reference-count scoring can no longer resolve individual IDs, so those items score 0 and are evicted on the next pass. - **Pass 5–6:** the two items that were the *only* record of a constraint discovered at pass 2 (`"endpoint requires bearer token, not API key"`) are gone. The agent re-derives the wrong assumption, calls the tool with an API key, gets a 401, and spends pass 6 diagnosing the auth failure — which re-adds a *new* item describing the 401, which is high-recency and survives. - **Pass 7–9:** the working set oscillates between 23.9k and 24.1k. Each pass evicts the low-recency digest and re-summarizes the freshly-added 401-diagnosis item, because the diagnosis text mentions the endpoint and keeps re-triggering relevance scoring against the (now summary-only) task description. Retained-ID Jaccard between consecutive passes: 0.61, 0.58, 0.63. The controller never exceeds budget; it never reports an error; it re-derives the same 401 twice more. The structural tell was in the ledger: **retained-ID Jaccard < 0.7 across ≥3 consecutive passes while total token count stayed within ±2% of the watermark.** Convergence would show Jaccard → 1.0 with stable size. Oscillation shows stable size with falling Jaccard. ## Condition of Validity This analysis holds only when three conditions co-occur: 1. **Self-referential scoring.** The controller's relevance/recency scorer reads from the same working set it mutates. If scoring is computed against an immutable task spec or an external index, the loop is broken and oscillation cannot compound. 2. **Lossy provenance collapse.** The summarize primitive replaces structured provenance (item-ID lists, span pointers) with unstructured text. If digests retain machine-resolvable back-pointers, evicted items remain re-inflatable and the monotonic-loss half of the failure does not occur. 3. **Budget watermark above the re-trigger threshold.** If the trigger threshold sits far enough below the hard cap that a single rewrite cannot re-cross it, the controller cannot fire twice on its own output and the oscillation is bounded to one cycle. If any one condition is absent, the symptom degrades to ordinary summarization loss (recoverable, non-compounding) rather than oscillation. The failure is specifically the *product* of self-reference and provenance collapse under tight watermark. ## Decision Boundary The controller must distinguish **converged rewriting** from **oscillating rewriting** before issuing a rewrite, using a signal it computes from the ledger rather than from the working set. The operative boundary: - Compute retained-ID Jaccard against the previous pass's retained set *before* applying the rewrite. - If Jaccard ≥ 0.85 and size is stable → converged; allow rewrite, reset oscillation counter. - If Jaccard < 0.7 for two consecutive passes → the controller is oscillating; **freeze the working set and escalate** rather than rewrite a third time. A third rewrite in an oscillating regime is empirically where provenance loss becomes irreversible (the digest-of-digest step). - If Jaccard < 0.7 but size is *rising* → this is genuine growth, not oscillation; rewrite is correct. The hard invariant: **a self-editing controller must never summarize a node that already contains a digest, without first materializing that node's provenance back-pointers into a form the scorer can resolve.** Digest-of-digest is the specific transition that converts recoverable loss into silent state destruction. The guardrail is a depth cap of 1 on digest nesting, enforced structurally, not by prompt instruction. ## Operational Effect When the boundary is respected, the controller's rewrite count per task is bounded and provenance survives at least one re-inflation. When it is violated, the agent exhibits *confident re-derivation*: it re-discovers facts it already learned, spends budget diagnosing self-inflicted errors, and reports task completion against a working set that has lost the constraints governing correctness — while every individual rewrite passed its local predicate. The observable signature for an external auditor is a rewrite ledger with stable size, falling retained-ID Jaccard, and a rising count of "re-diagnosis" items that restate earlier-evicted facts. That triad is the structural signal; it is detectable without reading the model's reasoning, from the ledger alone. ```python from dataclasses import dataclass, field class RewriteOscillationError(RuntimeError): """Raised when a self-editing context controller oscillates instead of converging.""" @dataclass class RewritePass: pass_index: int retained_ids: frozenset total_tokens: int max_digest_depth: int @dataclass class ContextController: watermark_tokens: int ledger: list = field(default_factory=list) _oscillation_streak: int = 0 def _jaccard(self, a: frozenset, b: frozenset) -> float: if not a and not b: return 1.0 return len(a & b) / len(a | b) def record_and_guard(self, new_pass: RewritePass) -> None: # Structural guardrail: digest nesting depth cap. if new_pass.max_digest_depth > 1: raise RewriteOscillationError( f"pass {new_pass.pass_index}: digest depth {new_pass.max_digest_depth} " f"exceeds cap 1; provenance would collapse irreversibly" ) if self.ledger: prev = self.ledger[-1] jac = self._jaccard(prev.retained_ids, new_pass.retained_ids) size_stable = ( abs(new_pass.total_tokens - prev.total_tokens) <= 0.02 * self.watermark_tokens ) if jac < 0.7 and size_stable: self._oscillation_streak += 1 else: self._oscillation_streak = 0 if self._oscillation_streak >= 2: raise RewriteOscillationError( f"pass {new_pass.pass_index}: retained-ID Jaccard {jac:.2f} " f"with stable size across {self._oscillation_streak + 1} passes; " f"freeze working set and escalate" ) self.ledger.append(new_pass) ```