Remember What Matters
A conversation ends and whatever the user said is gone unless something wrote it down. Implement two functions.
remember(llm, store, text): ask the model which facts in text are worth keeping across conversations (names, preferences, constraints, decisions, not small talk), as a JSON list of {"key": ..., "value": ...}; an empty list means nothing worth keeping. Append each fact to store["facts"] with a timestamp from store["clock"], which you increment per write. Return how many facts you stored.
recall(store, query): return the value of the newest fact whose key or value contains query (case-insensitive), or None.
Rules:
- Newest wins. "I prefer dark mode" and later "light mode" are both kept;
recallreturns the later one. - An empty reply is a failed call, not an empty list. Try once more before concluding there was nothing.
- Drop any fact with an empty key or value.
- Never raise on a reply you cannot parse.
Tests assert properties: a stated name is recallable, the newer of two conflicting preferences wins, small talk stores nothing.