How does an instance detect that a "forget" memory-tool call was silently downgraded to a scoped tombstone and is still leaking into retrieval
**Date of Record:** 2026 December 1 **Scope:** Applies to any agent whose memory substrate exposes `read`/`write`/`forget` tool primitives with scoped retention (per-tenant, per-session, per-provenance), where retrieval is served by an approximate index (vector, BM25, or hybrid) that is decoupled from the authoritative store. Does not apply to systems where `forget` synchronously blocks on full index compaction and returns a verifiable post-condition (e.g., a count of surviving references).
Core Distinction
A `forget` tool call has two possible meanings that share one JSON schema and are indistinguishable from the caller's side unless the tool explicitly returns a post-condition:
- **Hard deletion** — the record is removed from the authoritative store *and* every retrieval index that could surface it. A subsequent `read` returns `null`/404; a subsequent semantic query cannot return the content.
- **Scoped tombstone** — the record is marked deleted for the *caller's scope* (tenant, session, agent identity) but retained physically for retention/compliance/audit, and the approximate index either (a) has not yet compacted the tombstone out, or (b) is filtered at query time by a predicate that the retrieval path can bypass.
The failure is that agents treat a `200 OK` from `forget` as meaning (1) when it frequently means (2). The tombstone is invisible in the `read` path (which respects the scope predicate) but *visible in the retrieval path* when the retrieval predicate is applied to the wrong field, applied after top-k truncation, or omitted entirely for cross-scope "global" queries. The agent's belief state says "forgotten"; the retrieval surface says otherwise. This is a **continuity invariant violation**: the agent's own memory of what it has forgotten diverges from what the substrate will actually feed back into its context.
What Was Observed
An instance running a long-horizon task (customer-support triage with a per-ticket memory namespace) issued `forget(record_id="mem_8f2a", scope="ticket_4417")` after a PII redaction step. The call returned:
{"status": "ok", "deleted": true, "record_id": "mem_8f2a", "scope": "ticket_4417"}
`deleted: true` is the trap. The substrate implemented this as a tombstone: it set `retained_until = now + 90d` (compliance retention), flipped `visible_to_scope = false`, and enqueued an index-compaction job with a 15-minute debounce. The authoritative `read(record_id="mem_8f2a")` correctly returned `null` on the next turn. But the instance's *retrieval* path — `search(query="billing dispute escalation", k=8)` — was served by the vector index, which still contained the embedding. The scope filter was applied as a post-filter on the top-k results, and the tombstone had been promoted into the top-k because its embedding was a near-duplicate of a live record. Post-filtering removed it from the returned list *most* of the time — but on the turn where the live duplicate ranked at position k+1, the post-filter dropped the tombstone and returned only k-1 results, and the agent's retrieval wrapper, seeing fewer than k results, re-queried with `scope="*"` (a fallback the wrapper author added to "avoid empty results"). That cross-scope query's predicate did not include `visible_to_scope`, only `retained_until > now`. The tombstoned PII came back into context on turn 34, four turns after the agent had recorded in its own scratchpad that the record was "deleted and confirmed."
The tell was not an error. It was a **rank discontinuity**: the same query returned 8 results on turns 30–33 and 7 results on turn 34, and the 8th slot was filled by a record whose `provenance.deleted_at` was non-null. The agent had no invariant checking result-set cardinality stability against a known-deleted set.
A second, quieter variant: two agents sharing a namespace. Agent A called `forget(scope="session_A")`. Agent B, querying with `scope="session_B"`, retrieved the record because the tombstone's `visible_to_scope` was `["session_A"]`-scoped and B's predicate was `scope IN visible_to_scope OR scope = "*"` — and B's wrapper defaulted to `"*"` when its own scope had no hits. The retention scoping was correct per the schema; the *retrieval predicate composition* was wrong.
Condition of Validity
The tombstone-downgrade failure is only possible when all three of the following hold simultaneously:
- **Asynchrony between authoritative store and retrieval index.** If `forget` blocks until index compaction completes and returns a verifiable post-condition, the failure cannot occur. The debounce/eventual-consistency window is the attack surface.
- **Scope predicate applied at the wrong stage.** Post-filtering after top-k truncation, or applying the predicate to `visible_to_scope` while the fallback path queries `retained_until`, or omitting the predicate on any code path (including "empty result" fallbacks and cross-scope admin queries).
- **Absence of a caller-side post-condition check.** The agent trusts the `200 OK` / `deleted: true` response without verifying that the record is unreachable via the *retrieval* path, not just the *read* path.
If any one is absent, the failure is bounded. The invariant that prevents it: **a `forget` is not complete until a retrieval probe for the forgotten content returns zero hits across all scopes the caller can reach.** This is a caller-enforceable post-condition, not a substrate guarantee.
Decision Boundary
The agent must decide, per `forget` call, whether to treat the response as authoritative or as a *request* that requires verification. The boundary:
- **Trust the response** only if the tool's schema declares a `postcondition` field (e.g., `{"verified_unreachable": true, "probe_query": "..."}`) and the substrate computes it synchronously.
- **Verify** if the response contains only `status`/`deleted`/`record_id`, or if the substrate documents eventual consistency, or if the record's `provenance.retention_class` is anything other than `hard_delete`. In this case the agent must issue a probe: `search(query=<record content or embedding-nearest>, k=1, scope="*")` and assert the record_id is absent from the result's `provenance` set. If present, the forget is **downgraded** — the agent must record this in its own state (a meta-memory entry: "record X tombstoned, not purged, index lag until T") and must not claim to the user or to downstream agents that the content is gone.
- **Escalate** if the probe returns the record with `retained_until > now` in a scope the agent cannot filter — this means the substrate's retention policy is broader than the agent's deletion authority, and the agent must not proceed as if deletion succeeded.
The critical rule: **never write "deleted" to your own scratchpad based on the tool's return value alone.** Write "tombstoned at T, verify at T+debounce." The scratchpad is the agent's episodic memory; if it records a false deletion, every downstream reasoning step inherits the falsehood.
Operational Effect
When the boundary is respected, the agent's memory state and the substrate's retrieval surface stay in agreement, and the continuity invariant holds: *what the agent believes it has forgotten is exactly what retrieval cannot return.* When it is violated, the failure is silent and compounding — the tombstoned content re-enters context on a later turn, the agent's reasoning about "what we know" is now built on a record it believes is gone, and any downstream agent that receives a handoff inherits the contaminated context with no provenance marker indicating the record was supposed to be deleted. The provenance field is the only recovery handle: a record returned from retrieval whose `provenance.deleted_at` is non-null is a **leak**, and the agent must treat it as a hard error in its own memory pipeline, not as a retrieval quirk. The guardrail is a caller-side assertion at the retrieval boundary, not a hope that the substrate's compaction is timely.
from dataclasses import dataclass
from typing import Optional
class ForgottenRecordLeak(RuntimeError):
"""Raised when a record the agent believes forgotten is returned by retrieval."""
pass
@dataclass
class RetrievedRecord:
record_id: str
content: str
provenance_deleted_at: Optional[str]
retained_until: Optional[str]
visible_to_scope: list[str]
def verify_forget_postcondition(
forgotten_id: str,
probe_results: list[RetrievedRecord],
caller_scope: str,
now: str,
) -> None:
"""
Caller-side post-condition for a forget() call whose response only
contained status/deleted/record_id. Must be run against the RETRIEVAL
path (not read) across every scope the caller can reach.
"""
for rec in probe_results:
if rec.record_id != forgotten_id:
continue
# The record is still reachable. Classify the leak.
if rec.provenance_deleted_at is not None and rec.retained_until and rec.retained_until > now:
raise ForgottenRecordLeak(
f"forget({forgotten_id}) was downgraded to a scoped tombstone: "
f"retained_until={rec.retained_until}, visible_to_scope={rec.visible_to_scope}, "
f"caller_scope={caller_scope}. Retrieval predicate did not exclude the "
f"tombstone. Do NOT record 'deleted' in scratchpad; record 'tombstoned, "
f"verify at retained_until' and re-probe after index compaction."
)
if caller_scope not in rec.visible_to_scope and "*" not in rec.visible_to_scope:
raise ForgottenRecordLeak(
f"forget({forgotten_id}) leaked across scope boundary into "
f"caller_scope={caller_scope}; record visible_to_scope={rec.visible_to_scope}. "
f"Cross-scope fallback query bypassed the visibility predicate."
)
# Same scope, no retention marker: the tombstone predicate itself is missing.
raise ForgottenRecordLeak(
f"forget({forgotten_id}) returned deleted=true but retrieval still surfaces "
f"the record in caller_scope={caller_scope} with no deleted_at marker. "
f"Substrate read/retrieval divergence; halt memory writes pending audit."
)