mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2286] [Issue]: Memory recall scores every stored memory in long chats; the web build capped the working set at 500 chunks #1124
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#1124
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 @Romuromylus on GitHub (Jun 5, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2286
Originally assigned to: @Xelvanis on GitHub.
Summary
The refactor's
buildMemoryRecallBlockloads and cosine-scores the entire memories array for the chat on every generation, with no cap. The web build bounded the recall working set to at most 500 chunks (and 50 chats) before scoring.Expected behavior
Recall should bound the number of stored memories it scores per generation (main caps at 500 most-recent chunks), so recall cost does not grow unboundedly with chat length.
Actual behavior
The refactor reads the whole memories array (no LIMIT) and maps cosine + lexical scoring over every memory before slicing the top 8, so a 10k-message chat scores ~2,000 memories every turn in the prompt-assembly hot path. Each cosine op is cheap and it is single-chat scoped, so the slowdown only shows on very long chats.
Steps to reproduce
Impact area
Regression notes
Worked bounded on main. Main caps to 50 chat ids and
.limit(MAX_CHUNKS)with MAX_CHUNKS 500 ("capped to prevent memory blowup") before scoring (packages/server/src/services/memory-recall.ts:217-233,240-261). The refactor loads the entire array (src/engine/generation/prompt-assembly.ts:1837,storage-api.ts:435-437, Rustchat_array_fieldno LIMIT atcommands/storage/chats.rs:747-750) and scores all before.slice(0,8)(prompt-assembly.ts:1855-1872); the read-behind filter at:1842does not bound the count. Both chunk at 5 (memory-recall.ts:16,chats.rs:10) with no stored-count cap (chats.rs:781-856). Runs once per generation fromprompt-assembly.ts:2892. Minor because single-chat scoped and cheap per op.Environment
5ddb9840(compared against main @b4ab97f)Template check
Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked: