mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2695] [Issue]: Cross-chat memory recall caps candidates by recency (MAX_CHUNKS=500) before similarity, dropping older relevant memories #1339
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#1339
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kolacheee on GitHub (Jun 21, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2695
Originally assigned to: @SpicyMarinara on GitHub.
Summary
Cross-chat memory recall selects which memory chunks to score by recency, not relevance: it loads only the
MAX_CHUNKS = 500most-recent chunks (ORDER BY lastMessageAt DESC LIMIT 500) and runs cosine similarity only over those. In a long-lived chat (or one with many imported cross-chat memories) that exceeds 500 chunks, a highly relevant but older memory is excluded from scoring entirely and can never be recalled — silently defeating the whole point of semantic recall.Expected behavior
Semantic memory recall should surface the most relevant memories regardless of age — an old-but-highly-similar memory should be recallable even when newer (less relevant) memories exist.
Actual behavior
recallMemoriesloads candidate chunks with.orderBy(desc(memoryChunks.lastMessageAt)).limit(MAX_CHUNKS)(MAX_CHUNKS = 500), then computes cosine scores and top-K selection only over those 500 rows. The candidate cutoff is applied at the DB layer by recency before similarity is ever computed, so any relevant chunk older than the 500 most-recent is never considered.How it breaks the pipeline
Code trace (staging @
b826f8f4):packages/server/src/services/memory-recall.ts:220,:232-233—.orderBy(desc(memoryChunks.lastMessageAt)).limit(MAX_CHUNKS)(MAX_CHUNKS = 500).:240-261— cosine scoring + top-K run only over the loaded rows.Steps to reproduce
lastMessageAtthan the 500 most-recent chunks.Suggested fix
Do similarity scoring at the storage layer (an ANN / vector index over the full set), or at least raise/remove the recency-ordered cap, or pre-filter candidates by something other than pure recency so old high-similarity chunks remain eligible for scoring.
Environment
b826f8f4)Additional context
Found via a systematic multi-agent audit of conditional prompt insertion. Affects long-lived chats and heavy cross-chat-memory users; matches reports of "it forgets old things even though it should remember them." Part of a set of conditional-injection issues filed together.
Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:
@SpicyMarinara commented on GitHub (Jun 21, 2026):
Fixed in branch
codex/spicy-issue-sweep-2026-06-21.What changed:
MAX_CHUNKS = 500pre-cap from memory recall.Final repo checks will run after the full issue sweep.