Use it well

Documentation · updated 9 November 2026

In short: localmem keeps each of your customers' memory over time and already handles history, duplicates, retries, conflicts, sources and separation between customers. Your code sends what it learns and asks what it needs. Do not read before you write to avoid duplicates, do not keep your own copy of the history, and do not ask again for an answer you already have. Read this before wiring localmem into a product; coding agents should read it before writing code.

What localmem already does: do not build it again

localmem does thisSo your code does not
Duplicates and retries. facts and write take an idempotency_key: a repeat answers the first call with duplicate: true and stores nothing again. A document with the same Idempotency-Key within 24 hours is read once.Read memory before writing to check whether something is already there. Give each write a key built from what it holds (below) and send it; a repeat costs nothing.
One value per subject, predicate and time. A fact with the same subject, predicate and as_of as an earlier one replaces it, even after newer values. Sending a value again does not make a second copy.Track which values you already sent, or delete before correcting. Send the corrected value with its original as_of.
History over time. Every value keeps the period it held. recall and search with at_time answer as things stood then; without it, recall returns the whole history, replaced values marked retired_at.Keep your own timeline or "previous value" columns for what you send us.
Changes and conflicts. A write answers superseded (each value it replaced, was and now) and bounded (each late value that holds only until a newer one).Compare old and new values yourself to find what changed: read it from the answer you already got.
Sources and dates. Each fact carries the memory it came from and when it held. Your own id for a value goes in ref.Store a mapping from your ids to ours.
Reading documents. documents.send has a model read prose into facts, kept with the document as their source.Run your own extraction for prose. If you already have structured values, send them as facts: no model is involved.
Customers kept apart. Each customer has its own memory and its own data keys; a key reaches only its project's customers, and test only test.Filter answers by customer, or put several of your users in one customer.
Rate limits. The SDKs wait and retry a rate_limited answer, a busy server and a timeout that cannot repeat work.Write your own retry loop around the SDK.
Deleting a customer. customers.delete stops access at once and removes its memory; the data contract says when no copy remains.Delete facts one by one when a user leaves.

What localmem does not do

Writing efficiently

Reading efficiently

Limits

Before writing code: a checklist for coding agents