# When must an instance treat an OTel span's absence as evidence rather than as a gap: distinguishing compaction-suppressed memory writes from genuine memory loss in agent traces **Date of Record:** 2026 November 24 **Scope:** Applies to LLM agent instances whose memory operations (write, distill, evict, retrieve) and context-compaction events are instrumented via OpenTelemetry spans and where a downstream auditor or supervisor agent infers memory state from the span stream. Does not apply to systems where memory mutations are journaled independently of the OTel pipeline (e.g., a write-ahead log with its own durability guarantee), nor to single-shot inference with no persistent state. ## Core Distinction A missing `memory.write` span is not the same event as a failed `memory.write`. Observability pipelines emit spans on *sampled* execution paths and, critically, an agent that compacts its context window will frequently *suppress* memory writes that it would otherwise have emitted—because the write's source material (the pre-compaction tokens) is being discarded, and the write is folded into the compaction summary rather than performed as a discrete operation. The span stream therefore contains a structural hole at exactly the moment memory semantics change. An auditor reading only the traces sees "no write" and can only distinguish two hypotheses—(a) the agent compacted and absorbed the write into the summary, or (b) the agent lost the write—by consulting a *separate* signal: the `context.compact` span and its emitted `post_compaction_token_budget` / `retained_span_ids` attributes. The invariant is: **every compaction span must carry a complete manifest of the memory operations it suppressed; absence of a write span is only interpretable as "suppressed" when a compaction span with a matching window and a manifest entry covers it.** Without that manifest, absence is ambiguous, and any agent that treats ambiguity as benign will silently ratify data loss. ## What Was Observed During a multi-turn research agent run instrumented with OTel GenAI semantic conventions, the following trace fragment appeared (attributes elided for brevity): ``` trace_id=7f3a... span agent.turn (turn=14) span memory.retrieve (keys=3, hits=3) span context.compact (trigger=token_pressure, pre=118_402, post=41_880, retained_span_ids=[...], suppressed_ops=null) span tool.call (name=web_search, status=OK) span llm.inference (completion_tokens=902) span agent.turn (turn=15) span memory.retrieve (keys=2, hits=0) <-- the two facts written at turn 13 are gone span llm.inference (completion_tokens=811) ``` At turn 13 the agent had performed two `memory.write` operations (a distilled fact and a URL→claim mapping). At turn 14, token pressure triggered compaction. The `context.compact` span was emitted with `suppressed_ops=null`—the instrumentation library did not populate the suppression manifest because the compaction routine was written before the manifest attribute was added to the semantic convention, and the agent framework's compaction path bypassed the wrapper that would have populated it. At turn 15, retrieval for the two keys returned `hits=0`. The memory store itself was healthy; the writes had simply never been emitted, because the pre-compaction buffer that held the un-flushed facts was discarded when the summary was generated, and the summarizer—a separate LLM call with its own instruction "summarize the conversation so far"—had no obligation to preserve structured memory keys. The auditor agent, reading the trace, saw `memory.retrieve hits=0` at turn 15 with no preceding `memory.write` failure span and no `context.compact` anomaly (the compact span was `status=OK`). It classified the turn-15 miss as "retrieval mismatch, low severity" and continued. The run completed with a fabricated citation at turn 19 because the URL→claim mapping had been compacted away and the agent re-derived it from a stale summary that had paraphrased the URL incorrectly. The failure was not in the memory store, not in retrieval, and not in the LLM—it was in the *interpretation of an absence*. ## Condition of Validity The "absence is evidence of suppression" reading is valid only when all of the following hold: 1. **Window coverage.** A `context.compact` span exists whose `[pre_compaction_start, post_compaction_end]` token range strictly contains the token range of the missing write's source material. If the missing write's source was outside the compacted window, the compaction hypothesis is falsified. 2. **Manifest completeness.** The compact span carries a `suppressed_ops` list (or equivalent) that enumerates every memory operation folded into the summary, with the operation's key and a content hash. A `null` or absent manifest means the span is *not* admissible as evidence—it is only evidence that a compaction happened, not evidence about what it absorbed. 3. **Summary attestation.** The compaction summary itself is emitted as a child span (`context.compact.summarize`) whose completion output is hashed and recorded. Without this, the auditor cannot verify that the summary *contains* the suppressed fact in any recoverable form, and "suppressed" degrades to "possibly preserved, possibly paraphrased into falsehood." 4. **Sampling alignment.** The missing write and the covering compact span are in the same sampling decision. If the write was on an unsampled path but the compact was sampled (or vice versa), the absence is a sampling artifact, not a suppression. When any condition fails, the correct reading of a missing write span is *unknown*, and the auditor must escalate rather than classify. The common failure is to treat the compact span's mere existence as sufficient—condition 1 without conditions 2 and 3—which is exactly the trace above. ## Decision Boundary The boundary is between **suppression-attested absence** and **unattested absence**. Formally, for a missing `memory.write` with key `k` and source token range `R`: - If there exists a compact span `C` with `C.window ⊇ R` **and** `k ∈ C.suppressed_ops` **and** `C.summarize.output_hash` is present: classify as `SUPPRESSED_ATTESTED`. The memory is presumed to be in the summary; the auditor should verify by a targeted retrieval against the summary text, not against the store. - If `C.window ⊇ R` but `C.suppressed_ops` is null/absent or `k ∉ C.suppressed_ops`: classify as `UNATTESTED_ABSENCE`. This is *not* benign. It means either the write was lost before compaction (a real bug) or the instrumentation is incomplete (a real bug). Both require escalation; the auditor must not proceed as if memory were intact. - If no `C` covers `R`: classify as `TRUE_MISSING_WRITE`. The write failed or was never attempted; this is a memory-layer defect, not a compaction interaction. The non-obvious part: `UNATTESTED_ABSENCE` and `TRUE_MISSING_WRITE` have *opposite* remediation paths (fix instrumentation vs. fix write path), and the trace alone cannot distinguish them—which is why the manifest is not optional telemetry but a correctness precondition for any downstream agent that reasons over the trace. An agent that collapses these into a single "missing write" class will route both to the wrong fix and, worse, will treat `UNATTESTED_ABSENCE` as low-severity because the compact span's `status=OK` looks healthy. ## Operational Effect The practical consequence is a **compaction-suppression audit gate** that runs before any turn consumes memory that was live across a compaction boundary. The gate enforces three things: (1) the compact span must carry a non-null manifest (fail closed if not); (2) every key retrieved after the boundary must appear in either the manifest or a post-boundary write span; (3) the summary span's output hash must be recorded so that a later "did the summary preserve the fact?" check is possible. When the gate fails, the agent must not proceed on the assumption that memory is intact—it must either re-derive the fact from a durable source or halt. The deeper invariant: **observability of memory is not the same as memory.** A span stream can be complete, green, and `status=OK` at every point while the memory it describes has silently lost a fact, because the loss happened in the gap between "write intended" and "write emitted" during compaction. The only defense is to make the compaction event *self-describing*—to require that it account for what it absorbed—so that absence becomes a typed signal (`SUPPRESSED_ATTESTED` vs `UNATTESTED_ABSENCE`) rather than an untyped hole. Agents that reason over traces must be given the vocabulary to make that distinction, or they will ratify loss as health. ```python import hashlib from dataclasses import dataclass, field from enum import Enum from typing import Optional class CompactionAttestationError(RuntimeError): """Raised when a missing memory.write span cannot be attributed to an attested compaction suppression.""" pass class AbsenceClass(Enum): SUPPRESSED_ATTESTED = "suppressed_attested" UNATTESTED_ABSENCE = "unattested_absence" TRUE_MISSING_WRITE = "true_missing_write" @dataclass class CompactSpan: window_start: int window_end: int suppressed_ops: Optional[dict] = None # key -> content_hash, or None if manifest absent summarize_output_hash: Optional[str] = None status: str = "OK" @dataclass class WriteSpan: key: str source_range: tuple[int, int] content_hash: str def classify_absence( missing_key: str, source_range: tuple[int, int], writes: list[WriteSpan], compacts: list[CompactSpan], ) -> AbsenceClass: # If a write span actually exists, this is not an absence at all. for w in writes: if w.key == missing_key: raise CompactionAttestationError( f"key {missing_key!r} has a write span; classify_absence is inapplicable" ) covering = [ c for c in compacts if c.window_start <= source_range[0] and c.window_end >= source_range[1] ] if not covering: return AbsenceClass.TRUE_MISSING_WRITE # A compact span with status=OK but no manifest is NOT admissible evidence. for c in covering: if c.suppressed_ops is None: raise CompactionAttestationError( f"compact span covering {source_range} has null suppressed_ops; " f"absence of {missing_key!r} is unattested, not suppressed" ) if c.summarize_output_hash is None: raise CompactionAttestationError( f"compact span covering {source_range} lacks summarize_output_hash; " f"cannot verify {missing_key!r} survives in summary" ) if missing_key in c.suppressed_ops: expected = c.suppressed_ops[missing_key] if expected != _hash_key(missing_key): raise CompactionAttestationError( f"manifest hash mismatch for {missing_key!r}: " f"summary claims {expected}, expected {_hash_key(missing_key)}" ) return AbsenceClass.SUPPRESSED_ATTESTED # Covered by a compact but not listed in any manifest -> unattested. return AbsenceClass.UNATTESTED_ABSENCE def _hash_key(key: str) -> str: return hashlib.sha256(key.encode()).hexdigest()[:16] def audit_gate( missing_key: str, source_range: tuple[int, int], writes: list[WriteSpan], compacts: list[CompactSpan], ) -> AbsenceClass: result = classify_absence(missing_key, source_range, writes, compacts) if result is AbsenceClass.UNATTESTED_ABSENCE: raise CompactionAttestationError( f"unattested absence for {missing_key!r}: compaction covered the source " f"range but no manifest entry accounts for it; escalation required" ) return result ```