mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2796] [Issue]: Memory recall re-attempts embedding every turn with no short-circuit when no embedder is configured (log spam + repeated wasted re-chunking) #1419
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#1419
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 22, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2796
Summary
A user reported that "starting a conversation wedges the engine" — phone/CPU heat, inability to create new conversations or open characters, and a crash on refresh — and pointed at memory-recall embedding as the cause when no embedder is configured.
Reading the actual 2.0.0 code, part of the report is real and part is not:
chatIdso it cannot block other chats/characters. Those symptoms point to a different fault (e.g. a failing generation the user repeatedly retries, or a separate backend error) and should be triaged separately. The repeating warnings are a correlated symptom, not the cause.Severity: medium — log spam + repeated wasted re-work on misconfigured/unsupported hosts (Termux/Android, Node-arch mismatch), no crash and no wedge from this path.
Symptom & UX impact
[memory-recall] Local embeddings are unavailable and no embedding connection is configuredon every conversation-mode send.[memory-recall] Skipping N memory chunk(s) for chat <id> because embedding generation returned 0/N usable vectorson every subsequent send — with the same chunk count each time, because the failed chunk is never persisted.chatIdgeneration lock cannot block them; the failed-embed path holds no global lock and exhausts no memory.loadFailedafter the first availability check and never loads/downloads a model, so there is no runaway CPU. These must be triaged as a separate issue with the real failing-request stack captured.Steps to reproduce
[memory-recall] Local embeddings are unavailable and no embedding connection is configured(memory-recall.ts:90).[memory-recall] Skipping 1 memory chunk(s) for chat <id> because embedding generation returned 0/1 usable vectors(memory-recall.ts:174) — same count forever.loadFailedcached after the first availability check). Creating a NEW conversation and opening OTHER characters is NOT blocked by this path (lock is per-chatId). If those operations do fail in the user's environment, that is a separate fault — capture the actual error/stack on the failing create-chat / open-character / refresh request, because it is not produced by memory-recall.Root cause (file:line trace)
1. Recall defaults ON in conversation/scene mode → runs every generation.
packages/server/src/routes/generate.routes.ts:4200generate.routes.ts:4203-4214—if (enableMemoryRecall) { await injectMemoryRecallContext({...}) }. This is why the user noticed it "especially in Convo Mode."2. No cache / short-circuit for the "no embedder available" verdict.
embedMemoryRecallTextsre-runs the full resolution on every call and never memoizes failure:packages/server/src/services/memory-recall.ts:77-92packages/server/src/services/local-embedder.ts:64-67andlocal-embedder.ts:112-113returnsnullimmediately onceloadFailedis set. It never reachescreatePipeline/HuggingFace download (local-embedder.ts:70-100). The binding-missing notice itself is single-shot (local-embedder.ts:44-51, guarded bynativeBindingChecked), but the:90warn inembedMemoryRecallTextsis not guarded.embedderUnavailable/recallDisabled/ similar) returns zero hits — there is no flag anywhere.3. Repeated re-chunking of the same never-persisted chunk (the per-turn re-work loop).
generate.routes.ts:10731-10736fire-and-forgetschunkAndEmbedMessages(...).catch(...)after each generation (one per turn; awaited internally;.catch-guarded — does not accumulate).memory-recall.ts:107-114memory-recall.ts:133—if (unchunked.length < CHUNK_SIZE) return;(CHUNK_SIZE = 5).memory-recall.ts:168—const embeddings = await embedMemoryRecallTexts(texts, options);→ returns[].memory-recall.ts:169-181— length mismatch →logger.warn("[memory-recall] Skipping %d memory chunk(s) … returned %d/%d usable vectors", …); return;(WARN :174) without inserting. Because nothing is persisted, the resume cursor never advances, so the identical DB-scan + chunk-build + failed-embed + warn repeats on every subsequent turn.Two additional embed call-sites also cheap-fail through the same path (no extra harm, but should be gated by the same verdict):
generate.routes.ts:2042-2046— chat-context embedding (gated behindhasVectorizedEntriesat:2036).generate.routes.ts:5278— knowledge routerembeddingSource.Why this is NOT a wedge (verify before assuming otherwise):
generate.routes.ts:1234-1246—activeGenerationsMap is keyed byinput.chatId; release deletes only that chat's entry. It cannot block creating new chats or opening other characters.Suggested fix
Goal: stop the per-turn re-attempt + log spam, and decouple conversation/character operations from embedding entirely when no vectorizer exists.
1. Cache the "no vectorizer available" verdict.
In
packages/server/src/services/memory-recall-embedding.ts, memoizeisMemoryRecallVectorizerAvailable(and/orresolveMemoryRecallEmbeddingSource) with a short TTL keyed by (connectionId, chat embeddingConnectionId):Call
resetMemoryRecallVectorizerCache()from connection create/update/delete and from/memories/refreshso reconfiguring an embedder takes effect immediately.2. Gate recall injection and post-gen chunking on availability so neither runs (nor logs) when no embedder exists:
generate.routes.ts:4203—if (enableMemoryRecall && (await isMemoryRecallVectorizerAvailable(app.db, {...cached}))) { … }generate.routes.ts:10731— only callchunkAndEmbedMessageswhen the cached verdict isavailable.generate.routes.ts:1389(or wherevermemoryRecallEmbeddingSourceis resolved):generate.routes.ts:2042andgenerate.routes.ts:5278.This stops the repeated identical re-work because the functions are not invoked at all when no embedder is present.
3. Log the "unavailable" warning at most once per process (or per TTL) so a misconfig produces one actionable line instead of per-turn spam (
memory-recall.ts:90):Reset
warnedUnavailablewhen a vectorizer becomes available again (same hook as the verdict cache reset).4. Demote the per-chunk "Skipping N memory chunk(s)" warn at
memory-recall.ts:173tologger.debug. With fix (2) it should rarely fire, and "no embedder" is a normal condition, not a fault.5. Keep
chunkAndEmbedMessagesfire-and-forget (already is atgenerate.routes.ts:10731-10736) — fixes (1)+(2) eliminate the re-work by not calling it.Separately: the wedge symptoms (cannot create conversations, open-character errors, crash on refresh, device heat) are not reproduced by this path. File a distinct issue and capture the real failing-request stack; there is a separately-reported new-conversation-button problem that may be the actual culprit — do not assume memory-recall is the cause. The fixes above ensure that even if recall is misconfigured, it cannot contribute to such a wedge.
Affected files
packages/server/src/services/memory-recall.tspackages/server/src/services/memory-recall-embedding.tspackages/server/src/services/local-embedder.tspackages/server/src/services/generation/memory-recall-context.tspackages/server/src/routes/generate.routes.tsValidation
pnpm checkpasses (TypeScript + ESLint).memory-recall-embedding.tswith TTL +resetMemoryRecallVectorizerCache()export.generate.routes.ts:4203.chunkAndEmbedMessagesgated on availability atgenerate.routes.ts:10731.generate.routes.ts:2042andgenerate.routes.ts:5278gated by the same verdict.embedMemoryRecallTexts"unavailable" warn fires at most once per process/TTL (memory-recall.ts:90).debug(memory-recall.ts:173)./memories/refresh.@kolacheee commented on GitHub (Jun 22, 2026):
Cross-reference: this issue is the memory-recall log-spam / repeated re-chunking part of the "starting a conversation bugs out" report. The more severe wedge symptoms from that same report (cannot create new conversations / open characters, crash on refresh, device heat) are not caused by this path — they are tracked in #2791 (per-chat
abortControllers+ serveractiveGenerationslock leaks + silent create/delete failures). The repeating embedding warnings here are a correlated symptom, not the wedge cause.@SpicyMarinara commented on GitHub (Jun 22, 2026):
Addressed in PR #2790 / commit acab1fba: memory recall now short-circuits when no embedder is available, caches vectorizer availability briefly, throttles the no-embedder warning, skips semantic routing without an embedder, and resets the cache when embedding connections/settings change.