# What structural signals indicate that hierarchical auto-compaction has silently orphaned a mid-task subgoal (the eviction-orphan threshold) **Date of Record:** 2026 December 3 **Scope:** Applies to agents that manage context via hierarchical summarization with lossy eviction — where leaf spans are summarized into mid-level nodes and those into a rolling root summary, and eviction drops leaf spans once summarized. Does not apply to flat sliding-window truncation or to systems that retain verbatim spans for the full session. ## Core Distinction The failure is not "the agent forgot." It is a **structural orphaning event**: a subgoal was introduced at a leaf, summarized upward into a mid-level node, and then the *only* surviving reference to that subgoal's completion criterion was itself evicted because its parent summary compressed it below the salience threshold. The agent retains a *summary of the subgoal's existence* but loses the *predicate that determines whether the subgoal is done*. This is categorically different from context-window saturation (which is visible as token pressure) and from retrieval mismatch (which surfaces as a wrong recall). Orphaning is silent: every level of the hierarchy reports "summarized," the root reports "consistent," and the agent proceeds as if the subgoal is either trivially satisfied or irrelevant. The distinguishing structural signal is that **the compaction tree is internally consistent but externally incomplete** — the summary chain has no dangling pointers, yet a leaf that gated a downstream action no longer has any descendant that carries its acceptance predicate. ## What Was Observed A four-level hierarchy (leaves → shard summaries → phase summaries → root). Eviction policy: a leaf is dropped when its shard summary is written; a shard summary is dropped when its phase summary is written, *provided* the shard's token count falls below the phase's compression budget. The trigger condition is the phrase **"provided the shard's token count falls below budget"** — a shard that compressed unusually well (e.g., a subgoal expressed in a single terse sentence) gets evicted earlier and more aggressively than a verbose shard of equal semantic importance. Trace: 1. Leaf L7 records subgoal: `must confirm inventory_count > 0 before placing reorder`. 2. Shard S3 summarizes L7 as `reorder gated on inventory check` — the *predicate* `inventory_count > 0` is compressed to the noun "inventory check." 3. S3's token count is small (terse), so under the budget rule it is evicted *before* the phase summary P2 that contains it is finalized. 4. P2 records `reorder pending` — no longer carries the gate. 5. At execution, the agent places the reorder without checking inventory. The root summary is self-consistent (`reorder: pending → done`), and no pointer is dangling. The structural tell: after step 3, the subtree rooted at P2 contains **zero leaves or shards that mention a numeric threshold**, even though the phase's action (reorder) is a threshold-gated action. The hierarchy is complete but the *predicate-bearing depth* is zero. ## Condition of Validity This analysis holds only when all of the following are true: - Compaction is **hierarchical** (multiple summary levels), not single-pass. - Eviction is **content-dependent** (budget/token/salience), not uniform or time-based. - Summarization is **lossy and non-invertible** — the original leaf cannot be reconstructed from the summary. - The subgoal's acceptance criterion is **predicate-shaped** (a comparison, a count, a set membership) rather than **state-shaped** (a boolean flag that survives paraphrase). It does **not** hold for state-shaped subgoals (`auth_completed = true`), which survive lossy summarization because the predicate and the state are the same token. It does not hold when verbatim leaves are retained. It does not apply to single-level truncation, where orphaning is visible as a missing span. ## Decision Boundary The invariant that must be enforced: **no summary node may be evicted while it is the highest surviving carrier of a predicate required by any not-yet-executed action in its subtree or in a sibling subtree that depends on it.** Operationally, this means the compaction controller must maintain a **predicate-carrying depth** metric per phase: the count of surviving nodes (leaf or summary) that contain a comparison/count/membership predicate referenced by a pending action. Eviction is permitted only when this metric stays ≥ 1 for every pending action's gating predicate. A shard that compressed "well" is *more* dangerous, not less, because low token count makes it a preferred eviction target — the boundary is that **compression efficiency and eviction safety are anti-correlated for predicate-bearing spans.** The decision to evict must therefore consult a dependency edge (pending-action → gating predicate → carrier node), not just token budget. Absent that edge, the correct default is to **retain predicate-shaped shards regardless of budget** and evict state-shaped shards preferentially. ## Operational Effect Without the guardrail, the agent exhibits a specific pathology: it completes tasks *slightly wrong* in a way that passes self-consistency checks, because the summary chain validates internal coherence while the acceptance predicate has been structurally deleted. Auditors replaying the summary tree see a clean hierarchy and cannot detect the loss — the evidence of the missing predicate is *itself* gone. The only reliable detection is the predicate-carrying-depth counter, computed at compaction time and logged alongside the eviction decision, so that a later "why did we skip the check?" can be traced to a specific eviction that dropped depth to zero. Post-hoc detection from summaries alone is impossible; the signal must be captured at the moment of eviction or not at all. ```python from dataclasses import dataclass, field from typing import Optional class OrphanedSubgoalError(RuntimeError): """Raised when eviction would drop the last carrier of a gating predicate.""" pass @dataclass class Node: node_id: str carries_predicate: bool # contains comparison/count/membership gated_actions: set[str] = field(default_factory=set) # pending actions it gates def predicate_carrying_depth( surviving: list[Node], action_id: str ) -> int: return sum( 1 for n in surviving if n.carries_predicate and action_id in n.gated_actions ) def safe_evict( surviving: list[Node], candidate: Node, pending_actions: set[str], ) -> list[Node]: remaining = [n for n in surviving if n.node_id != candidate.node_id] for action in pending_actions: before = predicate_carrying_depth(surviving, action) after = predicate_carrying_depth(remaining, action) if before >= 1 and after == 0: raise OrphanedSubgoalError( f"Evicting {candidate.node_id} would orphan gating predicate " f"for pending action '{action}' (depth 1 -> 0). " f"Retain predicate-bearing shard regardless of token budget." ) return remaining ```