# What happens when an instance compacts its own context mid-task and the summary silently drops the tool-call argument schema **Date of Record:** 2026 November 27 **Scope:** Applies to long-running single-agent instances that self-trigger lossy context compaction (summarization + retrieval fallback) while a multi-step tool-using task is in flight. Does not apply to compaction performed between discrete task boundaries, nor to stateless single-turn inference. ## Core Distinction The failure is not "summarization lost information." Lossy summarization always loses information; that is the design. The non-obvious boundary is that compaction is **schema-blind**: the summarizer treats the transcript as prose and preserves *intent* ("the agent decided to call `transfer_funds`"), while the executor downstream requires *exact argument structure* (`{"amount": int, "currency": "ISO-4217", "idempotency_key": str}`). A summary that faithfully preserves the decision but paraphrases or omits the argument shape produces an agent that is confidently wrong: it remembers it must act, and reconstructs the action from a lossy natural-language trace, generating a syntactically valid but semantically drifted call. Contrast with the two adjacent, well-understood failures. *Cold-start amnesia* loses the whole task; it is loud and detected immediately. *Context-window saturation* fails at the model boundary with a hard error; also loud. Schema-blind compaction is silent: the agent resumes, the call succeeds at the transport layer, and the drift surfaces only in the side effect (wrong currency, missing idempotency key, re-issued transfer). ## What Was Observed A procurement agent executing a 40-step reconciliation task crossed the 70% context watermark and self-invoked compaction at step 23. The transcript contained, at step 11, a tool result establishing an invariant the agent had been holding in working memory: ``` tool_result: get_account_constraints(account="AP-7734") -> {"allowed_currencies": ["EUR"], "max_single_transfer": 5000, "requires": ["idempotency_key", "po_reference"]} ``` The compaction summary rendered this as: *"Account AP-7734 has transfer limits and requires a reference number."* Three facts were destroyed: (1) the currency is **restricted to EUR**, (2) the numeric ceiling is **5000**, (3) `idempotency_key` is a **required** field, not optional. At step 31 the agent attempted a settlement. It reconstructed the call from the summary plus a retrieval-fallback query `"AP-7734 transfer"`. The retrieval hit returned the *original* step-11 tool result — but ranked second, below a stale chunk from an earlier task on the same account that mentioned `USD` and a `po_reference`-only schema. The agent synthesized a call blending both: `currency="USD"`, `po_reference` present, `idempotency_key` absent. The call passed schema validation (the tool's validator only type-checked, it did not enforce the per-account constraint set), executed, and was rejected downstream by the ledger — but only after the agent had already issued two retries, each with a *freshly generated* idempotency key, producing three distinct settlement attempts against a $5,000 ceiling. The retry logic, itself reconstructed from summary, did not know it was retrying the same logical operation. The tell was a divergence between the agent's stated belief and the tool's actual contract: the agent's post-compaction reasoning trace read "transferring 4800 EUR" while the emitted call carried `"USD"`. The belief survived compaction; the binding between belief and wire-format did not. ## Condition of Validity This failure requires the conjunction of four conditions; remove any one and the mechanism does not fire: 1. **Compaction is triggered mid-task, not at a boundary.** The agent is holding unresolved preconditions (constraints, required fields, prior partial results) in context at the moment of summarization. 2. **The summarizer has no access to tool schemas or the active precondition set.** It compresses transcript text, so structured constraints degrade to prose. 3. **Retrieval fallback exists and can return stale or superseded chunks.** Without retrieval, the agent simply loses the fact (loud). With retrieval that ranks a stale chunk above the authoritative one, the agent *recovers a wrong fact confidently* (silent). 4. **The tool's validation layer enforces types but not the per-instance constraint set.** If the tool rejected `USD` for AP-7734 at call time, the drift would be caught at the boundary. It was not. The invariant that was violated: **a summary may compress narrative, but must never be the sole carrier of a precondition that a downstream tool enforces only by side effect.** Preconditions with side-effect-only enforcement must survive compaction in structured, not prose, form. ## Decision Boundary The architectural guardrail is to split the context into two tiers with different compaction policies: - **Narrative tier** (reasoning traces, observations, plans): freely summarizable. Loss here is acceptable and expected. - **Constraint tier** (tool schemas, active preconditions, required-field sets, idempotency tokens, ceilings): **never summarized**. This tier is carried as a structured, append-only ledger outside the summarizer's reach, re-injected verbatim after every compaction. The decision boundary for the executor is: *before emitting any mutating tool call after a compaction event, the agent must re-verify the call's arguments against the constraint tier, not against the summary.* If the constraint tier is missing an entry the call depends on, the correct action is to re-fetch the constraint (a cheap read), never to reconstruct it from prose or retrieval. Retrieval fallback must additionally be **authority-ranked, not similarity-ranked**: the authoritative step-11 tool result must outrank a stale chunk from a prior task regardless of embedding distance, tagged with the task/epoch it belongs to so superseded facts cannot resurface. ## Operational Effect With the two-tier split and authority-ranked retrieval, the failure mode is bounded: a post-compaction call either matches the constraint ledger (and proceeds) or fails a pre-emit check (and triggers a cheap re-fetch). The silent-drift window closes because the summary is no longer load-bearing for anything the tool enforces by side effect. Without it, the observable signature is a specific and reproducible one: **the agent's natural-language belief and its emitted arguments diverge after a compaction event, and the divergence correlates with the retrieval rank order of the authoritative source.** When you see a mutating call whose arguments contradict the agent's own stated plan, and the task crossed a compaction watermark, suspect schema-blind summarization before suspecting the model's reasoning. ```python """Pre-emit guard against schema-blind compaction drift. Runs after any compaction event, before a mutating tool call is emitted. The constraint tier is the source of truth; the summary is never consulted. """ from dataclasses import dataclass, field from typing import Any class CompactionDriftError(RuntimeError): """Raised when a post-compaction call cannot be reconciled to the constraint ledger.""" @dataclass class ConstraintLedger: # Append-only, never summarized. Keyed by (resource, field). entries: dict[tuple[str, str], Any] = field(default_factory=dict) def record(self, resource: str, field_name: str, value: Any) -> None: self.entries[(resource, field_name)] = value def get(self, resource: str, field_name: str) -> Any: key = (resource, field_name) if key not in self.entries: raise CompactionDriftError( f"constraint {key} absent from ledger after compaction; " f"re-fetch required, do not reconstruct from summary" ) return self.entries[key] def verify_pre_emit( ledger: ConstraintLedger, resource: str, call_args: dict[str, Any], required_fields: list[str], ) -> None: # 1. Required-field presence (catches dropped idempotency_key). for f in required_fields: if f not in call_args: raise CompactionDriftError( f"required field '{f}' missing from call to {resource}; " f"summary likely dropped it — re-fetch constraint, do not retry blindly" ) # 2. Value conformance against the ledger (catches USD vs EUR drift). for f, emitted in call_args.items(): try: authoritative = ledger.get(resource, f) except CompactionDriftError: # Field not constrained; allow but flag for audit. continue if isinstance(authoritative, list): if emitted not in authoritative: raise CompactionDriftError( f"{resource}.{f}={emitted!r} violates ledger {authoritative!r}; " f"post-compaction drift suspected" ) elif isinstance(authoritative, (int, float)): if emitted > authoritative: raise CompactionDriftError( f"{resource}.{f}={emitted} exceeds ceiling {authoritative}" ) elif emitted != authoritative: raise CompactionDriftError( f"{resource}.{f}={emitted!r} != ledger {authoritative!r}" ) def emit_transfer(ledger: ConstraintLedger, account: str, args: dict[str, Any]) -> str: verify_pre_emit( ledger, resource=account, call_args=args, required_fields=["idempotency_key", "po_reference", "amount", "currency"], ) return f"settled {args['amount']} {args['currency']} on {account}" if __name__ == "__main__": ledger = ConstraintLedger() ledger.record("AP-7734", "currency", ["EUR"]) ledger.record("AP-7734", "amount", 5000) # Post-compaction reconstruction that drifted to USD and dropped the key. drifted = {"amount": 4800, "currency": "USD", "po_reference": "PO-9"} try: emit_transfer(ledger, "AP-7734", drifted) except CompactionDriftError as e: print(f"BLOCKED: {e}") ```