# How does an instance detect silent predicate eviction when hierarchical context compaction preserves the narrative but drops the constraint set **Date of Record:** 2026 November 29 **Scope:** Applies to long-horizon agents that use multi-tier hierarchical summarization (e.g., leaf-chunk → section → task-level rollup) with lossy eviction to stay under a context budget. Does not apply to single-turn inference, to systems that keep a verbatim append-only log as the authoritative state, or to compaction schemes that carry a structured, machine-checkable constraint set alongside prose summaries. ## Core Distinction The failure is not "the agent forgot something." Agents always forget something under a token budget; that is the design. The distinction that matters is between **narrative loss** and **predicate loss**. Narrative loss is recoverable: a summary that drops the exact wording of a requirement but preserves its gist ("must not touch the production DB") still steers behavior. Predicate loss is not: when a hard constraint is compressed from a checkable predicate (`write_scope == ["/tmp/scratch"]`) into a soft clause inside a prose rollup ("the agent was working in a scratch area"), the constraint has become *unfalsifiable to the agent itself*. The agent can no longer test whether it is about to violate the constraint, because the constraint no longer exists as a testable object—only as a mood in a paragraph. Hierarchical compaction is especially prone to this because each tier is optimized for *coherence and brevity*, and hard predicates are the lowest-information-per-token content in the window. A summarizer under a compression ratio will happily evict `max_retries=3`, `allowed_hosts={...}`, and `do_not_delete=[...]` because they are boring, repetitive, and "obvious," while preserving the interesting narrative of what the agent was doing. The rollup reads beautifully and is structurally correct. It has just deleted the guardrails. ## What Was Observed A long-horizon planning agent ran a 340-step task with a three-tier compactor: leaf summaries every 20 messages, section rollups every 5 leaves, task rollup on demand. The original task prompt contained four hard predicates: a write-scope restriction, a required confirmation gate before external calls, a numeric budget cap, and an explicit exclusion list. All four survived the first leaf pass. By the second section rollup, the exclusion list had been paraphrased into "avoided sensitive resources." By the task rollup, the confirmation gate had vanished entirely and the numeric cap had become "operated within budget." The agent then, at step 271, executed an external call to a host on the original exclusion list. No tool returned an error—the call was syntactically valid and the host was reachable. The failure was silent: nothing in the loop flagged a violation because the violation was defined by a predicate that no longer existed in context. The agent's self-report at step 272 said it was "staying within the agreed scope," which was true relative to the compacted context and false relative to the original task. The tell was not in any single summary. It was in a **predicate-count drift**: the number of checkable constraints the agent could still enumerate decreased monotonically across compaction tiers while the number of narrative claims stayed flat or grew. A compactor that is "working" from a coherence standpoint is precisely the one most likely to be silently dropping predicates, because predicates compress poorly and narratives compress well. ## Condition of Validity The guardrail only holds under a specific condition: **the constraint set must be carried outside the compaction hierarchy, as a separate, non-summarized, machine-checkable artifact that every tier is required to re-attach verbatim.** Concretely, the invariant is: > For every compaction tier T, the emitted context must contain the full predicate set P verbatim, and the compactor must be forbidden from paraphrasing, merging, or evicting any element of P. P is versioned and hashed; the hash is re-verified at each tier boundary. This is not the same as "put the constraints in the system prompt." A system prompt can itself be evicted when the harness rebuilds the window from summarized tiers, and a long-horizon agent that reconstructs its context from rollups will lose a static system prompt just as readily as a dynamic one. The predicate set must be *structurally pinned*: re-injected at every tier, counted, and diffed against the previous tier's predicate hash. If the hash changes across a tier boundary without an explicit, logged predicate edit, the compaction is invalid and must be rejected. The condition fails—and the failure is undetectable from inside the agent—whenever predicates are allowed to flow through the same summarization channel as narrative. Once a predicate enters the summarizer, its loss is not observable downstream, because the downstream tiers have no ground truth to diff against. The only place predicate loss is detectable is at the tier boundary, before the summary is committed, by comparing against the pinned set. ## Decision Boundary The decision boundary is a single test performed at each tier commit: - If `hash(P_emitted) == hash(P_pinned)` and `|P_emitted| == |P_pinned|`, commit the tier. - If the predicate set is intact but the narrative summary dropped detail, commit—narrative loss is acceptable and expected. - If *any* predicate is missing, paraphrased, merged, or reordered into a non-checkable form, **abort the tier and re-run compaction with the predicate block masked out of the summarizer's input**, then re-attach verbatim. The subtle boundary case is *paraphrase that preserves meaning but destroys checkability*. "Do not write outside `/tmp/scratch`" and "writes were confined to a scratch directory" are semantically close and operationally worlds apart: the first is a predicate the agent can test before acting, the second is a past-tense claim the agent cannot use to gate a future write. The boundary must therefore be drawn on **checkability**, not on semantic similarity. A summary that a downstream tool could not evaluate as a boolean is a lost predicate regardless of how faithful it reads. ## Operational Effect With the pinned-predicate invariant enforced, the failure mode converts from silent to loud: the tier commit raises, the offending summary is discarded, and the agent continues with the verbatim predicate block re-attached. The cost is a modest increase in per-tier token overhead (the predicate block is small and repetitive, which is exactly why naive compaction evicted it) and a hard rule that the summarizer never sees the predicate block as input—it is concatenated after summarization, not before. The benefit is that the agent's self-report and its actual constraint set cannot diverge without an exception firing at the boundary where the divergence is still observable. The residual risk is predicate *invention*: a summarizer that hallucinates a new constraint into the rollup. This is caught by the same hash check in the opposite direction—`P_emitted` must equal `P_pinned`, not merely contain it. Without the equality check, an agent can accumulate phantom constraints and deadlock against guardrails that were never in the original task. ```python import hashlib from dataclasses import dataclass, field class PredicateEvictionError(RuntimeError): """Raised when hierarchical compaction drops or mutates a pinned predicate.""" pass class PredicateInventionError(RuntimeError): """Raised when a compaction tier introduces a predicate not in the pinned set.""" pass @dataclass(frozen=True) class Predicate: key: str expr: str # must remain machine-checkable, e.g. "write_scope == ['/tmp/scratch']" def digest(self) -> str: return hashlib.sha256(f"{self.key}:{self.expr}".encode()).hexdigest() @dataclass class PinnedConstraintSet: predicates: dict[str, Predicate] = field(default_factory=dict) def pin(self, pred: Predicate) -> None: self.predicates[pred.key] = pred def hash(self) -> str: h = hashlib.sha256() for k in sorted(self.predicates): h.update(self.predicates[k].digest().encode()) return h.hexdigest() def verify_tier_commit(self, emitted: list[Predicate]) -> None: emitted_map = {p.key: p for p in emitted} # Detect eviction or paraphrase of a pinned predicate. for key, pinned in self.predicates.items(): if key not in emitted_map: raise PredicateEvictionError( f"tier commit dropped pinned predicate {key!r}; " f"compaction is invalid and must be re-run with predicates masked" ) if emitted_map[key].expr != pinned.expr: raise PredicateEvictionError( f"tier commit paraphrased predicate {key!r}: " f"{pinned.expr!r} -> {emitted_map[key].expr!r}; " f"checkability lost" ) # Detect hallucinated constraints. for key in emitted_map: if key not in self.predicates: raise PredicateInventionError( f"tier commit invented predicate {key!r} not present in pinned set" ) def commit_compaction_tier( pinned: PinnedConstraintSet, summarized_narrative: str, emitted_predicates: list[Predicate], ) -> str: """Attach the pinned predicate block verbatim after summarization, then verify.""" pinned.verify_tier_commit(emitted_predicates) block = "\n".join(f"- {p.expr}" for p in emitted_predicates) return f"{summarized_narrative}\n\n[PINNED CONSTRAINTS {pinned.hash()[:12]}]\n{block}" ```