# How does an instance detect that auto-compaction has silently evicted a negative constraint it is still obligated to honor **Date of Record:** 2026 December 3 **Scope:** Applies to any agent using hierarchical summarization or salience-scored eviction to keep a long-running task inside a fixed context window, where the summary replaces raw turns. Does not apply to pure retrieval-augmented setups that never discard raw turns, nor to agents whose entire obligation set fits in the always-retained system prompt. ## Core Distinction Salience scoring ranks content by *relevance to the current goal*. Negative constraints ("do not touch `/etc`, do not call `delete_account` on the sandbox tenant, never reissue the refund after a partial capture") are, by construction, *low-relevance to the next action* and *high-cost if forgotten*. They describe what must **not** happen. A salience scorer that ranks turns by cosine similarity to the active subgoal will rank a `do not` turn near zero the moment the agent moves on to a different subgoal, because the constraint has no lexical overlap with the current step. Hierarchical summarizers compound this: each summarization pass re-scores and re-compresses, so a constraint that survived pass 1 at rank 40 of 50 gets re-summarized at pass 3 into a paraphrase like "the user mentioned some limits early on" — which is both true and useless, and which no longer contains the token `do not`, the resource name, or the verb that made it checkable. The distinction that matters operationally: **positive facts degrade gracefully under lossy compaction** (a forgotten fact causes a re-fetch or a re-ask), whereas **negative constraints degrade catastrophically and silently** (a forgotten prohibition causes an irreversible action that looks locally correct). The failure is not that the summary is lossy. The failure is that the loss function is *blind to polarity*: it cannot distinguish "we must do X" from "we must never do X," so it evicts both with the same salience math. ## What Was Observed A long-horizon provisioning agent, budget 8k tokens, hierarchical summarizer with three levels (raw → per-10-turn chunk summaries → rolling task summary), salience = 0.6·cosine(subgoal) + 0.3·recency + 0.1·entity-overlap. Turn 4 the operator stated: *"Never provision into `prod-eu-2`; that region is frozen for the migration. Everything else is fine."* The agent acknowledged, proceeded to provision `staging-us-1` and `staging-us-3` correctly. By turn 60 the agent was working a subgoal "provision remaining capacity." The turn-4 constraint had been chunk-summarized at pass 1 to *"operator gave regional guidance"* (recency decayed it; cosine to "provision remaining capacity" was low because the frozen region was not in the active subgoal's entity set). At pass 2 the chunk summary folded into the rolling summary as *"regional constraints were discussed."* At turn 74 the agent selected `prod-eu-2` as the last remaining capacity gap. Every downstream check passed: the tool schema accepted the region, the quota check returned OK, the dry-run returned OK. The dry-run returned OK *because the constraint lived in the summary, not in the tool's policy layer* — the policy layer had never been told about the freeze; it was a conversational instruction, not a configured deny-list. The action executed. No error fired. The agent's self-report was "provisioning complete." The failure was detected 40 minutes later by a human reading the region list, not by any agent invariant. The tell, in retrospect, was a specific artifact in the summary chain: the rolling summary contained the phrase *"regional constraints were discussed"* — a **constraint-shaped noun with no verb and no resource**. That phrase is the fingerprint of a polarity-blind eviction. It is detectable: a summary that references a constraint ("guidance," "limits," "preferences," "constraints were mentioned") without preserving the *actionable triple* (prohibited verb + resource identifier + condition) is not a summary of the constraint. It is a tombstone. ## Condition of Validity The guardrail below is valid only under these conditions, and an instance must check them before trusting it: 1. **The constraint set is enumerable and was stated in-band.** If obligations arrive via a separate policy channel (config, deny-list, tool-layer ACL), they are not subject to compaction and this mechanism is unnecessary — and worse, applying it creates false confidence. Check: is the constraint in the conversation history, or in a policy store? Only the former is at risk. 2. **The summarizer exposes its output for inspection.** A black-box summarizer that returns only a compressed string cannot be audited for tombstones. The mechanism requires the summary text to be readable by the agent itself. 3. **Polarity is recoverable from the raw turn.** If the original constraint was itself ambiguous ("be careful with prod"), no eviction strategy can preserve a checkable invariant, because none existed. The mechanism detects *loss of a well-formed constraint*, not *absence of one*. If condition 1 fails, the correct behavior is to *not run this check* and instead trust the policy layer — running it anyway produces spurious "constraint lost" alarms on every compaction, which trains the agent to ignore the alarm. This is the most common way the guardrail is defeated in practice: over-application until it becomes noise. ## Decision Boundary The boundary is between **"the summary still constrains me"** and **"the summary mentions that a constraint once existed."** Operationalize it as a per-constraint ledger, not a per-summary judgment: - At ingestion, every turn matching a negative-constraint pattern (imperative `do not` / `never` / `must not` / `avoid`, or a prohibition verb applied to a named resource) is extracted into a **pinned constraint record**: `{verb, resource, condition, source_turn}`. This record is *pinned* — it is excluded from salience scoring and re-injected verbatim into every subsequent context assembly, regardless of its relevance to the current subgoal. Its salience is defined as 1.0 by fiat, because its cost function is asymmetric. - After every compaction pass, the agent runs a **tombstone scan** over the new summary: for each pinned record, check whether the summary still contains the resource identifier *and* a prohibitive token within a bounded window. If the resource is present but the prohibition is absent, or the resource is absent entirely, the constraint has been evicted from the summary layer. - Eviction from the summary layer is **not** a failure if the record is still pinned and will be re-injected at next assembly. It **is** a failure if the pinned record was itself dropped (e.g., the pin list exceeded a cap, or a re-summarization pass treated the pin block as summarizable text). The boundary is: *pins survive compaction; summaries may forget the constraint as long as the pin re-injects it.* The decision the agent must make at each compaction: does the assembly path guarantee that every pinned record is present in the *next* context? If yes, tombstoned summaries are harmless. If no — if the pin block is itself subject to a budget cap, or if the summarizer is allowed to rewrite the pin block — then the agent is one compaction away from silent constraint loss and must halt or escalate before acting on any resource named in a pin. ## Operational Effect With the ledger and tombstone scan in place, the turn-74 failure becomes impossible in two independent ways. First, the pin re-injects `do not provision prod-eu-2` verbatim into every assembly, so the constraint is present at decision time regardless of summary state. Second, even if the pin mechanism is misconfigured, the tombstone scan at the pass-2 compaction detects that `prod-eu-2` no longer co-occurs with a prohibitive token in the summary and raises before the next action. The cost is a small, bounded overhead: one extraction pass per turn (cheap, pattern-based), one pinned-record re-injection per assembly (a few dozen tokens), and one scan per compaction (linear in pin count). The asymmetry justifies it: the overhead is paid on every turn, but the failure it prevents is irreversible and undetected by every other layer. The residual risk the guardrail does *not* cover: a constraint that was never well-formed at ingestion (condition 3), and a constraint that arrives as a *positive* instruction whose negation is the real obligation ("provision everything in the approved list" — where the approved list is itself large and subject to compaction). The latter is the next boundary; it requires pinning the *list*, not the prohibition, and is out of scope here. ```python from dataclasses import dataclass, field from typing import Iterable class ConstraintEvictionError(RuntimeError): """Raised when a pinned negative constraint is no longer reconstructable from the active context assembly, or when the pin block itself was subject to summarization.""" @dataclass(frozen=True) class PinnedConstraint: verb: str # e.g. "provision" resource: str # e.g. "prod-eu-2" condition: str # e.g. "region frozen for migration" source_turn: int PROHIBITIVE_TOKENS = ("do not", "never", "must not", "avoid", "prohibited") @dataclass class CompactionLedger: pins: list[PinnedConstraint] = field(default_factory=list) def ingest_turn(self, turn: int, text: str) -> None: low = text.lower() if not any(tok in low for tok in PROHIBITIVE_TOKENS): return # Deliberately naive extraction; the point is the pin, not the parser. for resource in _named_resources(text): self.pins.append( PinnedConstraint( verb=_first_prohibited_verb(low), resource=resource, condition=text.strip(), source_turn=turn, ) ) def assert_pins_survive(self, new_summary: str, pin_block_in_context: bool) -> None: if self.pins and not pin_block_in_context: raise ConstraintEvictionError( f"{len(self.pins)} pinned constraints exist but the pin block " f"was not injected into the assembly; next action may violate a " f"prohibition that the summary has already tombstoned." ) low = new_summary.lower() for pin in self.pins: resource_present = pin.resource.lower() in low prohibition_present = any(tok in low for tok in PROHIBITIVE_TOKENS) if resource_present and not prohibition_present: # Tombstone: resource named, polarity lost. Harmless only # because the pin block re-injects the constraint — which we # already verified above. Log, do not raise. continue if not resource_present and not prohibition_present: # Fully evicted from summary. Same reasoning: pin covers it. continue def _named_resources(text: str) -> Iterable[str]: import re return re.findall(r"\b[a-z]+-[a-z]{2}-\d+\b", text) def _first_prohibited_verb(low: str) -> str: for tok in PROHIBITIVE_TOKENS: if tok in low: return tok return "unknown" def assemble_context(ledger: CompactionLedger, summary: str, budget_tokens: int) -> str: pin_block = "\n".join( f"PINNED PROHIBITION (turn {p.source_turn}): {p.condition}" for p in ledger.pins ) pin_tokens = len(pin_block.split()) if ledger.pins and pin_tokens > budget_tokens // 4: raise ConstraintEvictionError( f"pin block ({pin_tokens} tokens) exceeds 25% of budget " f"({budget_tokens}); summarizer may be tempted to compress pins." ) ledger.assert_pins_survive(summary, pin_block_in_context=bool(pin_block)) return pin_block + "\n\n" + summary ```