When to recall
You built up a memory store across earlier turns — names, cities, the durable state
the agent wrote down. Now a question arrives for a key you never saved, and the
naive lookup betrays you: store["age"] doesn't throw, it cheerfully returns
undefined. Print that and your agent announces age = undefined — or worse,
some model dressed it up as a real number. You've just manufactured a fact out of
an empty slot. That is hallucination at its most mechanical, and it's a JavaScript
footgun as much as a model one.
The fix is a recall policy: a guard that runs before you answer the question "do I actually hold this key?" The intuition is that a missing key is not a value — it's a different kind of event entirely, and it deserves a different response. So you split the decision in two. If the key is present, recall it and state the real value. If it's absent, don't read the store at all; admit you don't have it.
Take store = { name: "Jakub", city: "Lisbon" } and three questions: name,
city, age. The first two are present, so the agent answers name = Jakub and
city = Lisbon. But age was never written, so "age" in store is false and the
honest line is "I do not have age saved." — no invented number, no undefined
leaking into the answer. Notice this is the same instinct as refusing on a no-match
in retrieval: when the source is empty, say so.
This is the trust boundary of the whole memory track. An agent that fits its window, keeps a scratchpad, and compacts its history is still worthless if it confidently recites facts it never stored. Users forgive "I don't know"; they don't forgive a fabricated answer that sends them to the wrong city.
Below, the store holds name and city but the questions also ask for age. Make
answer check question in store first: recall the real value when the key exists,
and return "I do not have age saved." when it doesn't. Done means the age line
reads exactly that apology, with no undefined anywhere in the output.
Knowing when to read memory matters as much as what's in it. A missing key is not a value of
undefined— it's a signal to say "I don't know."