AGENT MEMORY · RETRIEVAL WORKBENCH

Memory bank: pack a bounded context

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

Reduce the word budget until the best matching fact no longer fits. Explain why the next smaller candidate may be selected instead.

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.

    A bank can contain more than the context can hold

    This memory-bank workbench demonstrates selecting a bounded context from ten fixed cross-session records. Storage capacity, retrieval count and prompt capacity are different quantities. All records remain visible in the table even when selection excludes them. This is a local selection model, not a hosted Memory Bank implementation, a persistence test, a deletion system or a token-accurate context-window estimator. The related readings extend the discussion to consolidation and compaction; neither process runs here.

    A nonempty context can omit the answer

    Choose the database-timeout procedure Question, Procedural steps, Team A, previous sessions enabled, age 168, recency zero and maximum retrieved records three. At budget eleven, M4 fits and supplies the declared procedure. At ten, M4 is skipped, but the shorter M7 deployment checklist fits because it shares logs with the query. The tray is nonempty while supporting-fact coverage is zero of one. At nine neither fits. At twenty only M4 fits; at twenty-one both fit. Reducing the maximum retrieved records to one then removes M7 even though sufficient word budget remains.

    Separate retention from ranking

    Choose the timeout-incident Question with All stores, budget eighty and maximum retrieved records one. Compare recency zero with one: the final choice at one is the current working ticket M5. Select Episodic events and set maximum age forty-seven: the past incident M3 is excluded. At forty-eight it becomes eligible. Turning off previous sessions excludes M3 independently of age. This bank does not summarize an excluded incident or infer missing facts, and recency is not evidence of correctness.

    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