AGENT MEMORY · RETRIEVAL WORKBENCH

Semantic memory: retrieve stored facts

Follow real ranking calculations from stored memory cards through scope filters into a bounded context tray.

30-second inspection at 1× · actual TF-IDF cosine

Your experiment

Choose the semantic store and ask about deployment region. Switch tenants and observe how the selected fact changes without crossing the tenant boundary.

Make a prediction, capture a baseline, change one policy and advance through all four stages. An empty context is a valid result; the table explains every exclusion.

Selected context

    The tray is populated at the final stage. No answer is generated: compare the selected source facts yourself.

    Inspect every record

    IDMemory textCosineBlended scoreOutcome

    Offline teaching model, not an ADK service implementation or a trained semantic encoder. The ten records and supporting-fact labels are synthetic fixtures. Retrieval uses lexical TF-IDF cosine; semantic refers to the type of stored fact, not neural similarity. Score = (1 − recency weight) × cosine + recency weight × 2^(−age/24h). Zero lexical matches are excluded. Greedy packing skips records that do not fit. Budgets count whitespace-separated words, not model tokens. Memory types, tenant rules, age limits and latest-key replacement are explicit application policies; no LLM accuracy, production capacity or privacy guarantee is measured. ADK memory concepts · Cosine similarity reference.

    Facts are different from matching words

    Semantic memory in this lesson means stored factual assertions, not neural semantic search. Ten synthetic records contain policies, deployment regions, incidents and instructions. The experiment asks whether the right fact survives scope, age, version and budget rules. It deliberately separates retrieving a source from answering a question. The two related readings describe richer extraction, consolidation and vector-store systems; this local fixture implements none of their model calls or service APIs.

    Compare two tenants at an exact boundary

    Choose the deployment-region Question and Semantic facts in Memory store. Keep previous sessions enabled, maximum age 168, recency zero, maximum retrieved records three and budget forty. Team A retrieves M2: Mumbai. Switch to Team B: only M9, London, is selected; M2 has the tenant-boundary reason. Switch back to Team A. M2 has eight words: budget eight includes it and budget seven gives an empty tray. Set maximum age twenty to include M2, then nineteen to exclude it. An empty result is preferable to silently borrowing another tenant's fact.

    Expose a stale assertion

    Choose the retry-budget Question, Team A and Semantic facts. Set budget eighty, maximum age 168 and maximum retrieved records ten. Disable Keep latest fact per key: both M1, three attempts, and M6, the obsolete five-attempt policy, enter the context. Enable the control and M6 is superseded. Disabling previous sessions removes both facts. At six words M1 fits exactly; at five it cannot fit. Observe that lexical similarity alone cannot decide which contradictory assertion is current.

    Scope before similarity

    Question selects one of four fixed queries. Active tenant is a hard filter: Team A and Team B cannot select one another's records. Memory store chooses semantic facts, episodic events, procedural steps, working context or all stores. Include previous sessions admits older conversations; disabling it leaves only current-session records. Maximum age is an inclusive retention boundary, measured in fixture hours. Keep latest fact per key excludes an older record whenever a newer record with the same tenant and key exists, even if other filters later exclude that newer record. It does not resurrect stale facts. These are application policies in a local example, not a tested production authorization or deletion service.

    Read the actual score

    The model lowercases words, removes a fixed stop-word list and computes log term frequency with smoothed inverse document frequency over ten fixed records. Cosine is the dot product divided by the two vector lengths. Recency weight blends that cosine with 2 raised to minus age divided by twenty-four hours. At zero, ranking uses only cosine; at one, it uses only recency, but records with no shared query terms remain excluded. This lexical method does not understand paraphrases or negation. A recent or high-scoring record can still be the wrong evidence. The table exposes each full text, cosine, blended score and exclusion reason.

    Pack and inspect

    Context word budget limits the sum of whitespace-separated record lengths. Maximum retrieved records imposes a separate count limit. Greedy packing visits ranked candidates, skips those too large for the remaining budget, and continues. It neither truncates records nor solves an optimal packing problem. The result is computed immediately. Play reveals stored records, scope filters, ranking and the final context over thirty inspection seconds at normal speed. Pause settles elapsed time and freezes it; Next stage pauses at the next ten-second boundary. Restart inspection preserves policy settings and speed while clearing playback. Speed offers quarter, half, normal and double pace; changing it settles time at the old pace first. Input changes restart inspection, and a hidden tab pauses. Reduced-motion preference prevents automatic playback after input changes.

    Keep a reproducible observation

    Capture baseline saves the visible preview and settings, Replace baseline refreshes them, and Clear baseline removes the comparison. Record selected record IDs and exclusions in the notebook; Export notes downloads your observations and the notebook survives reload. Expand experiment enters fullscreen; Exit full screen returns. The diagram and record table scroll horizontally by keyboard on a phone to preserve readable labels. Supporting-fact coverage counts declared fixture IDs; it is not a measured answer-quality score. No language model generates an answer, no embedding service is called, and no persistent bank is modified. Read the source text before treating a retrieved fact as true.

    Views are my own and do not represent any employer, past or present.

    Search