Skip to main content
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 semantic 0.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 are semantic, 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.

How Importance Is Assigned

Some stores capture importance during extraction or accept it on manual writes. Review those records before using them for high-impact decisions. Importance does not make generated content verified, authoritative, or safe to share.

Scoring Configuration Reference

For token allocation across memory sections, use context budgets. That is a separate control from candidate ranking. Use memory isolation to choose storage and visibility boundaries before tuning retrieval.