← Back to PRs

#18919: feat: importance-weighted temporal decay for memory search

by ruypang open 2026-02-17 05:47 View on GitHub →
size: M
## Summary Adds an optional importance-weighted boost to the temporal decay system, so emotionally significant or important memories decay slower in search results. ## Changes - Extended `TemporalDecayConfig` with optional `importanceBoost` settings - Added `ImportanceBoostConfig` type with configurable boost factor and pattern matching - `isImportantChunk()` detects importance via file path patterns and content markers (`<!-- important -->`, `**IMPORTANT**`, `[!important]`) - Important memories have their effective age divided by the boost factor (default 3x), making them decay slower - Fully backwards-compatible: importance boost is disabled by default - Added 8 new test cases ## How it works When enabled, the system checks each memory chunk against configurable patterns: - **File patterns**: e.g., `MEMORY.md` files - **Content markers**: inline markers like `<!-- important -->` in the snippet Matching chunks get their effective age divided by `boostFactor`, so a 90-day-old important memory with factor 3 decays as if it were only 30 days old. ## Configuration ```ts temporalDecay: { enabled: true, halfLifeDays: 30, importanceBoost: { enabled: true, boostFactor: 3, patterns: { contentMarkers: ['<!-- important -->', '**IMPORTANT**', '[!important]'], filePatterns: ['MEMORY.md'], }, }, } ``` <!-- greptile_comment --> <h3>Greptile Summary</h3> Adds an optional importance-weighted boost to the temporal decay system for memory search. When enabled, chunks matching configurable file path patterns (e.g., `MEMORY.md`) or content markers (e.g., `<!-- important -->`) have their effective age divided by a configurable `boostFactor`, causing them to decay slower in search results. - New `ImportanceBoostConfig` and `ImportanceBoostPatterns` types with defaults - `isImportantChunk()` function for pattern-based importance detection (case-insensitive) - Importance boost integrated into `applyTemporalDecayToHybridResults` with proper guards (`enabled` check, `boostFactor > 1`) - Fully backwards-compatible: disabled by default, generic constraint change (`snippet?: string`) is non-breaking - 8 new test cases with good edge case coverage (disabled state, `boostFactor=1` no-op, integration with hybrid merge) - Note: the default `MEMORY.md` file pattern in importance boost config is effectively a no-op for `source: "memory"` entries since evergreen memory paths already skip decay entirely via `extractTimestamp` returning `null` <h3>Confidence Score: 4/5</h3> - This PR is safe to merge — the feature is disabled by default and the logic is well-guarded. - Clean, focused implementation with proper feature flag (disabled by default), guard against division by zero/no-op (`boostFactor > 1`), and comprehensive test coverage. No breaking changes to the generic constraint or config shape. Only minor style issue found (redundant type assertion). - No files require special attention. <sub>Last reviewed commit: e1b8d73</sub> <!-- greptile_other_comments_section --> <sub>(5/5) You can turn off certain types of comments like style [here](https://app.greptile.com/review/github)!</sub> <!-- /greptile_comment -->

Most Similar PRs