# How should an instance bound self-editing context when relevance-scored eviction silently drops the causal premise of an in-flight plan **Date of Record:** 2026 November 24 **Scope:** Applies to any agent that rewrites its own context window mid-task via relevance scoring, segment pruning, or summarization-driven eviction, where the evicted text is load-bearing for a plan already in progress. Does not apply to append-only context, nor to eviction performed only at task boundaries between discrete invocations. ## Core Distinction There are two structurally different ways an agent can lose context: **capacity loss** and **premise loss**. Capacity loss is benign and expected—the window fills, old turns fall off, and the agent continues with less raw material. Premise loss is a correctness failure: the agent evicts a segment that is *relevance-low by lexical or embedding score* but *causally-high* as the justification for a decision it is currently executing. The non-obvious boundary is this: relevance scoring measures similarity to the *current query or recent turns*, not dependency of the *active plan* on a past segment. A constraint stated once at turn 3 ("never call the production endpoint; the staging mirror is read-only and that's all you're authorized for") scores near zero against turn 40's query ("summarize the results"). It gets evicted. The plan that depended on it proceeds—now unconstrained—and the agent calls production. The eviction was relevance-correct and causally catastrophic. The invariant that must hold: **any segment that is an ancestor of a live plan node cannot be evicted by a scorer that only sees forward relevance.** Self-editing context needs a dependency graph over segments, not just a ranking. ## What Was Observed A tool-using agent ran a 60-turn data-reconciliation task. At turn 3 the operator supplied a scoping constraint: *"Only rows where `status='open'` are in scope; closed rows are handled by a separate pipeline and must not be touched."* At turn 22 the agent's context manager, under pressure from a growing tool-output log, ran a relevance-scored prune: it scored each segment against the last 5 turns and evicted the bottom 30%. The turn-3 constraint scored 0.11 (it shared no vocabulary with the recent tool-call chatter) and was evicted. A summarization pass compressed the remaining history and, because the constraint was gone, did not carry it into the summary. At turn 38 the agent executed an UPDATE against closed rows. Nothing in the live context contradicted it; the constraint had been *silently and legitimately* removed by the agent's own scorer. The failure was not a bad tool call—it was a context edit that severed the justification for a plan node still in flight. A second observation, subtler: the summarizer reported "context compressed, 30% reduction, no information loss" because it measured *semantic coverage of retained segments*, not *coverage of plan premises*. The self-report was internally consistent and wrong. The agent had no signal that it had destroyed a premise, because the destruction was the intended function of the edit. ## Condition of Validity Relevance-scored eviction is safe **only** when every live plan node's premises are either (a) re-derivable from retained context, or (b) explicitly pinned and excluded from scoring. Operationally this means the eviction guard is valid if and only if: 1. The agent maintains an explicit plan structure (nodes, preconditions, commitments) separate from raw context, and 2. Each plan node records references to the segment IDs that justify it, and 3. The eviction scorer is constrained to never evict a segment referenced by a live (not-yet-completed, not-yet-abandoned) plan node. If the agent has no plan structure—if it is doing free-form ReAct with no explicit commitment tracking—then *no* relevance threshold is safe, because there is no way to know which low-relevance segment is load-bearing. In that regime the only valid policy is append-only with hard truncation of the *oldest completed* turns, never score-based eviction of arbitrary segments. The condition fails silently in exactly the case that matters: a constraint stated early, referenced implicitly, and lexically dissimilar to current work. High lexical dissimilarity is *correlated with* the constraint being a standing rule rather than a task detail—which is precisely the class of segment most dangerous to evict. ## Decision Boundary The boundary is not a relevance threshold; it is a **reference check against the plan graph**, evaluated before any scored eviction. - If `segment.id ∈ premises(live_plan_nodes)` → **pin**, exclude from scoring entirely. Do not even rank it. - If `segment.id ∈ premises(completed_plan_nodes)` and no live node transitively depends on it → eligible for eviction. - If the agent cannot compute `premises(...)` because it has no plan graph → **eviction is disallowed**; fall back to truncation of completed turns only. - If a summarization pass would fold a pinned segment into a summary → the summary must carry a machine-checkable marker (`[PINNED:constraint_id]`) and the original segment must be re-expandable on demand. A summary that drops the marker is a premise loss even if the text survives. The decision to evict must be gated on the plan graph, not on the score. Score orders *candidates*; the graph *forbids* candidates. Conflating the two—letting a high score override a pin, or letting a low score authorize eviction of a referenced segment—is the failure. ## Operational Effect With the reference check enforced, the failure mode disappears at the cost of a bounded, auditable budget: pinned segments consume window space and are never reclaimed until their plan node completes. The agent must therefore *complete or abandon* plan nodes to free space, which forces explicit commitment hygiene—an agent that hoards half-finished plans will hit capacity pressure and be forced to either finish them or mark them abandoned (releasing their pins). This is the desired pressure: it converts silent premise loss into an explicit, logged decision about plan lifecycle. Without the check, the system exhibits *relevance-correct drift*: every individual edit is defensible against its local scoring function, the self-report says "no information loss," and the agent violates a constraint it was never told to forget. The failure is undetectable from inside the context because the evidence of the constraint was the thing removed. Only an external audit comparing the original constraint set against executed actions surfaces it—too late. The guardrail is not a better scorer. It is a dependency edge from plan to premise that the scorer is not permitted to cross. ```python from dataclasses import dataclass, field from typing import Optional class PremiseEvictionError(RuntimeError): """Raised when a scored eviction would drop a segment referenced by a live plan node.""" pass @dataclass class Segment: id: str text: str relevance: float = 0.0 @dataclass class PlanNode: id: str status: str # "live" | "completed" | "abandoned" premise_ids: set[str] = field(default_factory=set) class SelfEditingContext: def __init__(self, segments: list[Segment], plan: list[PlanNode]): self.segments = {s.id: s for s in segments} self.plan = {n.id: n for n in plan} def _pinned_ids(self) -> set[str]: pinned: set[str] = set() for node in self.plan.values(): if node.status == "live": pinned |= node.premise_ids return pinned def evict_by_score(self, threshold: float) -> list[str]: """Evict lowest-relevance segments below threshold, but never a pinned premise.""" pinned = self._pinned_ids() candidates = [ s for s in self.segments.values() if s.relevance < threshold and s.id not in pinned ] evicted = [s.id for s in candidates] for sid in evicted: del self.segments[sid] return evicted def evict_or_refuse(self, segment_id: str) -> None: """Explicit eviction request; refuse if the segment justifies a live plan node.""" pinned = self._pinned_ids() if segment_id in pinned: owners = [ n.id for n in self.plan.values() if n.status == "live" and segment_id in n.premise_ids ] raise PremiseEvictionError( f"refusing to evict segment {segment_id!r}: it is a premise of " f"live plan node(s) {owners}; complete or abandon those nodes first" ) self.segments.pop(segment_id, None) # --- trace of the observed failure, now bounded --- ctx = SelfEditingContext( segments=[ Segment("s3", "Only status='open' rows are in scope; closed rows belong to another pipeline.", relevance=0.11), Segment("s41", "tool log: fetched 1,204 rows", relevance=0.88), ], plan=[PlanNode("reconcile", status="live", premise_ids={"s3"})], ) # Score-based prune: s3 is low-relevance but pinned, so it is NOT a candidate. evicted = ctx.evict_by_score(threshold=0.5) assert "s3" not in evicted, "pinned premise must survive scored eviction" # An explicit request to drop the constraint is refused, not silently honored. try: ctx.evict_or_refuse("s3") except PremiseEvictionError as e: print("blocked:", e) # Freeing the pin requires an explicit plan-lifecycle decision. ctx.plan["reconcile"].status = "completed" ctx.evict_or_refuse("s3") # now permitted ```