mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #5605] [Issue]: Long-Term Memory falls back to unavailable local embeddings on Termux #3105
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#3105
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 @Promansis on GitHub (Aug 28, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5605
Originally assigned to: @Promansis on GitHub.
Summary
Long-Term Memory can report semantic embeddings unavailable on Android/Termux even when a global default connection provides remote embeddings.
Expected behavior
Long-Term Memory resolves the configured global default embedding source and builds vector indexes on Termux without relying on the unavailable native local MiniLM runtime.
Actual behavior
The package reports that semantic embeddings are unavailable while lexical indexing remains available. Android/Termux cannot use the local
onnxruntime-nodeembedding fallback.Steps to reproduce
Environment
Logs, screenshots, or video
No redacted runtime logs were supplied.
Additional context
Engine local MiniLM embeddings are intentionally unavailable on Termux/Android. Investigation must prove that the configured remote source is selected and distinguish provider response failures from local fallback.
Template check
@kolacheee commented on GitHub (Aug 28, 2026):
Traced this end to end (engine + the LTM 1.2.14 package source) while checking whether the recent storage work (#5596/#5597) was responsible. It isn't — the reported build
2.4.4+1a299369ac70is released main, whichgit merge-base --is-ancestorconfirms contains neither PR, and independently the five files that decide embedding availability/source resolution are byte-identical from pre-#5596 through current staging. The bug is pre-existing resolution logic, and here is the exact mechanism, since it should save you the archaeology:Why "semantic embeddings unavailable" happens with a working remote default
The package never resolves anything itself — it only checks whether the single
embeddingshost the engine handed it at activation produces vectors. That host is built once, from the LTM agent row's ownconnectionId, not from the global default:capability-module-runtime.service.ts:60-66—config = await agents?.getByType(packageId)→createConfiguredCapabilityEmbeddingHost(app.db, config?.connectionId), thenObject.freeze.memory-recall-embedding.ts:174-180— the global default connection is consulted only whenconnectionIdis falsy:if (!activeConnection && !options.connectionId) { ...getDefault()... }. Any non-empty agent connectionId that fails to resolve returnsnullsilently and the default is never read.memory-recall-embedding.ts:237— even a resolved connection returnsnull(silently) unless it carries its ownembeddingModel+embeddingBaseUrl.capability-embedding.service.ts:31— a null source falls back to the built-in local MiniLM host, which on Termux arm64 can never work (local-embedder.ts:31-54, noonnxruntime-nodebinding for linux/arm64) — soembed()returns null forever and the package reports semantic unavailable.So the concrete triggers, most likely first:
__local_sidecar__sentinel: it's not a DB row, sogetWithKeyreturns null and, because the id is truthy, the default fallback is skipped. Notably the sidecar special-case exists incapability-language-model.service.ts:65-66andraw-route.ts:414but not in this resolver — a real asymmetry.getWithKeyalso nulls onprofileImportReviewRequired).Suggested fix (keeps Termux working AND memory light, in the spirit of #5597):
createConfiguredCapabilityEmbeddingHost(capability-embedding.service.ts:30): try the agent'sconnectionId; on null, retry withconnectionId: undefinedso the global default's embedding config (including itsembeddingConnectionIdindirection) is consulted; only then fall back to local MiniLM. This alone fixes triggers 1 and 3 without touching vector-space identity for existing chats.options.connectionId === LOCAL_SIDECAR_CONNECTION_IDlike the existingembeddingConnIdsidecar branch atmemory-recall-embedding.ts:186(mirroring the two files above). On Termux the sidecar's llama.cpp is often the only viable local embedder, so this doubles as a second working tier.embeddings.embedresolve its source per call behind the existing 60s-TTL pattern (cachedVectorizerVerdict/resetMemoryRecallVectorizerCache()in the same file are the precedent, already invalidated on connection writes). Fixes trigger 4 with no restart and no added memory — resolution is O(1) reads on theconnectionstable, which is not a lazy table, and never touches the lazily-loadedmemory_chunksrows. KeepspaceIdstable per resolved source and re-check it per batch so a source change is detected rather than silently mixing spaces.hasNativeOnnxRuntimeBinding()is already false, and add alogger.debugat the two silentreturn nulls (:180,:237) naming the connection id and the missing field — today the only Termux log line is the local-embedder one, which makes every failure look like a platform problem even when resolution bailed a step earlier.CapabilityEmbeddingHostwith optionalkind: "remote" | "sidecar" | "local"/availableso the package can say why ("no embedding source configured" vs "local runtime unsupported on this platform") instead of the flat unavailable copy. Optional fields keep older packages working.Memory-wise this stays aligned with #5596/#5597: the existing 128-text/200k-char batch caps stay, vectors land in the packed
vectorTextcolumn, and nothing in the resolution path makesmemory_chunksresident.Test-plan pointer:
capability-package-lifecycle.regression.ts:1280-1307currently covers only the happy path (explicit connection that already hasembeddingModel). The three cases above — agent connection without embedding config + default with it,__local_sidecar__, deleted connection — would pin the fix.Not opening a PR since you've got this one — happy to sanity-check a branch if useful.