Article chapter 06 of 08
Retrieve by task, scope and time
From Long-term AI memory: records, relationships and retrieval
A memory system should retrieve records for a defined task rather than assemble a generic profile of everything related to the user. The request can include the authenticated actor, task type, relevant entities, time reference and expected memory categories.
Apply hard filters first: tenant, permissions, sensitivity, validity and task scope. Ranking happens only inside the allowed set. Filtering a ranked result afterwards risks exposing restricted values to the ranking service and wasting the result budget on items the user cannot see.
Use several retrieval methods for different evidence:
- exact lookup for known entities and properties;
- graph traversal for typed relationships;
- lexical search for identifiers and precise terms;
- semantic search for conceptually related source passages;
- recency and authority rules for current-state selection.
Combine results into a compact context package. Current records should identify their source and status. Decisions should include scope and whether they remain active. Historical or disputed records need clear labels. Source passages can be attached when wording or rationale matters.
Limit traversal depth. A service may connect to an owner, who connects to many projects, which connect to large archives. Unbounded expansion produces related but useless context. Start from task entities and permit only relationship types known to help that task.
Rank current-state records by authority, validity, scope match and task relevance. A recent speculative note should not outrank an older approved decision that remains active. Use recency to resolve records that are otherwise comparable.
Allow the retriever to return no memory when nothing relevant and authorised exists. The agent can then ask a question or consult the source system instead of receiving the least irrelevant stored item.
Record what was retrieved and used. This supports debugging when a task follows stale context, and it provides training material for retrieval evaluation without requiring the full prompt to become the primary audit artefact.