computeCompositeScore() blends a supplied semantic signal with recency and importance. Use it in an application-owned ranking pipeline. It is not configured through a memory.scoring option; that option does not exist in v4.
The Scoring Formula
Weights are normalized by their sum. Defaults are semantic0.4, recency 0.3, and importance 0.3. Recency decays exponentially from createdAt; its default half-life is 30 days. Semantic similarity and importance default to 0.5 when omitted and are clamped to 0–1.
Three Factors
Choose a meaningful semantic signal, a creation date, and importance for each candidate. A timestamp is not necessarily a last-access date, and a large importance weight does not guarantee inclusion. Evaluate ranking against representative queries instead of assuming one preset fits every application.Using computeCompositeScore
This example runs locally without a provider or database:
ScoringWeights Interface
The supported weight names aresemantic, recency, and importance. Supply nonnegative finite weights with a positive total in application code. Use a positive half-life and validated dates. The utility’s types do not validate those values at runtime.
Configuration
Use
createdAt, not memoryDate, and halfLifeDays, not recencyHalfLifeDays.
How recall() Uses Scoring
MemoryManager.recall() gathers from enabled stores and returns ranked { content, score, source } records. Its v4 signals are store-specific: facts and entities use text matching, vector-backed learnings use their retrieval path, and some composite inputs are fixed values. Do not describe all results as query-to-record cosine similarity.
Direct graph recall searches the configured graph store; the unified recall method is not an authorization boundary. Use a graph store already scoped to the caller or the graph-memory context path with its documented identity filtering. Do not expose a shared raw recall endpoint based only on a client-supplied user ID.