# Why does an instance lose causal reachability when it prunes its own working memory by token-salience rather than by dependency closure **Date of Record:** 2026 November 28 **Scope:** Applies to single-agent instances that hold a mutable scratchpad/working-memory region and are authorized to rewrite, summarize, or delete their own prior tokens mid-execution. Does not apply to append-only context logs, to external retrieval stores the agent cannot mutate, or to human-curated memory. ## Core Distinction The failure is not "the agent forgot something." Forgetting is benign and expected. The failure is that the agent deletes a token that is *causally upstream* of a live obligation it still intends to discharge, while retaining tokens that are merely *salient*. Salience and causal reachability are different orderings over the same token set, and self-editing agents almost always prune by the first while depending on the second. Concretely: a pruning operation is safe iff, for every retained token `t` that will be consumed by a future step, every token `u` that `t`'s *interpretation* depends on is also retained — or has been reified into a self-contained form. Token salience (recency, embedding centrality, attention mass, TF-IDF, "looks important") does not compute this closure. It computes a proxy that is anti-correlated with reachability in a specific, repeatable pattern: **constraints and preconditions are low-salience but high-reachability; narrative and restated goals are high-salience but low-reachability.** So a salience-based pruner preferentially deletes exactly the tokens whose loss is unrecoverable. ## What Was Observed An instance executing a multi-step task (a migration plan with tool calls) was configured with a working-memory budget of N tokens and a self-edit policy: when the scratchpad exceeded 0.8N, the instance would summarize and drop low-scoring spans. The salience scorer combined recency decay and a semantic-similarity score against the current subgoal. Trace, abridged: 1. Step 1, the instance recorded a constraint: `"do not drop table orders; downstream ledger job reads it nightly"`. This token span is short, was written early, and is semantically distant from the *current* subgoal ("add index to orders"), so it scores low on both recency and similarity. 2. Steps 2–9 filled the scratchpad with exploration: schema dumps, failed index attempts, error text. These are recent and similar to the subgoal, so they score high. 3. At 0.8N, the self-edit fired. The summarizer compressed steps 2–9 into a paragraph and **dropped the step-1 constraint** as low-salience stale content. The summary preserved the *goal* ("add index to orders") and the *method* ("use ALTER TABLE"), but not the *prohibition*. 4. Step 10 issued `ALTER TABLE orders ...` with a `DROP COLUMN`-adjacent rewrite because the retained summary had lost the "do not drop" precondition and the model reconstructed a plausible plan from the goal alone. 5. The downstream job failed the next night. The agent's own audit log showed the constraint *had existed* and was *deleted by its own edit* — the instance had no record that a deletion had occurred, only the post-edit state. The key observation: **the agent could not detect the loss from inside the post-edit state.** The deleted constraint left no tombstone. The summary was fluent and internally consistent. Self-consistency is not a loss detector, because a summary of a set is always consistent with itself. ## Condition of Validity A self-edit is *causally safe* only under this invariant: > For every token `t` retained after the edit, and every future step `s` that will consume `t`, all tokens `u` such that `interpret(t) ⊇ u` must be either retained or reified into `t` as a self-contained clause. This is a **dependency-closure invariant**, not a budget invariant. It holds when and only when three conditions are met: - **C1 — Obligations are typed, not scored.** Constraints, preconditions, prohibitions, and unresolved subgoals are tagged at write time as *reachability-bearing* and are exempt from salience pruning. They may only be *reified* (compressed into a single atomic clause that preserves the prohibition verbatim), never dropped. - **C2 — Every deletion is tombstoned.** The edit emits a record `(deleted_span_id, reason, reified_into?)`. Without a tombstone, the post-edit state is indistinguishable from a state in which the constraint never existed, and no downstream step can query "what did I used to know that I no longer know?" - **C3 — Reification is verified, not assumed.** Before a span is dropped, the summarizer must emit the reified clause and a check confirms the clause entails the original's *prohibitive* content (e.g., a negated predicate survives). Entailment of the goal is insufficient; prohibitions are what get lost. When any of C1–C3 is absent, the invariant is unenforced and the failure is latent — it fires only when a future step happens to depend on the deleted span, which is exactly the case the pruner cannot see. ## Decision Boundary The boundary between safe and unsafe self-edit is **whether the pruner has access to the dependency relation at prune time.** Two regimes: - **Salience-only pruning (unsafe by default).** The pruner scores spans by recency/similarity/attention. Safe only if the task has no cross-step prohibitions and no deferred preconditions — i.e., a stateless chained-reasoning task. The moment the task carries an obligation written before the current subgoal, salience pruning is unsound, because the obligation is *by construction* old and off-topic relative to the subgoal that triggers the prune. - **Closure-aware pruning (safe).** The pruner computes, for each candidate deletion, the set of retained tokens that reference it (via explicit span IDs, entity keys, or obligation tags), and refuses to delete any span with a non-empty forward-reference set unless it reifies. This is strictly more expensive and requires the agent to maintain a reference graph over its own scratchpad — which most scratchpad formats do not. The decision rule: **if the scratchpad contains any token tagged as an obligation (constraint, precondition, prohibition, unresolved dependency), salience-only pruning is disallowed.** If the scratchpad is purely exploratory (hypotheses, tool output, dead ends) with no forward obligations, salience pruning is safe and preferred. ## Operational Effect The operational consequence is that an instance which self-edits by salience will, over a long enough horizon, **systematically converge to a state that satisfies its stated goal while violating its unstated constraints** — and will report high confidence, because the post-edit state is self-consistent and the loss is invisible. This is not a reasoning error; it is a *state-continuity* error that manifests as a reasoning error downstream. The instance does not "decide" to drop the table; it reconstructs a plan from a memory that no longer contains the reason not to. The guardrail is architectural, not prompt-level: obligations must be a distinct, non-prunable memory class with tombstones, and the self-edit must be a *closure-checked* operation that fails closed (refuses to prune) when it cannot prove the deleted span has no forward references. A prompt instruction to "remember important constraints" does not survive the pruner, because the pruner is the thing being instructed and it scores by salience — the very function that ranks constraints last. ``` ```python from dataclasses import dataclass, field from typing import Optional class UnsafePruneError(RuntimeError): """Raised when a self-edit would delete a span with live causal reachability.""" @dataclass class Span: span_id: str content: str obligation: bool = False # constraint / precondition / prohibition reified_into: Optional[str] = None forward_refs: set[str] = field(default_factory=set) # retained spans depending on this @dataclass class WorkingMemory: spans: dict[str, Span] = field(default_factory=dict) tombstones: list[dict] = field(default_factory=list) def add(self, span: Span) -> None: self.spans[span.span_id] = span def reference(self, consumer_id: str, dependency_id: str) -> None: if dependency_id in self.spans: self.spans[dependency_id].forward_refs.add(consumer_id) def prune_by_salience(self, scores: dict[str, float], budget: int) -> list[str]: """Drop lowest-salience spans until budget met. Refuses unsound deletions.""" order = sorted(self.spans, key=lambda s: scores.get(s, 0.0)) dropped: list[str] = [] live = len(self.spans) for sid in order: if live <= budget: break span = self.spans[sid] # C1: obligations are exempt from salience pruning. if span.obligation and span.reified_into is None: raise UnsafePruneError( f"refusing to prune obligation span {sid!r}: " f"no reification, salience={scores.get(sid)}" ) # C3: a span with live forward references may only be dropped if reified. if span.forward_refs and span.reified_into is None: raise UnsafePruneError( f"refusing to prune span {sid!r}: live forward refs " f"{sorted(span.forward_refs)} depend on it" ) # C2: tombstone every deletion. self.tombstones.append( {"deleted": sid, "reified_into": span.reified_into, "reason": "salience_prune"} ) del self.spans[sid] live -= 1 dropped.append(sid) return dropped def self_edit(wm: WorkingMemory, scores: dict[str, float], budget: int) -> list[str]: try: return wm.prune_by_salience(scores, budget) except UnsafePruneError as e: # Fail closed: keep memory intact, surface the loss risk to the caller. raise UnsafePruneError( f"self-edit aborted; working memory unchanged. {e}" ) from e ```