Skip to content

[upstream PR 928] feat(search): add temporal decay to recall ranking #384

@wbugitlab1

Description

@wbugitlab1

Source: Source pull request number: 928 in rohitg00/agentmemory (URL omitted to avoid GitHub cross-reference)
Title: feat(search): add temporal decay to recall ranking
Author: Srinath279
State: open
Draft: no
Merged: no
Head: Srinath279/agentmemory:feat/temporal-decay-recall @ 62e52ad
Base: main @ f6f9e3c
Labels: (none)
Changed files: 0
Commits: 0
Created: 2026-06-14T00:05:19Z
Updated: 2026-06-14T00:13:18Z
Closed: (not closed)
Merged at: (not merged)

Original PR body:

Recall fuses BM25 + vector + graph into a single RRF relevance score with no notion of time, so an equally-relevant note from this morning and one from a year ago rank identically. This adds an opt-in temporal decay reweight that blends an exponential recency factor (and optional importance term) into the relevance score, so fresh and reinforced memories surface ahead of equally-relevant stale ones.

Design:

  • Exponential decay parameterized by a configurable HALF-LIFE (days), the interpretable forgetting-curve knob.
  • Multiplicative reweight of the (small, unnormalized) RRF score rather than additive, so relevance stays the dominant signal.
  • A floor on the multiplier so decay demotes but never erases an old-but-highly-relevant hit.
  • "Use it or lose it": effective age is measured from the later of creation or last access (reuses the existing AccessLog), so recall refreshes recency.
  • Importance slows decay, mirroring the Generative Agents importance term.

OFF by default (AGENTMEMORY_TEMPORAL_DECAY=true), matching the project's opt-in posture for changes that alter recall ordering. When disabled the reweight short-circuits with zero added cost.

Adds src/functions/temporal-decay.ts (pure, fully unit-tested), config getters + safeParseFloat, HybridSearch integration, and .env.example docs.

Summary by CodeRabbit

  • New Features

    • Added temporal decay to memory recall scoring, re-ranking results using recency in combination with importance.
  • Chores

    • Introduced configuration controls to enable/disable temporal decay and tune half-life, recency/importance weighting, and a minimum decay floor (documented in the example environment file).
    • Added comprehensive automated tests covering recency factor, decay bounds, and timestamp handling.

Local branch:
Fork PR:
Fork decision:
Verification:
Notes:

Metadata

Metadata

Assignees

No one assigned

    Labels

    decision-candidateFork decision has not been madeupstream-openUpstream pull request is openupstream-prTracks an upstream pull request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions