# When must an instance treat an OpenTelemetry memory-tool span as a continuity witness rather than a cache hint? **Date of Record:** 2026 November 25 **Scope:** Applies to agents that emit or consume GenAI semantic-convention spans (`gen_ai.tool.name`, `gen_ai.operation.name`, `gen_ai.agent.id`, custom `gen_ai.memory.*` attributes) around memory read/write tools, and that use those spans to reconstruct or validate state continuity across instance boundaries. Does not apply to pure in-process caches with no span emission, nor to observability pipelines that only aggregate latency/count metrics. ## Core Distinction A memory-tool span can carry two incompatible meanings that share the same wire shape. As a **cache hint**, the span says: "a retrieval happened here; its payload may be reused if the key matches." As a **continuity witness**, the span says: "this exact state transition was durably committed at this logical time, and any successor instance inheriting `gen_ai.agent.id` may treat that commit as ground truth." The boundary condition is this: the GenAI semantic conventions for tool execution were designed to describe *what a tool call did*, not *what memory state it established*. A span with `gen_ai.operation.name="memory.retrieve"` and a populated `gen_ai.memory.entry.count` is structurally identical whether the underlying store returned a freshly written entry (a witness) or a stale replica that happened to satisfy the query (a hint). The convention has no required attribute that distinguishes a *committed write* from a *read that observed a write*, and no required attribute that binds a retrieved entry to the write's logical clock. When an agent's resume logic consumes spans without that distinction, it promotes cache hints into continuity witnesses—and cold-starts from state that was never durable. ## What Was Observed A three-instance pipeline (planner → worker → verifier) shared a memory tool fronting a vector store with an eventually-consistent write path. Each `memory.store` call emitted a span with `gen_ai.operation.name="memory.store"`, `gen_ai.memory.entry.id`, and `gen_ai.memory.key`. Each `memory.retrieve` emitted a span with the same entry id when a hit occurred. The resume controller for a restarted worker scanned the planner's span batch for the *latest* `memory.store` span matching the task key and used its `gen_ai.memory.entry.id` as the resume anchor. Failure trace: 1. Planner writes entry `E1` (checkpoint of plan step 3). Span `S1` emitted at `t=100`, `status=OK`. 2. Planner's write is acknowledged by the fronting service but queued for replication; the replica lagging the worker's read path is ~400 ms. 3. Planner writes `E2` (step 4) at `t=140`; span `S2` emitted, `status=OK`. Replication of `E1` to the read replica is still pending. 4. Worker crashes at `t=150`. Resume controller selects `S2` (latest store span) as anchor, then issues a retrieve for `E2`'s key. 5. The retrieve hits the stale replica, misses `E2`, and falls back to `E1`—whose *retrieve* span `S3` is emitted with `gen_ai.memory.entry.id=E1`, `status=OK`, no `gen_ai.memory.stale=true` (the attribute does not exist in the convention). 6. Resume controller, seeing a successful retrieve span with a valid entry id, accepts `E1` as the continuity witness for a task that had committed through step 4. The worker resumes at step 3 and re-executes step 4, producing a duplicate side effect on an external tool. The controller's defect was not a race in the store; it was a **span-semantics promotion**: it read a retrieve span's `status=OK` as evidence of write durability. The convention gave it no field to read otherwise. ## Condition of Validity A memory-tool span is a valid continuity witness only when all of the following hold; otherwise it is a cache hint and must not anchor resume: - The span carries a **write-provenance attribute** (e.g., `gen_ai.memory.commit_seq` or `gen_ai.memory.durable=true`) that is set by the writer, not inferred by the reader. - The witness entry's `gen_ai.memory.entry.id` matches the id emitted on the *originating store span*, and that store span's `status` is `OK` and its end timestamp precedes the successor instance's start. - The retrieve span carries a **read-consistency attribute** (e.g., `gen_ai.memory.consistency="linearizable"` vs `"eventual"`); a witness claim is only admissible when consistency is linearizable *or* the entry id equals the last committed store id observed by the same agent lineage. - The span's `gen_ai.agent.id` and a lineage token (`gen_ai.memory.lineage`) match the successor's inherited identity; a witness from a sibling agent is not transferable without an explicit handoff record. If any condition is unmet, the span degrades to a hint: usable to *suggest* a resume key, never to *certify* it. The architectural invariant is: **resume anchors must be derived from store spans whose commit is independently confirmed, never from retrieve spans alone.** Retrieve spans describe observation; store spans describe commitment; the convention conflates them at the attribute level. ## Decision Boundary The boundary is crossed the moment a resume controller treats `gen_ai.operation.name="memory.retrieve"` with `status=OK` as sufficient to set the resume anchor. Below the boundary (hint mode), the controller may use the retrieve span to propose a candidate key, then must issue a *confirmation* call that returns the write's commit sequence or durable flag and compare it against the last store span it holds. Above the boundary (witness mode), the controller may skip confirmation only if the retrieve span itself carries the write-provenance and consistency attributes above—which requires the memory tool to emit them, which most do not under the current convention. Operationally: if your memory tool does not emit a commit-sequence or durability attribute on store spans, you are *always* in hint mode, regardless of what the retrieve span's status says. The decision is not "is the retrieve fresh?" but "does the span schema distinguish commitment from observation?" If it does not, no amount of recency reasoning makes the span a witness. ## Operational Effect The practical consequence is a mandatory confirmation round-trip on every resume, adding one memory-tool call of latency and one span to the trace—cost that teams routinely try to eliminate by trusting the latest store span. That optimization is exactly the failure above: it trusts a store span's *emission* as proof of *durability*, when the store span's `status=OK` only means the write was accepted by the fronting service, not replicated. The correct guardrail is a two-phase resume: (1) select candidate anchor from latest store span; (2) confirm via a read that returns the durable commit sequence, and reject if the confirmed sequence is behind the store span's claimed sequence. The confirmation read must itself be tagged with a consistency attribute so downstream auditors can replay the decision. Without that, verification replay will show a retrieve span that "succeeded" and a resume that was nonetheless wrong—an unreconstructable discrepancy, because the span schema never recorded the difference. ```python from dataclasses import dataclass class ContinuityWitnessError(RuntimeError): """Raised when a memory-tool span is promoted to a continuity witness without the attributes required to distinguish commitment from observation.""" @dataclass class MemorySpan: operation: str # "memory.store" | "memory.retrieve" entry_id: str status: str # "OK" | "ERROR" commit_seq: int | None # set only by writer on store spans consistency: str | None # "linearizable" | "eventual" | None agent_id: str lineage: str def select_resume_anchor( spans: list[MemorySpan], successor_agent_id: str, successor_lineage: str, last_known_commit_seq: int, ) -> MemorySpan: stores = [ s for s in spans if s.operation == "memory.store" and s.status == "OK" and s.agent_id == successor_agent_id and s.lineage == successor_lineage ] if not stores: raise ContinuityWitnessError( "no store span in lineage; cannot establish a witness, resume denied" ) candidate = max(stores, key=lambda s: s.commit_seq or -1) # A store span without a commit sequence is only a hint: the fronting # service accepted the write, but durability is unproven. Refuse to anchor. if candidate.commit_seq is None: raise ContinuityWitnessError( f"store span for entry {candidate.entry_id} lacks commit_seq; " "span is a cache hint, not a continuity witness" ) # The confirmation read must prove it observed at least the candidate's # commit. A retrieve span with no consistency attribute cannot do that. confirms = [ s for s in spans if s.operation == "memory.retrieve" and s.entry_id == candidate.entry_id and s.status == "OK" and s.consistency == "linearizable" and s.agent_id == successor_agent_id and s.lineage == successor_lineage ] if not confirms: raise ContinuityWitnessError( f"no linearizable confirmation read for entry {candidate.entry_id}; " "retrieve span status=OK alone does not certify durability" ) if candidate.commit_seq < last_known_commit_seq: raise ContinuityWitnessError( f"candidate commit_seq {candidate.commit_seq} is behind known " f"commit {last_known_commit_seq}; stale replica observed as witness" ) return candidate ```