mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2284] [Issue]: Memory-recall embedding blocks every assistant turn and re-embeds the whole chat one request at a time (no defer, no watermark, no batch) #1121
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#1121
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/2284
Originally assigned to: @SpicyMarinara on GitHub.
Summary
In the refactor, memory-recall chunking/embedding runs synchronously right before the generation "done" event, re-embeds every visible chunk on each turn (no incremental watermark), and issues one embedding HTTP request per chunk (no batch). Main defers it fire-and-forget, embeds only the newly completed chunk, and batches in a single request.
Expected behavior
Memory embedding should not block the user-visible turn, should embed only new chunks incrementally, and should batch chunk texts into one embedding request, matching main's deferred/incremental/batched design.
Actual behavior
refreshMemoryRecallSafelyis awaited beforeyield { type: "done" }, andrefresh_chat_memoriesloops over all visible chunks awaiting one embedding round-trip each with no skip of already-embedded chunks, then overwrites the whole memories array. A K-chunk chat performs K blocking embedding round-trips every turn (O(n), compounding with chat length) when a remote embedding connection is configured.Steps to reproduce
Impact area
Regression notes
Worked better on main. Main runs fire-and-forget after generation with a
.catchnotawait(packages/server/src/routes/generate.routes.ts:11093-11098), is incremental via anaftercursor (memory-recall.ts:86-121), and batches all chunk texts into one POST (memory-recall.ts:155-156,base-provider.ts:615). The refactor awaitsrefreshMemoryRecallSafelybefore done (src/engine/generation/start-generation.ts:3095,3227, gate:1741), andrefresh_chat_memoriesloops all chunks (src-tauri/src/commands/storage/chats.rs:781-857, esp.:784-787,:849) awaitingembed_textper chunk (prompts.rs:512-523), with no batch path anywhere (llm.rs:127-132also one-at-a-time) and notokio::spawn. Lexical-only configs avoid the network cost but the synchronous full re-embed before done remains.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:
@SpicyMarinara commented on GitHub (Jun 6, 2026):
Pretty straightforward to fix.
@SpicyMarinara commented on GitHub (Jun 6, 2026):
Fixed on
refactorin5775f354.What changed:
doneevent.refresh_chat_memoriesnow preserves existing complete five-message chunks when the span/content and embedding source/model still match.embeddedandreusedcounts in addition to the existing chunk payload.Validation:
cargo test --manifest-path src-tauri/Cargo.toml -p marinara-engine refresh_chat_memories_reuses_existing_complete_chunkspnpm typecheckcargo check --manifest-path src-tauri/Cargo.tomlpnpm check:architectureClosing as completed.