(feat): mmr and temporal decay#18097
Merged
steipete merged 5 commits intoopenclaw:mainfrom Feb 16, 2026
Merged
Conversation
Adds Maximal Marginal Relevance (MMR) re-ranking to hybrid search results. - New mmr.ts with tokenization, Jaccard similarity, and MMR algorithm - Integrated into mergeHybridResults() with optional mmr config - 40 comprehensive tests covering edge cases and diversity behavior - Configurable lambda parameter (default 0.7) to balance relevance vs diversity - Updated CHANGELOG.md and memory docs This helps avoid redundant results when multiple chunks contain similar content.
Exponential decay (half-life configurable, default 30 days) applied
before MMR re-ranking. Dated daily files (memory/YYYY-MM-DD.md) use
filename date; evergreen files (MEMORY.md, topic files) are not
decayed; other sources fall back to file mtime.
Config: memorySearch.query.hybrid.temporalDecay.{enabled, halfLifeDays}
Default: disabled (backwards compatible, opt-in).
- DEFAULT_MMR_CONFIG.enabled = false (opt-in, was incorrectly true) - Tie-break: handle bestItem === null so first candidate always wins - CHANGELOG URL: docs.clawd.bot → docs.openclaw.ai - Tests updated to pass enabled: true explicitly where needed
Contributor
|
Thanks again for the work here, and sorry for the churn. We accidentally merged a batch of PRs and need to temporarily roll this back for now. Revert details:
We can't repope right now, but we will revisit this later and bring this back properly. |
Contributor
|
Please re-open this in a new PR, needs far more time to review. |
Contributor
Author
|
But I'm curious, did something break because of this? would like more details to help make it better, or do you want it again as is? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
main, and part of its config UI metadata touchedsrc/config/schema.tsin a way that no longer matches current config schema organization.main, aligned config metadata tosrc/config/schema.labels.ts+src/config/schema.help.ts, preserved opt-in defaults, and revalidated tests/checks.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
agents.defaults.memorySearch.query.hybrid.mmr.enabled(defaultfalse)agents.defaults.memorySearch.query.hybrid.mmr.lambda(default0.7)agents.defaults.memorySearch.query.hybrid.temporalDecay.enabled(defaultfalse)agents.defaults.memorySearch.query.hybrid.temporalDecay.halfLifeDays(default30)Vector + Keyword -> Weighted Merge -> Temporal Decay -> Sort -> MMR -> Top-KSecurity Impact (required)
No)No)No)No)No)Yes, explain risk + mitigation:Repro + Verification
Environment
Steps
main.pnpm vitest run src/memory/hybrid.test.ts src/memory/mmr.test.ts src/memory/temporal-decay.test.ts src/config/schema.test.tspnpm checkExpected
Actual
Evidence
Attach at least one:
Human Verification (required)
src/memory/mmr.test.tssrc/memory/temporal-decay.test.tssrc/memory/hybrid.test.tssrc/config/schema.test.tsCompatibility / Migration
Yes)Yes)No)Failure Recovery (if this breaks)
hybrid.mmr.enabled: falseandhybrid.temporalDecay.enabled: false(defaults already false).Risks and Mitigations
schema.labels.ts,schema.help.ts) and validated with schema tests.pnpm checkpassed.Greptile Summary
Adds MMR (Maximal Marginal Relevance) re-ranking and optional temporal decay to the hybrid memory search pipeline. Both features are opt-in (disabled by default) and can be enabled independently via
memorySearch.query.hybrid.mmrandmemorySearch.query.hybrid.temporalDecay.Key Changes:
MEMORY.md, non-datedmemory/*.md) are exempt from temporal decayVector + Keyword → Merge → Temporal Decay → Sort → MMR → Top-Kschema.labels.tsandschema.help.tsstructuredocs/concepts/memory.mdImplementation Quality:
mmr.ts,temporal-decay.ts)Confidence Score: 5/5
Last reviewed commit: b5d57df