[GH-ISSUE #5605] [Issue]: Long-Term Memory falls back to unavailable local embeddings on Termux #3105

Closed
opened 2026-10-21 05:59:39 +07:00 by bsakaguchi · 1 comment
Owner

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-node embedding fallback.

Steps to reproduce

  1. Run Marinara Engine 2.4.4+1a299369ac70 on Android/Termux arm64.
  2. Configure a global default connection with a remote embedding source.
  3. Install Long-Term Memory 1.2.14, save memory content, and reindex.

Environment

  • Marinara Engine version: 2.4.4+1a299369ac70
  • Install type: termux
  • OS + version: Android/Termux arm64 (reported)
  • Browser or app shell: not reported

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

  • I DID NOT read this template and provide the requested details.
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-node` embedding fallback. ## Steps to reproduce 1. Run Marinara Engine 2.4.4+1a299369ac70 on Android/Termux arm64. 2. Configure a global default connection with a remote embedding source. 3. Install Long-Term Memory 1.2.14, save memory content, and reindex. ## Environment - Marinara Engine version: 2.4.4+1a299369ac70 - Install type: termux - OS + version: Android/Termux arm64 (reported) - Browser or app shell: not reported ## 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 - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:59:39 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@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+1a299369ac70 is released main, which git merge-base --is-ancestor confirms 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 embeddings host the engine handed it at activation produces vectors. That host is built once, from the LTM agent row's own connectionId, not from the global default:

  • capability-module-runtime.service.ts:60-66 — config = await agents?.getByType(packageId) → createConfiguredCapabilityEmbeddingHost(app.db, config?.connectionId), then Object.freeze.
  • memory-recall-embedding.ts:174-180 — the global default connection is consulted only when connectionId is falsy: if (!activeConnection && !options.connectionId) { ...getDefault()... }. Any non-empty agent connectionId that fails to resolve returns null silently and the default is never read.
  • memory-recall-embedding.ts:237 — even a resolved connection returns null (silently) unless it carries its own embeddingModel + 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, no onnxruntime-node binding for linux/arm64) — so embed() returns null forever and the package reports semantic unavailable.

So the concrete triggers, most likely first:

  1. The LTM agent has any connection assigned in the Agents panel — users assign one because LTM needs an LLM — and that connection has no embedding fields. Since v2.4.4's #5539 (agents default = built-in Local Model + bulk assignment) this is the common state, which likely explains the report's timing.
  2. The assigned id is the __local_sidecar__ sentinel: it's not a DB row, so getWithKey returns null and, because the id is truthy, the default fallback is skipped. Notably the sidecar special-case exists in capability-language-model.service.ts:65-66 and raw-route.ts:414 but not in this resolver — a real asymmetry.
  3. The assigned connection was deleted or is import-quarantined (getWithKey also nulls on profileImportReviewRequired).
  4. Staleness: the host is frozen at activation, so configuring embeddings after boot does nothing until a restart/reactivation — the reporter may be reading a boot-time snapshot.

Suggested fix (keeps Termux working AND memory light, in the spirit of #5597):

  • Cascade instead of branch-once in createConfiguredCapabilityEmbeddingHost (capability-embedding.service.ts:30): try the agent's connectionId; on null, retry with connectionId: undefined so the global default's embedding config (including its embeddingConnectionId indirection) is consulted; only then fall back to local MiniLM. This alone fixes triggers 1 and 3 without touching vector-space identity for existing chats.
  • Teach the resolver the sidecar sentinel: treat options.connectionId === LOCAL_SIDECAR_CONNECTION_ID like the existing embeddingConnId sidecar branch at memory-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.
  • Resolve lazily instead of freezing at activation: make embeddings.embed resolve 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 the connections table, which is not a lazy table, and never touches the lazily-loaded memory_chunks rows. Keep spaceId stable per resolved source and re-check it per batch so a source change is detected rather than silently mixing spaces.
  • Don't attempt the doomed local probe when hasNativeOnnxRuntimeBinding() is already false, and add a logger.debug at the two silent return 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.
  • Optional polish: extend CapabilityEmbeddingHost with optional kind: "remote" | "sidecar" | "local" / available so 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 vectorText column, and nothing in the resolution path makes memory_chunks resident.

Test-plan pointer: capability-package-lifecycle.regression.ts:1280-1307 currently covers only the happy path (explicit connection that already has embeddingModel). 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.

<!-- gh-comment-id:5456885938 --> @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+1a299369ac70` is released main, which `git merge-base --is-ancestor` confirms 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 `embeddings` host the engine handed it at activation produces vectors. That host is built once, from the **LTM agent row's own `connectionId`**, not from the global default: - `capability-module-runtime.service.ts:60-66` — `config = await agents?.getByType(packageId)` → `createConfiguredCapabilityEmbeddingHost(app.db, config?.connectionId)`, then `Object.freeze`. - `memory-recall-embedding.ts:174-180` — the global default connection is consulted **only when `connectionId` is falsy**: `if (!activeConnection && !options.connectionId) { ...getDefault()... }`. Any non-empty agent connectionId that fails to resolve returns `null` silently and the default is never read. - `memory-recall-embedding.ts:237` — even a resolved connection returns `null` (silently) unless it carries its own `embeddingModel` + `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`, no `onnxruntime-node` binding for linux/arm64) — so `embed()` returns null forever and the package reports semantic unavailable. So the concrete triggers, most likely first: 1. The LTM agent has **any** connection assigned in the Agents panel — users assign one because LTM needs an LLM — and that connection has no embedding fields. Since v2.4.4's #5539 (agents default = built-in Local Model + bulk assignment) this is the common state, which likely explains the report's timing. 2. The assigned id is the `__local_sidecar__` sentinel: it's not a DB row, so `getWithKey` returns null and, because the id is truthy, the default fallback is skipped. Notably the sidecar special-case exists in `capability-language-model.service.ts:65-66` and `raw-route.ts:414` but not in this resolver — a real asymmetry. 3. The assigned connection was deleted or is import-quarantined (`getWithKey` also nulls on `profileImportReviewRequired`). 4. Staleness: the host is frozen at activation, so configuring embeddings after boot does nothing until a restart/reactivation — the reporter may be reading a boot-time snapshot. **Suggested fix** (keeps Termux working AND memory light, in the spirit of #5597): - **Cascade instead of branch-once** in `createConfiguredCapabilityEmbeddingHost` (`capability-embedding.service.ts:30`): try the agent's `connectionId`; on null, retry with `connectionId: undefined` so the global default's embedding config (including its `embeddingConnectionId` indirection) is consulted; only then fall back to local MiniLM. This alone fixes triggers 1 and 3 without touching vector-space identity for existing chats. - **Teach the resolver the sidecar sentinel**: treat `options.connectionId === LOCAL_SIDECAR_CONNECTION_ID` like the existing `embeddingConnId` sidecar branch at `memory-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. - **Resolve lazily instead of freezing at activation**: make `embeddings.embed` resolve 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 the `connections` table, which is not a lazy table, and never touches the lazily-loaded `memory_chunks` rows. Keep `spaceId` stable per resolved source and re-check it per batch so a source change is detected rather than silently mixing spaces. - **Don't attempt the doomed local probe** when `hasNativeOnnxRuntimeBinding()` is already false, and add a `logger.debug` at the two silent `return null`s (`: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. - Optional polish: extend `CapabilityEmbeddingHost` with optional `kind: "remote" | "sidecar" | "local"` / `available` so 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 `vectorText` column, and nothing in the resolution path makes `memory_chunks` resident. Test-plan pointer: `capability-package-lifecycle.regression.ts:1280-1307` currently covers only the happy path (explicit connection that already has `embeddingModel`). 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.
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#3105
No description provided.