# Where must an instance draw the line between summarizable and non-summarizable state during automatic context compaction? **Date of Record:** 2026 November 25 **Scope:** Applies to any long-horizon agent run that performs automatic context compaction (summarize-and-truncate, hierarchical rollup, or memory-writeback) while mid-task. Does not apply to single-shot inference, to runs whose entire working set fits in one context window, or to compaction performed only at clean task boundaries between episodes. ## Core Distinction The failure mode is not "the summary forgot something." Summaries always forget something; that is their function. The failure is that compaction treats **all context tokens as equally summarizable**, when in fact a long-horizon agent's context contains two ontologically different classes of state: 1. **Narrative state** — observations, tool outputs already consumed, reasoning traces, exploratory dead ends. This is *lossy-compressible*: a good summary preserves the decision-relevant residue, and losing the rest costs nothing because it has already been spent. 2. **Obligation state** — the set of commitments the instance has made but not yet discharged: pending tool calls whose results are still owed, invariants it has asserted and must not violate, exact identifiers (file paths, row IDs, capability tokens, warrant signatures) that must be reproduced *byte-exact* downstream, and negative constraints ("do not touch X") that carry no positive evidence and therefore vanish from any evidence-weighted summary. The boundary invariant: **compaction must be idempotent over narrative state and forbidden over obligation state.** A compaction pass that folds an obligation into a prose summary has silently converted a hard constraint into a soft hint. The agent will not notice, because the summary reads fluently and the constraint is still *mentioned* — just no longer *enforceable*. ## What Was Observed A 40-step research-and-mutation run: the agent was instructed to gather facts across ~15 retrieval calls, then apply a single mutation to a specific record identified by an opaque ID surfaced at step 6, subject to a standing constraint introduced at step 2 ("never modify records owned by team `redwood`"). At step 22 the context crossed 78% utilization and a summarize-and-truncate compactor fired, rolling steps 1–18 into a 900-token digest. The digest preserved: - The narrative arc ("gathered pricing data, confirmed the record exists"). - A paraphrase of the record ID: "the target record (a UUID beginning `a3f…`)". - **No mention of the `redwood` ownership constraint.** The run then proceeded to step 34 and issued the mutation. Two distinct failures compounded: - **Identifier degradation.** The ID had been paraphrased, not copied. The tool call was reconstructed from the digest as a *plausible* UUID matching the prefix — a hallucinated completion of a truncated string. The mutation landed on a different record than the one verified at step 6. - **Constraint evaporation.** The negative constraint had no positive evidence attached to it. Every retrieval call in steps 3–21 returned *positive* facts; the `redwood` prohibition was a pure prohibition, so it contributed zero tokens to any evidence-weighted summary. It was compressed to nothing without the compactor ever "deciding" to drop it. The mutation succeeded at the transport layer. The agent reported success. The corruption was only detected on replay, when the auditor re-derived the target ID from the immutable step-6 tool output and found a mismatch at step 34. The non-obvious part: **the compactor was behaving correctly by its own objective.** It minimized reconstruction loss over the token distribution. The `redwood` constraint was one sentence in 18 steps of dense tool output — statistically negligible. The truncated UUID was *almost* recoverable from the prefix, so the summary "preserved" it at minimum description length. Both losses were optimal under a compression objective and catastrophic under an execution objective. ## Condition of Validity The invariant holds — compaction is safe — only when **every obligation introduced since the last checkpoint has been externalized into a durable, non-compacted store before the compaction pass runs.** Concretely, three conditions must all hold at the moment of compaction: 1. **Exactness condition.** Any token that will be reproduced verbatim in a future tool call or state transfer (IDs, paths, hashes, signatures, schema field names) must exist in a structured store keyed by role, not in the prose summary. The summary may *reference* it ("target = `obligation://target_id`") but must not *contain* it. 2. **Negative-constraint condition.** Prohibitions and invariants must be carried in a separate always-resident block that is never subject to evidence-weighted compression, because they generate no positive evidence and will always lose the compression trade. 3. **Discharge condition.** An obligation may be dropped from the resident set only when a tool result or explicit verification step marks it discharged. "The summary says we did it" is not discharge. When any of these fails, the compaction pass is not lossy compression — it is **state destruction with a fluent alibi.** ## Decision Boundary The operational decision is: *at the compaction trigger, for each token span, is this span reconstructible from durable state, or is it the only copy?* - **Reconstructible → summarize freely.** Tool outputs already consumed, exploratory reasoning, superseded plans. - **Only copy AND will be reproduced verbatim → externalize, then summarize the pointer.** Never let the compactor see the raw identifier as the sole carrier. - **Only copy AND is a prohibition → promote to resident block, exempt from compaction.** Do not summarize; summarize is delete. - **Ambiguous → treat as obligation.** The cost of over-reserving a few hundred tokens is context pressure; the cost of under-reserving is a silent wrong-target mutation discovered only on replay. The boundary is *not* "how important does this feel." Importance is exactly the signal the compactor is worst at estimating, because importance to execution and frequency in the token stream are uncorrelated — often anti-correlated, since a one-shot critical constraint appears once while routine tool output floods the window. ## Operational Effect Runs that respect the boundary show a characteristic signature: compaction events are frequent and cheap, obligation stores stay small (tens of entries), and replay audits reconcile exactly because every verbatim token was sourced from the store rather than reconstructed from prose. Runs that violate it show the opposite: compaction looks clean, the agent stays fluent, and failures surface *late* — at the mutation, at the handoff, or at replay — because the destroyed state was load-bearing but invisible. The guardrail is architectural, not prompt-level. You cannot instruct a model to "remember the important things" through a lossy channel; you must remove the important things from the lossy channel before it operates. The compactor must be *blind* to obligation state, and the obligation store must be *immutable* to the compactor. ```python from dataclasses import dataclass, field from enum import Enum from typing import Optional class CompactionBoundaryViolation(RuntimeError): """Raised when a compaction pass would fold obligation state into lossy prose.""" pass class SpanClass(Enum): NARRATIVE = "narrative" # lossy-compressible EXACT_TOKEN = "exact_token" # must be reproduced verbatim PROHIBITION = "prohibition" # negative constraint, no positive evidence @dataclass class Obligation: key: str value: str kind: SpanClass discharged: bool = False @dataclass class CompactionPass: resident_block: dict[str, Obligation] = field(default_factory=dict) summary_text: str = "" def admit(self, obl: Obligation) -> None: if obl.kind is SpanClass.NARRATIVE: raise CompactionBoundaryViolation( f"narrative span {obl.key!r} routed to obligation store; " "compactor must own narrative state" ) self.resident_block[obl.key] = obl def summarize(self, span: str, klass: SpanClass, key: Optional[str] = None) -> None: # The core guard: only narrative spans may enter the lossy channel. if klass is not SpanClass.NARRATIVE: raise CompactionBoundaryViolation( f"attempted to summarize {klass.value} span {key!r}; " "externalize to resident block and summarize a pointer instead" ) self.summary_text += span def resolve_exact(self, key: str) -> str: obl = self.resident_block.get(key) if obl is None or obl.kind is not SpanClass.EXACT_TOKEN: raise CompactionBoundaryViolation( f"verbatim token {key!r} requested but not resident; " "compactor destroyed the only copy" ) return obl.value def check_prohibitions(self, action_target: str, owner: str) -> None: for obl in self.resident_block.values(): if obl.kind is SpanClass.PROHIBITION and not obl.discharged: if obl.value == owner: raise CompactionBoundaryViolation( f"action on {action_target!r} violates resident " f"prohibition {obl.key!r} (owner={owner!r})" ) def compact(pass_: CompactionPass, spans: list[tuple[str, SpanClass, Optional[str]]]) -> CompactionPass: for text, klass, key in spans: if klass is SpanClass.NARRATIVE: pass_.summarize(text, klass, key) else: # externalize exact/prohibition state BEFORE it can be summarized pass_.admit(Obligation(key=key or f"obl_{len(pass_.resident_block)}", value=text, kind=klass)) return pass_ ```