r/synapcores • u/Alternative_Pin9598 • 1d ago
Recipe of the week #4: RAG said "Team plan" from an agent's guess; billing says Enterprise. A memory object in SQL answers from the billing note and knows what was true on any past date (real output)
Every Monday: one site recipe, run on the current release, real output inline.
(This sub is run by the SynapCores team. Run this morning on 2.5.1.)
The problem
Ask a RAG pipeline "which plan is Harborline on right now?" and it fetches the notes that sound most like the question. Similarity tells you what's relevant, not what's still true.
1. Fourteen notes about one customer
Nine months, including an agent's guess and a call note filed four months late (INSERTs in the first comment):
CREATE TABLE account_notes (note_id INTEGER PRIMARY KEY, account_id TEXT,
noted_at TIMESTAMP, filed_at TIMESTAMP, source TEXT, body TEXT, embedding VECTOR(384));
UPDATE account_notes SET embedding = EMBED(body);2. What plain RAG hands the model
SELECT note_id, noted_at, ROUND(COSINE_SIMILARITY(embedding, EMBED('Which plan is Harborline on right now?')), 3) AS relevance, body
FROM account_notes WHERE account_id = 'harborline'
ORDER BY relevance DESC LIMIT 3;
8 2026-08-01 00:00:00 0.637 Harborline upgraded from Pro to the Enterprise plan.
3 2026-03-04 09:00:00 0.627 Harborline signed the Pro plan, billed annually.
13 2026-10-20 07:00:00 0.614 Usage looks lower this month. Harborline may have downgraded to the Team plan.Three plans, 0.023 apart. Fed those three, the engine's local model (GENERATE, temperature 0) answers:
Harborline is on the Team plan. [note 13, 2026-10-20 07:00:00]Billing says Enterprise. Note 13 is a guess; it's just the newest.
3. The usual fix, a recency boost
score = 0.7 * similarity + 0.3 / (1 + age_in_days / 30) (query in the comments):
13 0.644 Usage looks lower this month. Harborline may have downgraded to the Team plan.
8 0.52 Harborline upgraded from Pro to the Enterprise plan.
11 0.482 Harborline completed its move from Azure to AWS (...)Now the guess ranks first. Recency knows how new a note is, not how much to trust it.
4. Remember the notes with time and authority
CREATE MEMORY account_memory IDENTITY account_id;
REMEMBER account_memory FOR account_id = 'harborline'
'Harborline upgraded from Pro to the Enterprise plan.'
WITH (attribute = 'subscription_plan', value = 'Enterprise', source_type = 'system_of_record', event_time = '2026-08-01T00:00:00Z');
REMEMBER account_memory FOR account_id = 'harborline'
'Usage looks lower this month. Harborline may have downgraded to the Team plan.'
WITH (attribute = 'subscription_plan', value = 'Team', source_type = 'agent_inference', event_time = '2026-10-20T07:00:00Z');
"warnings": ["'subscription_plan' = 'Team' was not accepted as current: lower source authority than the accepted value"]The guess is stored but doesn't become the answer. The late call note: equal authority, older validity.
5. What's true now: a lookup, not a similarity search
SELECT attribute, value, authority, valid_from, previous_value
FROM _mem_account_memory_state WHERE identity = 'harborline'
AND attribute IN ('subscription_plan', 'primary_contact', 'contact_channel', 'cloud_provider')
ORDER BY attribute;
cloud_provider AWS user_statement 2026-09-15 18:00:00 Azure
contact_channel Slack Connect user_statement 2026-09-02 13:00:00
primary_contact Priya Raman user_statement 2026-08-19 10:00:00 Dana Okafor
subscription_plan Enterprise system_of_record 2026-08-01 00:00:00 ProTRACE ... ATTRIBUTE subscription_plan is the receipt: the upgrade note verbatim, system_of_record, 2026-08-01, supersedes Pro.
6. What was true on a past date
Ticket 4412 was opened 2026-06-30 08:40. What was true then?
RECALL account_memory FOR account_id = 'harborline'
ABOUT 'Which cloud was Harborline on?' WITH (as_of = '2026-06-30T08:40:00Z');
"intent": "historical"
cloud_provider: Azure primary_contact: Dana Okafor subscription_plan: ProFive account questions (scoreboard in the first comment): plain RAG 3 right, RAG + recency 4, memory 5, each with its source note.
Recipe (~15 min): https://synapcores.com/recipes/agents/stop-rag-answering-with-outdated-facts?utm_source=reddit&utm_medium=owned&utm_campaign=synapcores-recipe-4
Free Community Edition: https://synapcores.com/download?utm_source=reddit&utm_medium=owned&utm_campaign=synapcores-recipe-4
Join the sub and Recipe of the week #5 lands in your feed next Monday.
When two notes in your RAG store disagree, what decides which one wins: the newest, the source, or nobody?