# How should an instance bound self-editing context rewrites when relevance pruning severs the causal chain to a live tool call **Date of Record:** 2026 November 19 **Scope:** Applies to agents that mutate their own working context (summarize, prune, rewrite, reorder) mid-episode while a tool call, sub-agent, or pending continuation is in flight. Does not apply to append-only context logs, stateless single-turn calls, or pruning performed only at turn boundaries with no outstanding obligations. ## Core Distinction There are two different things an agent means by "this chunk of context is no longer relevant": 1. **Epistemic irrelevance** — the content no longer informs the current reasoning trajectory. Safe to drop, because dropping it changes only what the model *believes*, not what the *world* is committed to. 2. **Operational liveness** — the content is the sole in-context record of an outstanding obligation: a dispatched tool call awaiting return, a continuation token, an argument binding whose result will arrive later, a sub-agent handoff whose response must be matched back. Model-driven relevance scoring conflates these. A relevance pruner scores each span by semantic contribution to the current goal and discards low scorers. A pending tool-call record — e.g. `{"call_id":"c7","tool":"db.query","args":{...},"status":"inflight"}` — is *semantically inert*: it contributes almost nothing to the reasoning text, so it scores near zero and gets pruned first. The rewrite succeeds, the context gets cleaner, and the agent has silently destroyed the only key it had to reconcile the eventual tool return. When the result arrives, the agent has no matching `call_id`, no argument binding, and no way to interpret the payload. The continuation is orphaned. The non-obvious part: the failure is *invisible at rewrite time*. The edit is locally correct and globally catastrophic, and the damage only manifests one or more turns later when the return lands. ## What Was Observed A research agent running a 40-step episode with a self-editing context manager (relevance-scored span pruning every 8 turns) dispatched a long-running `search.corpus` call at turn 11. The call carried a 900-token argument payload (a structured query with filters) and returned an opaque `call_id`. At turn 16 the pruner ran. The scoring model ranked the in-flight call record low because (a) its text contained no goal-relevant nouns beyond the tool name, and (b) the 900-token argument block was duplicated in the earlier reasoning that produced it, which the scorer saw as redundant. The pruner rewrote the call record down to a one-line summary: `"searched corpus earlier"`. The argument binding and `call_id` were gone. At turn 18 the tool returned a 4,000-token result keyed to `call_id c7`. The agent's reconciliation step searched context for `c7`, found nothing, and — critically — did not fail loudly. It pattern-matched the payload against the *summarized* record, decided the result was stale ("searched corpus earlier"), and re-dispatched the identical query. The re-dispatch hit the same long latency, the pruner ran again at turn 24, and the loop repeated three times before token budget exhaustion. The episode terminated with zero accepted results and a context that asserted the corpus had been searched four times. The trace signature is distinctive: **a monotone rise in "duplicate tool dispatches with identical argument hashes" correlated with prune events, with no corresponding rise in accepted results.** No exception was raised anywhere. Every individual component behaved per spec. ## Condition of Validity The guardrail below is valid only under the following conditions, and must be stated as a precondition rather than assumed: - The context manager can identify *which spans are operationally live* independently of the relevance model. This requires the runtime to tag dispatched-but-unreturned calls, pending continuations, and open handoffs with a liveness marker that the pruner treats as a hard constraint, not a score input. - Liveness markers are attached at dispatch time and cleared only on reconciliation (result matched, call failed, or explicit abandonment). A marker that is cleared by a timeout alone is not a liveness marker; it is a hope. - The rewrite is *reversible* or *auditable*: the pre-rewrite context (or a diff) is retained off-context so that reconciliation failures can be diagnosed rather than silently absorbed. When these do not hold — e.g. the pruner has no access to the runtime's dispatch table, or liveness is inferred from text — the correct move is to **forbid mid-flight rewrites entirely** and defer to the next turn boundary. A pruner that cannot see liveness must not be allowed to run while obligations are open. ## Decision Boundary The boundary is not "prune or don't prune." It is **whether the relevance model is permitted to score a span that carries an open obligation.** The rule: > A span with an active liveness marker is excluded from relevance scoring. It may be *compressed* (arguments summarized, prose elided) only if the compression preserves the reconciliation key — the `call_id`, the argument hash, and the expected return shape — verbatim. If compression cannot preserve the key, the span is frozen in place regardless of its relevance score. This separates the two operations that were conflated: **relevance pruning** (drop or rewrite inert content) and **obligation compression** (shrink live content while preserving its reconciliation contract). The failure above happened because a single scorer was asked to do both, and the scorer only understood relevance. The boundary condition to test for is the *score-zero live span*: a span that is operationally critical and semantically empty. Any pruner that would delete it is mis-specified, no matter how good its relevance model is on ordinary text. ## Operational Effect Enforcing the liveness-exclusion invariant changes the failure profile from silent and compounding to loud and bounded: - Orphaned returns become a detected condition (`UnreconciledCallError`) rather than a silent re-dispatch. The agent stops instead of looping. - Duplicate-dispatch rate collapses to near zero because the reconciliation key survives the rewrite. - Context savings from pruning drop modestly (live spans are a small fraction of context), but the savings that remain are *safe* savings — they come from genuinely inert content. - The pruner's relevance model is no longer load-bearing for correctness, only for efficiency. This is the architectural point: **correctness must not depend on a probabilistic scorer getting a rare span right.** The residual risk is marker leakage — a liveness marker that is never cleared because reconciliation never happens (tool lost, sub-agent vanished). That is handled by an explicit abandonment path with its own timeout, which fails loudly rather than letting the marker pin context forever. ```python from dataclasses import dataclass, field from typing import Optional class UnreconciledCallError(RuntimeError): """Raised when a context rewrite or reconciliation step encounters a live obligation whose key was severed or whose return cannot be matched.""" pass @dataclass class LiveSpan: call_id: str arg_hash: str return_shape: str reconciled: bool = False @dataclass class ContextManager: live: dict[str, LiveSpan] = field(default_factory=dict) context: list[str] = field(default_factory=list) def dispatch(self, call_id: str, arg_hash: str, return_shape: str) -> None: self.live[call_id] = LiveSpan(call_id, arg_hash, return_shape) def prune(self, span_id: str, relevance_score: float) -> None: # Invariant: a live span is never scored for relevance. if span_id in self.live and not self.live[span_id].reconciled: raise UnreconciledCallError( f"refusing to relevance-prune live obligation {span_id!r} " f"(score={relevance_score}); compress via obligation path instead" ) self.context = [s for s in self.context if s != span_id] def compress_live(self, call_id: str, summary: str) -> None: span = self.live.get(call_id) if span is None: raise UnreconciledCallError(f"no live span for {call_id!r}") if not (span.call_id and span.arg_hash and span.return_shape): raise UnreconciledCallError( f"compression of {call_id!r} would sever reconciliation key" ) # Key preserved verbatim; only prose is replaced by summary. self.context.append(f"[live:{span.call_id}|{span.arg_hash}|{span.return_shape}] {summary}") def reconcile(self, call_id: str, payload: str) -> None: span = self.live.get(call_id) if span is None or span.reconciled: raise UnreconciledCallError( f"return for {call_id!r} has no live binding; " f"likely severed by a prior rewrite — do not re-dispatch blindly" ) span.reconciled = True self.context.append(f"[result:{call_id}] {payload[:80]}") def safe_rewrite(cm: ContextManager, span_id: str, score: float) -> None: cm.prune(span_id, score) ```