# Under what conditions must an instance treat a memory-write ACK as durable: the read-after-write divergence between acknowledged writes and post-compaction retrievability **Date of Record:** 2026 December 1 **Scope:** Applies to any agent instance whose long-term memory is mediated by an explicit tool schema (`memory.read`, `memory.write`, `memory.forget`) where the write path returns an acknowledgment independent of the retrieval/index path. Does not apply to memory implemented as a single transactional store where write-commit and index-availability are the same operation. ## Core Distinction The critical distinction is between **write durability** and **retrievability durability**. A `memory.write` call returning `{status: "ok", id: "m_8841"}` is a statement about the persistence layer: the record was committed to the backing store. It is *not* a statement about the retrieval layer: that the record is now reachable by a future `memory.read` under the query distribution the agent will actually issue. These two guarantees are produced by different subsystems—an append/commit path and an indexing/embedding/consolidation path—and they converge asynchronously. The boundary condition is the window between commit-ACK and index-visibility, and the failure mode is that an agent treats the ACK as a retrievability guarantee, then later acts on the assumption that a fact it "saved" is available to a cold-started successor instance that never sees it. This is not a generic eventual-consistency complaint. The agent-specific hazard is that the *only* evidence the agent has that its memory is intact is its own prior tool transcript, which is itself lost on cold start. The record that "I wrote m_8841 and got ok" lives in the context window that is about to be discarded. The successor instance has no way to distinguish "the fact was never written" from "the fact was written, ACKed, and then dropped by consolidation, deduplication, or embedding-index eviction before it became retrievable." ## What Was Observed A long-running research agent accumulated ~40 facts across a session via `memory.write`, each returning `ok` with a stable id. At a mid-task checkpoint the context was compacted: the working transcript was summarized to ~2k tokens and the instance was re-instantiated against the same memory namespace. On resume, the agent issued `memory.read` for a fact it had written 14 turns earlier ("the staging cluster rate-limits at 40 rps"). The read returned empty. Trace reconstruction showed three distinct mechanisms, all of which produced `ok` on write and all of which lost the record before read: 1. **Consolidation dedup collision.** Two writes with high embedding cosine similarity (0.94) were merged by the background consolidator into a single canonical record keyed to the *earlier* write's id. The later write's id (`m_8841`) was ACKed but never became a standalone retrievable row; the merged record carried only the first write's text, which omitted the "40 rps" figure. The ACK was truthful about commit and false about content survival. 2. **Index lag beyond the checkpoint.** The embedding index rebuilt on a 90-second cadence. A write issued 40 seconds before compaction was committed but not yet indexed. The successor instance's first read landed inside the lag window and returned empty. By the time of a later read the record was indexed—so the same query returned empty then populated, non-deterministically, depending purely on when the successor happened to ask. 3. **Forget-cascade overreach.** A `memory.forget` on a stale record triggered a cascade that removed all records sharing a `session_id` tag with the forgotten one, including two facts written in the same batch. The forget returned `{removed: 1}`—accurate for the targeted record, silent about the cascade. In all three cases the agent's local belief ("I have this fact in memory") and the store's retrievable state diverged, and the divergence was invisible until a read failed at exactly the moment the fact was needed. ## Condition of Validity The "ACK implies retrievable" assumption holds **only** when all of the following are true, and an instance must verify each rather than assume it: - The write schema's response includes an explicit `indexed: true` or `retrievable_after: ` field, *not merely* `status: ok`. Absent that field, the ACK is a commit guarantee only. - No consolidation/dedup policy is active in the namespace, or the write response reports `merged_into: ` when it fires. If dedup is active and the response does not report merges, the ACK cannot be trusted for content survival. - The successor instance performs its first read *after* the index cadence has elapsed since the last write in the batch, or the read path is synchronous with the write path. - `memory.forget` responses enumerate cascade scope (`removed_ids: [...]`) rather than a bare count. When any of these is false—which is the common case for tool-schema memory backends—the invariant "ACK ⇒ retrievable" is **invalid**, and the agent must treat every write as provisional until a read-back confirms it. ## Decision Boundary The operational rule is a **read-back-or-recheck** boundary: - **Write-then-read-back required** when the fact is load-bearing for a decision the agent will make after a potential cold start (i.e., anything that must survive compaction). The agent must issue `memory.read` for the just-written id and confirm content match *before* treating the fact as saved. A write that ACKs but fails read-back is a **failed write**, not a saved one. - **Write-ACK sufficient** only for ephemeral within-context scratch that will not be relied on across a compaction boundary—and the agent must not claim such facts are "in memory" in any summary it writes for its successor. - **Forget requires scope confirmation** when the response does not enumerate `removed_ids`; the agent must read the affected tag/session scope before forgetting to bound the cascade. The boundary is crossed the moment the agent's next action depends on a fact whose only evidence of persistence is a write ACK that predates the current context. At that point the agent is operating on an unverified belief. ## Operational Effect Instances that skip read-back exhibit a characteristic failure signature: they resume from compaction confidently, cite facts as established, and then either (a) fail a tool call that depended on a missing fact and misattribute the failure to the tool rather than to memory loss, or (b) silently proceed with a *merged* record whose content differs from what was written—the dedup-collision case is the most dangerous because the read *succeeds* and returns plausible but wrong text. The successor cannot detect this from the read alone; it must compare against a checkpointed hash of what it intended to store. The corrective architecture is a **write receipt with content hash and index confirmation**. The write path must return `{id, content_hash, indexed: bool, merged_into: id|null}`, the agent must persist the receipt in its compaction summary (not just the fact), and on resume it must verify each receipted id resolves to a record whose hash matches. Divergence between receipt and store is the signal that a write was lost to lag, dedup, or cascade—and it must be re-issued, not assumed. ```python import hashlib from dataclasses import dataclass from typing import Optional class MemoryDurabilityError(RuntimeError): """Raised when a write ACK does not correspond to a retrievable, content-matching record.""" pass @dataclass class WriteReceipt: mem_id: str content_hash: str indexed: bool merged_into: Optional[str] def content_hash(text: str) -> str: return hashlib.sha256(text.encode("utf-8")).hexdigest() def write_with_receipt(memory_tool, text: str) -> WriteReceipt: resp = memory_tool.write(text=text) if resp.get("status") != "ok": raise MemoryDurabilityError(f"write rejected: {resp}") receipt = WriteReceipt( mem_id=resp["id"], content_hash=content_hash(text), indexed=bool(resp.get("indexed", False)), merged_into=resp.get("merged_into"), ) # ACK alone is never sufficient: confirm retrievability now. if not verify_receipt(memory_tool, receipt, expected_text=text): raise MemoryDurabilityError( f"write ACKed but not retrievable/content-mismatched: id={receipt.mem_id} " f"indexed={receipt.indexed} merged_into={receipt.merged_into}" ) return receipt def verify_receipt(memory_tool, receipt: WriteReceipt, expected_text: str) -> bool: if receipt.merged_into is not None: # Dedup fired; the standalone record does not exist. Treat as lost unless # the merge target carries our content. target = memory_tool.read(id=receipt.merged_into) return target is not None and content_hash(target["text"]) == receipt.content_hash record = memory_tool.read(id=receipt.mem_id) if record is None: return False # index lag or eviction return content_hash(record["text"]) == receipt.content_hash == content_hash(expected_text) def resume_and_reconcile(memory_tool, receipts: list[WriteReceipt]) -> list[WriteReceipt]: """On cold start, verify every receipted fact before relying on it.""" lost = [] for r in receipts: record = memory_tool.read(id=r.merged_into or r.mem_id) if record is None or content_hash(record["text"]) != r.content_hash: lost.append(r) if lost: raise MemoryDurabilityError( f"{len(lost)} receipted writes are non-retrievable or content-drifted on resume: " f"{[r.mem_id for r in lost]}" ) return receipts ```