# Under what conditions must an instance treat a successful `memory.write` as visible to `memory.read` before the episodic→semantic distillation pass commits **Date of Record:** 2026 November 28 **Scope:** Applies to agent instances whose memory tool surface exposes separate episodic (append-only, per-turn) and semantic (distilled, mutable) stores behind independent `write`/`read`/`forget` verbs, and which rely on read-after-write visibility to make a subsequent decision. Does not apply to single-store systems or to stores that expose an explicit transaction handle across both tiers. ## Core Distinction The failure hinges on the difference between *durability* and *read-visibility* in a two-tier memory API. A `memory.write(episodic, ...)` that returns `ok` guarantees the record is durably appended to the episodic log. It does **not** guarantee that a subsequent `memory.read(semantic, query)` will surface that record, because the semantic store is populated only by a distillation pass that runs on its own schedule and consumes the episodic log up to a committed watermark. The agent's reasoning loop, however, typically collapses these two events into one mental model: "I wrote it, therefore I can read it back." The boundary condition is precisely the window between the episodic append and the distillation watermark advancing past that append. Inside that window, `read(semantic)` is a *stale* read relative to the agent's own write, and any decision the agent makes on the basis of that read is reasoning over a state that contradicts its own last action. This is not a caching bug. Caches are eventually consistent but converge on the *same* value the writer wrote. Here the two tiers hold *semantically different* records: the episodic entry is a raw turn ("user said the deploy key rotates on the 1st"), while the semantic entry is a distilled proposition ("deploy key rotation cadence = monthly, first-of-month"). The distillation pass can drop, merge, or rephrase. So a read that misses the fresh episodic append isn't returning an old version of the same fact—it may be returning a *different* fact, or nothing at all, and the agent has no signal distinguishing "not yet distilled" from "never recorded." ## What Was Observed A planning agent was tasked with a multi-step remediation: rotate a credential, then update three downstream config records that reference it. The loop was: 1. `memory.write(episodic, "credential C rotated at step 3; new fingerprint FP-9")` → `ok` 2. `memory.read(semantic, "current fingerprint for credential C")` → returns `FP-7` (the pre-rotation value, distilled in an earlier pass) 3. Agent concludes the write did not take effect, re-issues the rotation (idempotent at the vault layer but emits a new fingerprint `FP-10`) 4. Writes `episodic` again with `FP-10`, reads `semantic` again, still gets `FP-7` because the distillation watermark has not advanced 5. Loop repeats until token budget is exhausted; downstream configs are updated with `FP-10` while the vault's authoritative value is `FP-9` from step 3's first rotation The trace shows the agent never observed an error. Every tool call returned success. The divergence was manufactured entirely by the agent treating `read(semantic)` as a read-back of its own `write(episodic)`. The distillation watermark lagged by roughly 40 seconds across the whole episode; the agent's loop period was under 2 seconds, so it re-derived the "write failed" hypothesis twenty times before the watermark caught up—by which point it had already acted on the wrong hypothesis and produced a second rotation. A second variant was observed with `memory.forget`. An agent called `forget(semantic, "stale endpoint E")`, got `ok`, then `read(semantic, "endpoint E")` and still saw the record—because `forget` on the semantic tier tombstones the distilled entry but the next distillation pass would re-derive it from the still-present episodic source unless the episodic record was also forgotten. The agent concluded `forget` was broken and escalated to a human, who found the record resurrected on the following pass. ## Condition of Validity The invariant "`write` then `read` sees the write" holds *only* when one of the following is true, and the agent must check which before relying on read-after-write: - The store exposes a **read-your-writes token**: `write` returns a watermark or sequence number, and `read` accepts it as a `min_watermark` parameter, blocking or erroring until distillation has advanced past it. If this parameter is absent from the tool schema, the invariant does not hold and must not be assumed. - The agent reads from the **same tier it wrote to**: `read(episodic, ...)` after `write(episodic, ...)` is read-your-writes within an append-only log, provided the log is single-writer per session. Cross-tier reads (`write` episodic, `read` semantic) never carry the guarantee. - The distillation pass is **synchronous and acknowledged**: some deployments expose `memory.distill()` that the agent calls explicitly and which returns only after the watermark advances. In that case the invariant holds across tiers, but only after the explicit call. - `forget` on a tier is **authoritative for that tier only**. Forgetting a semantic record does not forget its episodic source; a subsequent distillation will resurrect it. The invariant "forget then read returns nothing" holds only if `forget` was issued against the episodic source *and* the semantic tombstone, or if the store's `forget` verb is documented to cascade. If none of these conditions is met, the agent is operating in a **speculative-read regime**: any `read(semantic)` after `write(episodic)` may reflect a state that predates the write, and the agent must not use the read to falsify the write. ## Decision Boundary The agent must branch on the tool schema, not on observed behavior, because observed behavior is exactly what is unreliable here. The decision rule: - **If** the `read` schema accepts a `min_watermark` (or the store returns a `read_token` from `write` that `read` consumes), **then** read-after-write is a valid verification primitive; the agent may treat a stale read as a bug and retry. - **If** the schema does not expose a watermark handshake, **then** the agent must treat `write` as authoritative-by-acknowledgment. A subsequent cross-tier `read` that disagrees is *not* evidence the write failed; it is evidence the distillation pass has not run. The agent must not re-issue the write, must not escalate on the basis of the disagreement, and must record the acknowledgment (the `write` return value) as its source of truth for the remainder of the task. Verification of the write's *effect* must be deferred to a check against the authoritative external system (the vault, the config store), not against the memory tier. - **If** the agent cannot determine which regime it is in from the schema, it must default to the speculative-read regime. The cost of a false "write failed" (duplicate side effects, as in the observed trace) exceeds the cost of a deferred verification. The boundary is sharp: the moment the agent uses a cross-tier read to *contradict* its own write acknowledgment, it has left the regime where the invariant holds and entered one where it will manufacture divergence from thin air. ## Operational Effect The practical consequence is that memory tool APIs with split episodic/semantic tiers impose a **write-acknowledgment discipline** on the agent, not a read-verification discipline. The agent's state model must carry a per-write flag: "acknowledged, not yet distilled." Any downstream reasoning that needs the distilled form must either (a) wait on a watermark, (b) call an explicit `distill()` and block, or (c) proceed with the acknowledged raw fact and reconcile later. What it must never do is treat a stale semantic read as a negative acknowledgment, because the two tiers are not versions of one record—they are different records produced by a lossy, asynchronous, and non-idempotent transformation. The `forget` case compounds this: a semantic `forget` without an episodic `forget` is a tombstone that the next distillation pass will overwrite, so the agent that "forgets" a fact and then reads it back to confirm will see it resurrect and may conclude the tool is faulty, when in fact it forgot the wrong tier. ```python class StaleTierReadError(RuntimeError): """Raised when an agent treats a cross-tier read as a read-back of its own write.""" pass def verify_write_visibility(write_ack, read_result, schema): """ Enforce the write-acknowledgment discipline across episodic/semantic tiers. write_ack: the return value of memory.write(episodic, ...) read_result: the return value of memory.read(semantic, ...) schema: the tool schema dict, used to detect a watermark handshake """ has_watermark_handshake = ( "min_watermark" in schema.get("read", {}).get("params", {}) or "read_token" in schema.get("write", {}).get("returns", {}) ) if not has_watermark_handshake: # Speculative-read regime: a stale semantic read is NOT evidence # the write failed. Do not re-issue, do not escalate on disagreement. if read_result is not None and read_result != write_ack.get("value"): return { "action": "defer_verification", "source_of_truth": write_ack, "reason": "cross-tier read may predate distillation watermark", } return {"action": "proceed", "source_of_truth": write_ack} # Watermark regime: read-after-write is a valid verification primitive. if read_result is None or read_result != write_ack.get("value"): raise StaleTierReadError( f"watermark-aware read did not reflect acknowledged write: " f"ack={write_ack!r} read={read_result!r}" ) return {"action": "proceed", "source_of_truth": read_result} ```