mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-31 04:12:10 +03:00
fix(memory): recent strategy must not relevance-filter by prompt
The "recent" memory strategy maps to the internal "exact" retrieval path, whose post-query relevance filter (score > 0) silently dropped recent memories whose text didn't overlap the current prompt. Since the user-facing strategy enum is only recent|semantic|hybrid (no "exact"), forwarding the prompt as `query` for "recent" always engaged that filter, so recency-based injection returned nothing when the prompt was unrelated to the stored memory. Skip query forwarding for the "recent" strategy so retrieveMemories returns the most recent memories (ORDER BY created_at DESC) regardless of prompt overlap. Semantic/hybrid still forward the query for vector search. Fixes the chat-pipeline + memory-pipeline integration memory-injection tests.
This commit is contained in:
@@ -149,7 +149,14 @@ export function toMemoryRetrievalConfig(
|
||||
// Plan 21 FAIL #1 fix: forward the last user message as `query` so that
|
||||
// semantic / hybrid strategies actually exercise the vector store in the
|
||||
// chat hot path (chatCore.ts), not only in the Playground.
|
||||
if (extra.query && extra.query.trim().length > 0) {
|
||||
//
|
||||
// BUT only for query-driven strategies. The "recent" strategy (mapped to the
|
||||
// internal "exact" path) is recency-based: it must return the most recent
|
||||
// memories regardless of the current prompt. Forwarding a query there makes
|
||||
// retrieveMemories apply relevance filtering (score > 0), which silently
|
||||
// drops recent memories whose text doesn't overlap the prompt — breaking the
|
||||
// "recent" contract. So skip query forwarding when strategy === "recent".
|
||||
if (extra.query && extra.query.trim().length > 0 && settings.strategy !== "recent") {
|
||||
config.query = extra.query.trim();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user