[PR #558] [MERGED] Fix Memory Recall embedding fallback #4672

Closed
opened 2026-10-22 04:09:40 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/558
Author: @TheLonelyDevil9
Created: 5/8/2026
Status: ✅ Merged
Merged: 5/10/2026
Merged by: @SpicyMarinara

Base: main ← Head: fix/memory-recall-embedding-fallback


📝 Commits (2)

  • 90ebd7f Fix memory recall embedding fallback
  • adf46f4 Merge remote-tracking branch 'origin/main' into codex-resolve-pr-558

📊 Changes

5 files changed (+30 additions, -7 deletions)

View changed files

📝 packages/server/package.json (+1 -1)
📝 packages/server/src/services/memory-recall-embedding.ts (+12 -3)
📝 packages/server/src/services/memory-recall.ts (+14 -1)
📝 packages/server/test/memory-recall.test.ts (+2 -2)
➕ packages/server/test/setup-env.ts (+1 -0)

📄 Description

What?

Adds a configured embedding-connection fallback for Memory Recall when the local ONNX/HuggingFace embedder is unavailable.

  • Uses local embeddings first, preserving zero-cost local behavior where supported.
  • Falls back to the chat/configured embedding connection for memory chunk vectorization and recall query vectors.
  • Applies the fallback to background generation chunking and manual memory refresh.
  • Updates Memory Recall settings copy so it no longer promises local-only/no-cost embeddings.
  • Adds regression coverage for chunk and query fallback paths when local embeddings are unavailable.

Fixes #435.

Why?

On Android/Termux, onnxruntime-node native bindings may be unavailable, so localEmbed() returns null and Memory Recall chunks remain stuck as Waiting for vector. Users who already configure remote embedding models should be able to use that embedding source instead of losing Memory Recall entirely on unsupported local platforms.

How?

Memory Recall now resolves a MemoryRecallEmbeddingContext from the active chat connection, honoring chat-level embedding connection overrides, connection-level embedding connection overrides, embedding base URL overrides, provider default base URLs, and the selected embedding model.

The service wraps embedding calls in a local-first helper:

  • try localEmbed() first;
  • if local embeddings are unavailable, call the configured provider's embed();
  • if no fallback exists or the provider fails, keep the existing graceful behavior and store/return no embedding.

Recall now logs a warning if stored chunk vector dimensions differ from the query vector dimensions, which can happen after changing embedding models. Manual refresh remains the path to rebuild chunks under the current embedding model.

Testing?

  • pnpm --filter @marinara-engine/server exec tsx --import ./test/setup-env.ts --test test/memory-recall.test.ts
  • pnpm check
  • pnpm --filter @marinara-engine/server test (runs the new Memory Recall tests, but the full suite still has three unrelated baseline failures in claude-subscription-provider.test.ts and lorebook-keeper-utils.test.ts)

Screenshots (optional)

Not included. The user-facing UI change is copy-only in the Memory Recall settings help text; no layout or visual behavior changed.

Anything Else?

The fallback can use paid/remote embedding APIs depending on the configured connection, so the settings copy now says Memory Recall uses local embeddings when available and otherwise falls back to the configured embedding connection.

Summary by CodeRabbit

  • Bug Fixes

    • Memory recall now emits warnings when local embeddings are unavailable without a configured source.
    • Memory recall detects and gracefully handles mismatched embedding vector dimensions, logging a one-time warning.
  • Tests

    • Updated test coverage for embedding source resolution.

Review Change Stack


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/558 **Author:** [@TheLonelyDevil9](https://github.com/TheLonelyDevil9) **Created:** 5/8/2026 **Status:** ✅ Merged **Merged:** 5/10/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `main` ← **Head:** `fix/memory-recall-embedding-fallback` --- ### 📝 Commits (2) - [`90ebd7f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/90ebd7f8e119525b6cd931beff86dd7e30eb48db) Fix memory recall embedding fallback - [`adf46f4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/adf46f4c1328865105dcdf2e877008c1c3d67fa9) Merge remote-tracking branch 'origin/main' into codex-resolve-pr-558 ### 📊 Changes **5 files changed** (+30 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/package.json` (+1 -1) 📝 `packages/server/src/services/memory-recall-embedding.ts` (+12 -3) 📝 `packages/server/src/services/memory-recall.ts` (+14 -1) 📝 `packages/server/test/memory-recall.test.ts` (+2 -2) ➕ `packages/server/test/setup-env.ts` (+1 -0) </details> ### 📄 Description ## What? Adds a configured embedding-connection fallback for Memory Recall when the local ONNX/HuggingFace embedder is unavailable. - Uses local embeddings first, preserving zero-cost local behavior where supported. - Falls back to the chat/configured embedding connection for memory chunk vectorization and recall query vectors. - Applies the fallback to background generation chunking and manual memory refresh. - Updates Memory Recall settings copy so it no longer promises local-only/no-cost embeddings. - Adds regression coverage for chunk and query fallback paths when local embeddings are unavailable. Fixes #435. ## Why? On Android/Termux, `onnxruntime-node` native bindings may be unavailable, so `localEmbed()` returns `null` and Memory Recall chunks remain stuck as `Waiting for vector`. Users who already configure remote embedding models should be able to use that embedding source instead of losing Memory Recall entirely on unsupported local platforms. ## How? Memory Recall now resolves a `MemoryRecallEmbeddingContext` from the active chat connection, honoring chat-level embedding connection overrides, connection-level embedding connection overrides, embedding base URL overrides, provider default base URLs, and the selected embedding model. The service wraps embedding calls in a local-first helper: - try `localEmbed()` first; - if local embeddings are unavailable, call the configured provider's `embed()`; - if no fallback exists or the provider fails, keep the existing graceful behavior and store/return no embedding. Recall now logs a warning if stored chunk vector dimensions differ from the query vector dimensions, which can happen after changing embedding models. Manual refresh remains the path to rebuild chunks under the current embedding model. ## Testing? - [ ] `pnpm --filter @marinara-engine/server exec tsx --import ./test/setup-env.ts --test test/memory-recall.test.ts` - [ ] `pnpm check` - [ ] `pnpm --filter @marinara-engine/server test` *(runs the new Memory Recall tests, but the full suite still has three unrelated baseline failures in `claude-subscription-provider.test.ts` and `lorebook-keeper-utils.test.ts`)* ## Screenshots (optional) Not included. The user-facing UI change is copy-only in the Memory Recall settings help text; no layout or visual behavior changed. ## Anything Else? The fallback can use paid/remote embedding APIs depending on the configured connection, so the settings copy now says Memory Recall uses local embeddings when available and otherwise falls back to the configured embedding connection. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Memory recall now emits warnings when local embeddings are unavailable without a configured source. * Memory recall detects and gracefully handles mismatched embedding vector dimensions, logging a one-time warning. * **Tests** * Updated test coverage for embedding source resolution. [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/Pasta-Devs/Marinara-Engine/pull/558) <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:09:40 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#4672
No description provided.