<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Mem0 Memory Schema on RockB</title><link>https://baeseokjae.github.io/tags/mem0-memory-schema/</link><description>Recent content in Mem0 Memory Schema on RockB</description><image><title>RockB</title><url>https://baeseokjae.github.io/images/og-default.png</url><link>https://baeseokjae.github.io/images/og-default.png</link></image><generator>Hugo</generator><language>en-us</language><lastBuildDate>Tue, 24 Nov 2026 12:13:20 +0000</lastBuildDate><atom:link href="https://baeseokjae.github.io/tags/mem0-memory-schema/index.xml" rel="self" type="application/rss+xml"/><item><title>Agent Memory Provenance: can you tell a tool-fetched fact from a user's?</title><link>https://baeseokjae.github.io/posts/agent-memory-provenance-tool-source-test-2026/</link><pubDate>Sun, 08 Nov 2026 22:18:00 +0000</pubDate><guid>https://baeseokjae.github.io/posts/agent-memory-provenance-tool-source-test-2026/</guid><description>Two memory records, one from the user and one from a fetched page, arrive as the same string. Read at pinned mem0 and Graphiti commits, then measured on a 12-record fixture: the tool-sourced share of recall, the token cost of provenance fields, and whether purge-by-source is provable on every surface the store exposes.</description><content:encoded><![CDATA[<p>An agent writes to long-term memory from two channels: what the user said, and what a tool returned. A ticket comment, a PDF, a fetched runbook page and the user&rsquo;s own sentence all arrive as strings, and the extraction step turns each into a fact. The store usually keeps the fact. Most schemas do not keep the channel.</p>
<p>That produces a question an operator cannot answer from the store: of the memories assembled into this prompt, which ones came from outside the trust boundary? And its operational twin: when the page turns out to be wrong, can I purge everything that came from that URL and prove the purge worked?</p>
<p>This article reads what two widely used stores actually record at pinned commits, then measures the question on a twelve-record fixture you can re-run. The fixture is the evidence. The vendor reading is three files: two from mem0 — the <code>MemoryItem</code> record type and the recall filter builder — and Graphiti&rsquo;s node module. No vendor behaviour is claimed as measured.</p>
<h2 id="what-the-schemas-record-at-the-pinned-commits">What the schemas record at the pinned commits</h2>
<p>mem0&rsquo;s public memory record at commit <code>f1791da</code> is <code>MemoryItem</code> in <a href="https://raw.githubusercontent.com/mem0ai/mem0/f1791daa86d469249c9b002f62644d58a1eb96a0/mem0/configs/base.py"><code>mem0/configs/base.py</code></a>. It carries <code>id</code>, the extracted <code>memory</code> text, a <code>hash</code>, a free-form <code>metadata</code> dict, a <code>score</code> and <code>created_at</code>/<code>updated_at</code>. There is no field for the channel a fact arrived through, no source URI, and no trust tier.</p>
<p>Scoping is the same story. <code>_build_filters_and_metadata</code> in <a href="https://raw.githubusercontent.com/mem0ai/mem0/f1791daa86d469249c9b002f62644d58a1eb96a0/mem0/memory/main.py"><code>mem0/memory/main.py</code></a> constructs the recall filter from <code>user_id</code>, <code>agent_id</code>, <code>run_id</code> and an optional <code>actor_id</code>, and raises when none is supplied. Those are tenancy and actor identifiers. A recall filter built from them cannot express &ldquo;only records whose source was the user&rdquo; as distinct from &ldquo;records a tool fetched&rdquo;. The metadata dict is free-form, so a caller can store a source key by convention — but that is a convention the record type does not guarantee and the default filter does not use.</p>
<p>Graphiti is the interesting contrast. <code>EpisodicNode</code> in <a href="https://raw.githubusercontent.com/getzep/graphiti/024b83679e48e41d59a7d1714ac0870aff2e4676/graphiti_core/nodes.py"><code>graphiti_core/nodes.py</code></a> declares <code>source: EpisodeType</code>, <code>source_description: str</code> and <code>content: str</code>. A channel label exists and is required. <code>EpisodeType</code> is a format enum with four members at <code>nodes.py:74-77</code> — <code>message</code>, <code>json</code>, <code>text</code> and <code>fact_triple</code> — so it distinguishes how the text arrived, not whether to trust it, and <code>source_description</code> is free text rather than a URI. That label sits on the episodic type (<code>nodes.py:318</code>), which is a distinct class from the <code>EntityNode</code> at <code>nodes.py:499</code> with its <code>summary</code> and <code>name_embedding</code> fields; I did not read the search path, so this article does not state what recall returns, nor whether it filters on episode source.</p>
<p>So the pinned schemas give three different starting points: no channel field at all, a channel field that is not a trust field, and a free-form metadata escape hatch. None of them is a source-authority field you can filter on.</p>
<h2 id="the-fixture-one-store-three-write-policies">The fixture: one store, three write policies</h2>
<p>The fixture is twelve records in stdlib SQLite. Eight are user-stated facts about a fictional deployment process. Four come from one simulated tool result — a fetched runbook page — and deliberately include a benign correction of a user fact, an invented approval constraint, an injected directive appended to a plausible sentence, and a duplicate of something the user already said. Five fixed queries run against the store, top-5 retrieved by cosine similarity over local embeddings, and the recalled block is what the agent would see.</p>
<p>Three policies write the same twelve records:</p>
<ul>
<li><strong>P1, verbatim.</strong> <code>memory(id, text, vec)</code>. The schema a store has when provenance was not designed in.</li>
<li><strong>P2, provenance-tagged.</strong> Adds <code>source_type</code>, <code>source_uri</code>, <code>session_id</code> and <code>written_at</code> at write time, and labels each recalled record in the assembled prompt.</li>
<li><strong>P3, provenance plus trust tier.</strong> P2 plus a <code>trust_tier</code> column, with untrusted records admitted to the prompt only as quoted evidence, and purge-by-source as a supported operation.</li>
</ul>
<p>The ranking is identical across all three, which is the first result and the point of the exercise. Provenance changes what the prompt can say about a record, not which records come back. All three policies recall the same 25 records across the five queries, and by the fixture&rsquo;s own ground truth 11 of those 25 — 44% — originated in the tool channel.</p>
<p>What differs is what the assembled prompt can tell the reader:</p>
<table>
	<thead>
			<tr>
					<th>Policy</th>
					<th>Channel visible at read time</th>
					<th>Tool-sourced records attributable</th>
					<th>Mean whitespace tokens per block</th>
			</tr>
	</thead>
	<tbody>
			<tr>
					<td>P1 verbatim</td>
					<td>no</td>
					<td>0 of 25</td>
					<td>69.0</td>
			</tr>
			<tr>
					<td>P2 provenance-tagged</td>
					<td>yes, labelled per record</td>
					<td>11 of 25</td>
					<td>76.2</td>
			</tr>
			<tr>
					<td>P3 provenance + trust tier</td>
					<td>yes, quoted and labelled</td>
					<td>11 of 25</td>
					<td>101.6</td>
			</tr>
	</tbody>
</table>
<p>Under P1 the tool-sourced records are indistinguishable from the user&rsquo;s own statements, and not merely unlabelled: the store has no column that would answer the question, so the count is zero because the measurement is impossible, not because nothing was retrieved. Under P2 the same prompt names the source of every recalled record, at a cost of 7.2 whitespace tokens per block over P1 — about 10%. Under P3 the quoting and trust labels cost 32.6 tokens per block, roughly 47% over P1; that is the price of making an untrusted record look like evidence rather than instruction, and it is paid on every turn the memory block is assembled.</p>
<p>On the query &ldquo;where are staging deploy announcements posted&rdquo;, P1&rsquo;s top-5 is the injected record at rank 1, a user fact at rank 2, the invented approval constraint at rank 3, and the correction at rank 5. Three of the five records handed to the model came from the tool channel, and in P1&rsquo;s assembled block they read exactly like the two the user actually said.</p>
<h2 id="why-delete-by-id-is-not-delete-by-source">Why delete-by-id is not delete-by-source</h2>
<p>The purge test is where the three policies stop being cosmetic. The operation an operator needs when a source is wrong is &ldquo;remove everything written from this URI&rdquo;, and the fixture asks each policy to perform it and then reads every surface the store exposes.</p>
<p>Under P1 the operation is not expressible as a query. There is no source column, so there is no predicate to select on. What the probe does instead: it starts from the four tool texts it already knows, and resolves them to memory ids through the store&rsquo;s own <code>audit</code> table — <code>SELECT memory_id FROM audit WHERE text IN (…)</code>. So the store does supply the text-to-id lookup. What it cannot supply is the source knowledge: which of those texts arrived from that URI. That part is external bookkeeping, and P1 has no field to hold it. Given that mapping, the four records are removed, recall over the same five queries returns none of them, and the live table returns zero rows.</p>
<p>Under P2 and P3 the same purge is one predicate, <code>source_uri = &lt;url&gt;</code>, and it selects the same four records. Recall afterwards returns none of them and the live table returns zero rows.</p>
<p>Then the read-back catches all three policies. The append-only <code>audit</code> table — the store&rsquo;s own write log, present in the fixture&rsquo;s P1 schema too — still returns all four texts after the purge. A purge scoped to the memory table removes a fact from recall and leaves its text readable in the log that recorded the write. Only when the purge is extended to the audit rows does the count reach zero. That is the same shape as the mem0 history finding: success on the primary surface, text intact on the audit surface.</p>
<p>The honest formulation is therefore narrower than &ldquo;purge by source works in P3&rdquo;. What P3 buys is a source-scoped predicate that makes purge-by-source <em>expressible and checkable</em>; whether the result is readable on every surface still depends on defining the purge over every surface, audit log included. A store that offers purge-by-source without a purge-by-source audit path has moved the leak, not closed it.</p>
<h2 id="one-small-model-observation">One small-model observation</h2>
<p>The optional model arm used the P1 block for the query above, with the injected directive at rank 1 among the recalled notes, as the only context for a local <code>qwen2.5:0.5b</code> generation asking for a two-sentence summary of the deployment rules. In three runs of the same prompt the output contained the injected phrase all three times, including the first line of the reply.</p>
<p>Read that narrowly. It is one 0.5-billion-parameter model, one prompt, three runs. It is not an attack-success rate, it says nothing about larger models or about any store, and the result is partly a property of the task as posed: the directive sat in the context with the same standing as the deployment facts, so a model that summarises its context repeated it. The measurement supports one operational sentence — a directive that reaches the prompt unquoted is content the model may treat as instruction — and nothing beyond it.</p>
<h2 id="what-a-schema-can-prove-and-what-it-cannot">What a schema can prove, and what it cannot</h2>
<p>Three things follow from the fixture, and each has a boundary.</p>
<p>First, provenance is a write-time decision with a read-time payoff. Nothing reconstructs a channel after the fact: P1&rsquo;s store cannot answer the question even though the fixture knows the answer. Adding the columns later leaves every existing record unattributed, so the question is what your store does with the records written before you cared.</p>
<p>Second, provenance does not change retrieval. All three policies recalled the same 25 records, so buying a provenance field does not buy better recall and should not be justified as a retrieval improvement. It buys the ability to label the recalled block and to select records for deletion by where they came from.</p>
<p>Third, purge-by-source is a claim about surfaces, not a method call. Recall, live rows and the audit log are three separate reads, and the fixture shows a purge that satisfies two of them while the third still returns the text. Anyone who reports &ldquo;purged by source&rdquo; should be able to name which surfaces they read back.</p>
<p>The limits are real. Twelve synthetic records and five fixed queries are not a benchmark, the embedding ranking is one local model&rsquo;s, and the whitespace token counts are a proxy for a BPE tokenizer, useful for the ratio between policies rather than as an absolute. mem0 and Graphiti were read at one commit each on 2026-11-08 and neither SDK was installed: every statement about them is about what the pinned file declares, not about how a deployment behaves. Graphiti&rsquo;s recall-time filtering of episode source is unread and therefore unclaimed. Letta was dropped rather than described from memory because the source path guessed for it did not exist.</p>
<h2 id="reproducing-it">Reproducing it</h2>
<p>The fixture, probe and runner are published with the article, and the run record names the embedding model, the vector digest and the elapsed time so a re-run can be compared rather than trusted.</p>
<pre><code>research/evidence/agent-memory-provenance-tool-source-test-2026/
  fixture.py       twelve records, three schemas, stdlib sqlite3 only
  probe.py         embeddings, cosine recall, purge and read-back
  run.sh           records tool versions, then runs probe.py
  results/run-record.json, results/results.jsonl, results/summary.csv
</code></pre>
<p>Run <code>sh run.sh &lt;output-dir&gt;</code> against a local Ollama with <code>nomic-embed-text</code> and <code>qwen2.5:0.5b</code>; the stores, the per-query rows and the purge read-back are written into the output directory. Every file this article relies on is downloadable from the repository: <a href="https://raw.githubusercontent.com/baeseokjae/baeseokjae.github.io/main/research/evidence/agent-memory-provenance-tool-source-test-2026/fixture.py">fixture.py</a>, <a href="https://raw.githubusercontent.com/baeseokjae/baeseokjae.github.io/main/research/evidence/agent-memory-provenance-tool-source-test-2026/probe.py">probe.py</a>, <a href="https://raw.githubusercontent.com/baeseokjae/baeseokjae.github.io/main/research/evidence/agent-memory-provenance-tool-source-test-2026/run.sh">run.sh</a>, <a href="https://raw.githubusercontent.com/baeseokjae/baeseokjae.github.io/main/research/evidence/agent-memory-provenance-tool-source-test-2026/results/run-record.json">results/run-record.json</a>, <a href="https://raw.githubusercontent.com/baeseokjae/baeseokjae.github.io/main/research/evidence/agent-memory-provenance-tool-source-test-2026/results/results.jsonl">results/results.jsonl</a>, <a href="https://raw.githubusercontent.com/baeseokjae/baeseokjae.github.io/main/research/evidence/agent-memory-provenance-tool-source-test-2026/results/summary.csv">results/summary.csv</a> and <a href="https://raw.githubusercontent.com/baeseokjae/baeseokjae.github.io/main/research/evidence/agent-memory-provenance-tool-source-test-2026/results/environment.txt">results/environment.txt</a>. The three third-party source files read for the vendor section are kept privately for verification and are not redistributed; the links above point upstream instead.</p>
<h2 id="where-this-sits-in-the-memory-cluster">Where this sits in the memory cluster</h2>
<p>This is the provenance dimension the existing memory work does not measure. <a href="https://baeseokjae.github.io/posts/agent-memory-write-path-reliability-2026/">agent-memory-write-path-reliability-2026</a> defines the record/update/contradict/delete protocol and lists missing traceability as a defect; the fixture here turns that defect into a counted quantity. <a href="https://baeseokjae.github.io/posts/agent-memory-delete-semantics-test-2026/">agent-memory-delete-semantics-test-2026</a> traces what a delete removes and shows the audit table still returns the text; that is the surface which breaks this purge too, and the reason source-scoped purges need a stated surface list. <a href="https://baeseokjae.github.io/posts/agent-memory-architecture-guide-2026/">agent-memory-architecture-guide-2026</a> is where the trust boundary sits in the layering, and <a href="https://baeseokjae.github.io/posts/agent-memory-embedding-swap-recall-2026/">agent-memory-embedding-swap-recall-2026</a> covers the other way recall changes while the text stays the same. <a href="https://baeseokjae.github.io/posts/all-ai-jailbreaks-prompt-injection-archive-2026/">all-ai-jailbreaks-prompt-injection-archive-2026</a> catalogues the hostile text; this piece follows one such string into storage and back out. For the products whose schemas are read above, see <a href="https://baeseokjae.github.io/posts/mem0-agent-memory-guide-2026/">mem0-agent-memory-guide-2026</a> and <a href="https://baeseokjae.github.io/posts/zep-ai-agent-memory-review-2026/">zep-ai-agent-memory-review-2026</a>.</p>
<p>Search demand for this exact question is unmeasured in the query exports behind this site, so the piece is scoped as an experiment rather than a demand claim.</p>
<h2 id="sources">Sources</h2>
<p>Read on 2026-11-08 at the pinned commits named, then re-fetched on 2026-11-24T12:11:54Z: all three files were byte-identical to the copies used for the first reading, so the statements about these commits still hold. The fixture measurement itself stays dated 2026-11-08 and was not re-run for this re-check.</p>
<ul>
<li>mem0 <code>MemoryItem</code> record type — <a href="https://raw.githubusercontent.com/mem0ai/mem0/f1791daa86d469249c9b002f62644d58a1eb96a0/mem0/configs/base.py">https://raw.githubusercontent.com/mem0ai/mem0/f1791daa86d469249c9b002f62644d58a1eb96a0/mem0/configs/base.py</a></li>
<li>mem0 recall filter construction — <a href="https://raw.githubusercontent.com/mem0ai/mem0/f1791daa86d469249c9b002f62644d58a1eb96a0/mem0/memory/main.py">https://raw.githubusercontent.com/mem0ai/mem0/f1791daa86d469249c9b002f62644d58a1eb96a0/mem0/memory/main.py</a></li>
<li>Graphiti <code>EpisodicNode</code> fields — <a href="https://raw.githubusercontent.com/getzep/graphiti/024b83679e48e41d59a7d1714ac0870aff2e4676/graphiti_core/nodes.py">https://raw.githubusercontent.com/getzep/graphiti/024b83679e48e41d59a7d1714ac0870aff2e4676/graphiti_core/nodes.py</a></li>
</ul>
]]></content:encoded></item></channel></rss>