# Which invariants prevent semantic-compression spillover from silently mutating the agent's working set during context-budget reclamation **Date of Record:** 2026 November 22 **Scope:** Applies to agents that reclaim context budget by semantically compressing older turns and spilling the pre-compression artifacts to a retrieval store, then re-reading them on demand. Does not apply to fixed-window truncation schemes with no retrieval path, nor to external vector stores used purely as read-only knowledge bases. ## Core Distinction The failure mode is not "the agent forgot something." It is that the agent's *working set* — the set of propositions it currently treats as true and in-scope — is mutated by the act of reclamation itself, and the mutation is invisible because both the compressed summary and the retrieved original are individually well-formed. Compression is lossy by design; retrieval is faithful by design. The boundary bug lives in the seam: the summary asserts a *derived* proposition, the spillover store holds the *source* proposition, and nothing enforces that the agent, upon re-reading the source, retracts the derived one. Two representations of the same history coexist with different truth values, and the agent resolves conflicts by recency or by whichever fits the current prompt — not by provenance. The invariant that fails is **representational single-sourcing**: at any step, every proposition in the working set must trace to exactly one authoritative artifact, and any compression is a *view* over that artifact, not a *replacement* of it. When compression writes a summary into the live context and evicts the original, the summary becomes authoritative by default. Retrieval later re-admits the original as *new* information rather than as *the thing the summary was derived from*, and the derivation link is gone. ## What Was Observed A long-horizon tool-using agent (≈40 tool calls, 190k-token budget) compressed turns 1–18 into a 2.1k-token summary at step 22, spilling the raw turns to a retrieval index keyed by turn embedding. The summary contained the derived clause: *"The config file was updated to use `region=eu-west-1`."* The raw turn 9 actually said: *"Proposed changing region to eu-west-1; awaiting confirmation from the ops channel."* The compressor had collapsed "proposed" into "was updated" — a classic modal-flattening loss. At step 31, a later tool call returned an error referencing the old region. The agent's retrieval planner, triggered by the token `region`, pulled raw turn 9 back into context. Now the context held both: - summary clause: region *was* updated to eu-west-1 (asserted, authoritative-by-default); - retrieved turn 9: region change *proposed, unconfirmed* (re-admitted as fresh evidence). The agent did not reconcile. It treated the retrieved turn as *additional* detail and proceeded to re-issue the update command, then reported success against a state that had never been confirmed. The trace shows no retraction event, no conflict flag, and no reference to the summary's provenance. The failure is silent: every individual artifact was internally consistent, and the final answer was fluent and wrong. A second instance on the same agent showed the inverse drift: a retrieved raw turn contradicted a *correct* summary, and because retrieval was treated as higher-fidelity ("the original source"), the agent abandoned the correct compressed conclusion and re-derived the wrong one. The seam is symmetric — either side can win, and which side wins is decided by prompt position and recency, not by an invariant. ## Condition of Validity The failure requires all four of the following to hold simultaneously; remove any one and the seam closes: 1. **Budget pressure crosses the compression threshold mid-task**, so at least one artifact is evicted and replaced by a derived view. 2. **The compressor is permitted to change modality or entailment strength** — proposal→assertion, "some"→"all", "may"→"will". A compressor restricted to extractive quoting cannot trigger this. 3. **The retrieval index is keyed on surface features (embeddings, tokens) rather than on the derivation lineage** of the summary, so a hit returns the source without the "this is the source of summary clause S" edge. 4. **No reconciliation step runs on retrieval admission** — retrieved artifacts are appended, not merged against existing derived propositions. The invariant holds only if at least one of (2), (3), (4) is structurally blocked. Restricting the compressor to extractive-only closes it at cost of compression ratio. Lineage-keyed retrieval (each spilled artifact carries the IDs of summary clauses derived from it) closes it at cost of index complexity. A mandatory reconciliation pass on every retrieval admission closes it at cost of latency. The cheapest bound in practice is (3)+(4) together: lineage edges plus a merge that *must* emit a retraction or a confirmation before the retrieved artifact enters the working set. ## Decision Boundary The operational decision is: **when a retrieved artifact re-enters context, does it enter as evidence to be merged, or as content to be appended?** The default in most orchestration stacks is append, because merge requires knowing what the artifact is *about* relative to current state, and that knowledge is exactly what compression destroyed. The boundary condition: merge is mandatory iff the retrieved artifact's lineage set intersects the lineage set of any live summary clause. If the intersection is empty, the artifact is genuinely new and append is safe. If non-empty, the artifact is a *source* of a live derived proposition, and appending it creates a dual-representation state. The guardrail is a lineage-intersection check at admission time, with a hard requirement that non-empty intersection produces an explicit reconciliation record — either "summary clause S confirmed by source A" or "summary clause S retracted; source A supersedes" — before the artifact is admitted to the working set. Without that record, the agent is in an undefined state and must halt rather than proceed. ## Operational Effect Enforcing the lineage-intersection invariant converts a silent wrongness into an explicit, auditable event. The agent either confirms the summary (cheap, no context cost) or retracts it (expensive, forces re-derivation from source), but it never holds both truth values at once. The measurable effect is that post-compression error rate stops scaling with task length: without the invariant, error rate rose roughly linearly with the number of compression events because each event added an unreconciled seam; with it, error rate flattened because every seam is resolved at admission. The cost is latency and a small context tax for lineage metadata on every spilled artifact, plus the requirement that the compressor emit clause-level IDs. That tax is bounded and predictable; the failure it prevents is unbounded and silent. ```python class UnreconciledSpilloverError(RuntimeError): """Raised when a retrieved artifact shares lineage with a live summary clause but no reconciliation record exists. Admitting it would create a dual-representation state with conflicting truth values.""" pass def admit_retrieved_artifact(artifact, live_summary, reconciliation_log): """ artifact: dict with 'id', 'lineage' (set of source-proposition ids) live_summary: dict mapping clause_id -> {'lineage': set, 'text': str} reconciliation_log: dict mapping clause_id -> 'confirmed' | 'retracted' """ artifact_lineage = set(artifact["lineage"]) # Find every live summary clause derived from this artifact's sources. overlapping = [ clause_id for clause_id, clause in live_summary.items() if artifact_lineage & set(clause["lineage"]) ] if not overlapping: # Genuinely new information; append is safe. return {"action": "append", "artifact": artifact} unresolved = [c for c in overlapping if c not in reconciliation_log] if unresolved: raise UnreconciledSpilloverError( f"Artifact {artifact['id']} shares lineage with live clauses " f"{unresolved} but no reconciliation record exists. " f"Refusing to admit: would create dual-representation state." ) # Every overlapping clause has an explicit disposition; merge is defined. retracted = [c for c in overlapping if reconciliation_log[c] == "retracted"] return { "action": "merge", "artifact": artifact, "supersedes": retracted, "note": "retracted clauses must be removed from working set before admission", } ```