Article chapter 06 of 08
Retrieving for a task, a scope and a point in time
From Long-term AI memory: records, relationships and retrieval
I'd have the memory system retrieve records for a defined task, and avoid building up a generic profile of everything related to the user. The request can carry the authenticated actor, the task type, the relevant entities, a time reference and the memory categories you expect to need.
Apply the hard filters first: tenant, permissions, sensitivity, validity and task scope. Ranking only happens inside what's left. If you rank first and filter afterwards, you risk exposing restricted values to the ranking service, and you waste the result budget on items the user can't see anyway.
Different evidence calls for different retrieval methods:
- 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 picking the current state
Then combine the results into a compact context package. Current records should show their source and status. Decisions should include their scope and whether they're still active. Historical or disputed records need clear labels. Attach source passages when the wording or rationale matters.
Put a limit on traversal depth. A service connects to an owner, the owner connects to a dozen projects, and those connect to big archives. Let that expand unchecked and you get context that's related and useless. Start from the task's entities and only allow relationship types you know help with that kind of task.
For current-state records, rank by authority, validity, scope match and task relevance. A recent speculative note shouldn't beat an older approved decision that's still active. Use recency to break ties between records that are otherwise comparable.
The retriever should be allowed to return nothing when nothing relevant and authorised exists. Then the agent can ask a question or go to the source system, instead of being handed whichever stored item was least irrelevant.
Log what was retrieved and what got used. When a task runs on stale context, that log is what you debug from. It also gives you material for evaluating retrieval without making the full prompt your main audit record.