[PR #7627] [MERGED] feat: default embedding model in Connection defaults #7844

Closed
opened 2026-10-24 04:08:05 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7627
Author: @ylli-selmani
Created: 10/14/2026
Status: ✅ Merged
Merged: 10/14/2026
Merged by: @ylli-selmani

Base: staging ← Head: feat/default-embedding-model


📝 Commits (8)

  • 0da77aa feat(embeddings): app-wide default embedding source in the resolver
  • 1111c66 Merge branch 'staging' into feat/default-embedding-model
  • 106ae6c feat(connections): Embeddings row in Connection defaults
  • 3e9cb13 feat(lorebooks): Vectorize picker starts on the default embedding model
  • 838842d docs: default embedding model in Connection defaults
  • a4592ea fix(lorebooks): keep an explicit Vectorize choice over the default
  • 58f36db fix(embeddings): honor chat overrides first and reject unusable defaults
  • ba84242 fix: remember "No semantic search" and name Embedding Connection in copy

📊 Changes

12 files changed (+445 additions, -53 deletions)

View changed files

📝 docs/agents/memory.md (+3 -1)
📝 docs/lorebooks/semantic-search.md (+3 -1)
➕ packages/client/src/components/connections/EmbeddingDefaultControl.tsx (+102 -0)
📝 packages/client/src/components/lorebooks/LorebookEditor.tsx (+20 -3)
📝 packages/client/src/components/panels/ConnectionsPanel.tsx (+2 -0)
📝 packages/client/src/hooks/use-connections.ts (+29 -1)
📝 packages/client/src/localization/locales/en.json (+7 -0)
📝 packages/server/src/routes/app-settings.routes.ts (+32 -0)
📝 packages/server/src/services/memory-recall-embedding.ts (+95 -46)
📝 packages/server/src/services/storage/connection-reference-cleanup.ts (+8 -1)
📝 packages/shared/src/types/connection.ts (+9 -0)
➕ scripts/regressions/default-embedding-connection.regression.ts (+135 -0)

📄 Description

Requested by Ylli

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #7626

Why this change

  • Embeddings are set per connection only. A connection without an embedding model silently falls back to the built-in local MiniLM embedder, so switching a chat to a connection you forgot to configure, or one with a different model, makes queries land in a different vector space from the lorebook entries and memories you already vectorized. Those are then skipped without an error.
  • This adds one app-wide default embedding source (an Embeddings row in Connection defaults) that fills that gap. A chat's or connection's own embedding settings still win, so existing setups behave exactly as before.

What changed

Progress, one commit per slice:

  • Slice 1, server: default embedding source in the shared resolver
  • Slice 2, UI: Embeddings row in Connection defaults, with a "N connections use their own embedding settings" line
  • Slice 3, lorebooks: the Vectorize picker preselects the default
  • Slice 4, docs: docs/lorebooks/semantic-search.md, docs/agents/memory.md, and a [docs-i18n] follow-up issue

Slice 1:

  • New app setting default-embedding-connection (DEFAULT_EMBEDDING_CONNECTION_SETTINGS_KEY) holding a connection id or the local sidecar id. No schema change.
  • resolveMemoryRecallEmbeddingSource uses it only when the chat sets no embedding override and the connection sets neither an embedding model nor an Embedding Connection, or when there is no connection at all. Every existing caller (Memory Recall, Advanced Memory, chat summary retrieval, lorebook semantic matching, the Long-term memory capability host, Professor Mari's check, the raw embed route) picks it up without changes.
  • Random pools try each member's own embeddings first and use the default only when none has any, so the default cannot shadow a pool member.
  • GET/PUT /api/app-settings/default-embedding-connection checks the id, resets the vectorizer availability cache, and goes through withLongTermMemoryEmbeddingChange so Long-term memory re-indexes when the effective source changes.
  • Deleting the default connection clears the setting (connection-reference-cleanup.ts).
  • With no usable connection (or an empty random pool), a chat's own embedding override still comes before the default.
  • Saving a default refuses a connection with neither an embedding model nor an Embedding Connection.
  • The local sidecar source moved into createLocalSidecarEmbeddingSource() so the default and the per-connection path share it.

Slice 2:

  • EmbeddingDefaultControl sits between Audio and the Decision model, styled like the Decision picker. It lists connections with an embedding model, plus the local sidecar once its model is downloaded. None (built-in local model) keeps today's behavior.
  • With a default set, a line says how many connections use their own embedding settings instead. Connections that borrow the default connection itself aren't counted, because they end up on the same source.
  • Deleting a connection refreshes the row, since the server clears a default that pointed at it.

Slice 3:

  • When this browser has no remembered Vectorize choice, the lorebook picker starts on the default, so entries are vectorized in the space chat-time queries use. A remembered choice still wins, and once the user picks something (including No semantic search) the default no longer re-applies.

Slice 4:

  • docs/lorebooks/semantic-search.md and docs/agents/memory.md describe the default, precedence, and the picker.

Design note: Decision and the other purpose defaults use a flag on the connection row plus an app setting for local entries. Embeddings use a single app setting for both, because it needs no new column and one value can only ever name one source.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Local results: pnpm check exit 0 after every slice (the one lint warning, serverRun in an unrelated hook, is already on staging). pnpm localization:check clean. New regression default-embedding-connection passes. Related regressions pass: memory-recall-revectorize, capability-embedding-input-type, lorebook-vectorization, semantic-summary-settings, prompt, mari-permissions-mode, feature-settings, chat-window-default*, capability-package-lifecycle.

Local CodeRabbit: slice 1, 0 findings. Slices 1 and 2, 1 finding, on the help text being long and jargon-heavy: shortened it, but kept "Re-vectorize" because that is the button's name in the lorebook panel. Slices 3 and 4, 1 finding: picking No semantic search snapped the picker back to the default. Fixed in a4592ea52 and verified in the browser.

GitHub CodeRabbit, 2 findings, both fixed in 58f36dbc7 and answered in their threads: a chat's embedding override now comes before the default when there is no usable connection or the random pool is empty, and saving a default refuses a connection with no embedding source of its own. A second round had 2 minor findings, fixed in ba8424288 and answered in their threads: an explicit No semantic search is now remembered across visits (verified in the browser after a reload), and the help text and guide now name the Embedding Connection override before the default.

Checked in a browser against the worktree server (dark theme, 1400px wide): saving the default through the row (and the server returns 400 for an unknown id; the "no embedding model" refusal is covered by code review only); the count line; the lorebook picker preselecting the default; a remembered choice winning over it; and picking No semantic search staying put.

Not verified: light theme, mobile width, the local sidecar option (no sidecar model on the test machine), and a real embedding request through the default.

Manual verification notes

  • Manually verify that a connection with no embedding model uses the default for Memory Recall and lorebook semantic matching.
  • Manually verify that a connection with its own embedding model or Embedding Connection ignores the default.
  • Manually verify that deleting the default connection clears the Embeddings row.
  • Manually verify that changing the default with the Long-term memory package installed reports a refresh.
  • Manually verify the Embeddings row in light mode and at mobile width.
  • Manually verify that a lorebook vectorized with the default matches entries in a chat whose connection has no embedding model.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

Screenshots of the Embeddings row and the preselected lorebook picker exist locally and are not uploaded.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added an app-wide default embedding source setting in the Connections panel, with options for eligible connections or the built-in local model.
    • Memory Recall and semantic search now use the shared default when no more specific embedding source is configured. Connection-specific settings take precedence.
    • Lorebook vectorization selects the shared default automatically when available, unless a source has been manually chosen.
  • Documentation
    • Updated Memory Recall and semantic search guidance to explain embedding-source precedence and fallbacks.

🔄 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/7627 **Author:** [@ylli-selmani](https://github.com/ylli-selmani) **Created:** 10/14/2026 **Status:** ✅ Merged **Merged:** 10/14/2026 **Merged by:** [@ylli-selmani](https://github.com/ylli-selmani) **Base:** `staging` ← **Head:** `feat/default-embedding-model` --- ### 📝 Commits (8) - [`0da77aa`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0da77aaacecd144ff1922082421f4777bdf8271e) feat(embeddings): app-wide default embedding source in the resolver - [`1111c66`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1111c663e3e3510990c1ab2c4356029798072fdc) Merge branch 'staging' into feat/default-embedding-model - [`106ae6c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/106ae6c2228b5204164469e76b664e8922529efd) feat(connections): Embeddings row in Connection defaults - [`3e9cb13`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3e9cb1334262f0199e24c4d22eb69a918cd71a59) feat(lorebooks): Vectorize picker starts on the default embedding model - [`838842d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/838842d8e10fcb1f654a933f65000900744634ec) docs: default embedding model in Connection defaults - [`a4592ea`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a4592ea52da7de373a6aafddcf886ff41fa2673a) fix(lorebooks): keep an explicit Vectorize choice over the default - [`58f36db`](https://github.com/Pasta-Devs/Marinara-Engine/commit/58f36dbc76163deed5f49df8039ff0c1dd5b21bb) fix(embeddings): honor chat overrides first and reject unusable defaults - [`ba84242`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ba8424288e230fea86980f91e9639f035d35d074) fix: remember "No semantic search" and name Embedding Connection in copy ### 📊 Changes **12 files changed** (+445 additions, -53 deletions) <details> <summary>View changed files</summary> 📝 `docs/agents/memory.md` (+3 -1) 📝 `docs/lorebooks/semantic-search.md` (+3 -1) ➕ `packages/client/src/components/connections/EmbeddingDefaultControl.tsx` (+102 -0) 📝 `packages/client/src/components/lorebooks/LorebookEditor.tsx` (+20 -3) 📝 `packages/client/src/components/panels/ConnectionsPanel.tsx` (+2 -0) 📝 `packages/client/src/hooks/use-connections.ts` (+29 -1) 📝 `packages/client/src/localization/locales/en.json` (+7 -0) 📝 `packages/server/src/routes/app-settings.routes.ts` (+32 -0) 📝 `packages/server/src/services/memory-recall-embedding.ts` (+95 -46) 📝 `packages/server/src/services/storage/connection-reference-cleanup.ts` (+8 -1) 📝 `packages/shared/src/types/connection.ts` (+9 -0) ➕ `scripts/regressions/default-embedding-connection.regression.ts` (+135 -0) </details> ### 📄 Description <!-- claude-projects-attribution: {"github_login":"bobneumann77-hub"} --> _Requested by **Ylli**_ > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue Closes #7626 ## Why this change - Embeddings are set per connection only. A connection without an embedding model silently falls back to the built-in local MiniLM embedder, so switching a chat to a connection you forgot to configure, or one with a different model, makes queries land in a different vector space from the lorebook entries and memories you already vectorized. Those are then skipped without an error. - This adds one app-wide default embedding source (an **Embeddings** row in Connection defaults) that fills that gap. A chat's or connection's own embedding settings still win, so existing setups behave exactly as before. ## What changed Progress, one commit per slice: - [x] **Slice 1, server:** default embedding source in the shared resolver - [x] **Slice 2, UI:** Embeddings row in Connection defaults, with a "N connections use their own embedding settings" line - [x] **Slice 3, lorebooks:** the Vectorize picker preselects the default - [x] **Slice 4, docs:** `docs/lorebooks/semantic-search.md`, `docs/agents/memory.md`, and a `[docs-i18n]` follow-up issue Slice 1: - New app setting `default-embedding-connection` (`DEFAULT_EMBEDDING_CONNECTION_SETTINGS_KEY`) holding a connection id or the local sidecar id. No schema change. - `resolveMemoryRecallEmbeddingSource` uses it only when the chat sets no embedding override and the connection sets neither an embedding model nor an Embedding Connection, or when there is no connection at all. Every existing caller (Memory Recall, Advanced Memory, chat summary retrieval, lorebook semantic matching, the Long-term memory capability host, Professor Mari's check, the raw embed route) picks it up without changes. - Random pools try each member's own embeddings first and use the default only when none has any, so the default cannot shadow a pool member. - `GET/PUT /api/app-settings/default-embedding-connection` checks the id, resets the vectorizer availability cache, and goes through `withLongTermMemoryEmbeddingChange` so Long-term memory re-indexes when the effective source changes. - Deleting the default connection clears the setting (`connection-reference-cleanup.ts`). - With no usable connection (or an empty random pool), a chat's own embedding override still comes before the default. - Saving a default refuses a connection with neither an embedding model nor an Embedding Connection. - The local sidecar source moved into `createLocalSidecarEmbeddingSource()` so the default and the per-connection path share it. Slice 2: - `EmbeddingDefaultControl` sits between Audio and the Decision model, styled like the Decision picker. It lists connections with an embedding model, plus the local sidecar once its model is downloaded. **None (built-in local model)** keeps today's behavior. - With a default set, a line says how many connections use their own embedding settings instead. Connections that borrow the default connection itself aren't counted, because they end up on the same source. - Deleting a connection refreshes the row, since the server clears a default that pointed at it. Slice 3: - When this browser has no remembered Vectorize choice, the lorebook picker starts on the default, so entries are vectorized in the space chat-time queries use. A remembered choice still wins, and once the user picks something (including **No semantic search**) the default no longer re-applies. Slice 4: - `docs/lorebooks/semantic-search.md` and `docs/agents/memory.md` describe the default, precedence, and the picker. Design note: Decision and the other purpose defaults use a flag on the connection row plus an app setting for local entries. Embeddings use a single app setting for both, because it needs no new column and one value can only ever name one source. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` Local results: `pnpm check` exit 0 after every slice (the one lint warning, `serverRun` in an unrelated hook, is already on `staging`). `pnpm localization:check` clean. New regression `default-embedding-connection` passes. Related regressions pass: `memory-recall-revectorize`, `capability-embedding-input-type`, `lorebook-vectorization`, `semantic-summary-settings`, `prompt`, `mari-permissions-mode`, `feature-settings`, `chat-window-default*`, `capability-package-lifecycle`. Local CodeRabbit: slice 1, 0 findings. Slices 1 and 2, 1 finding, on the help text being long and jargon-heavy: shortened it, but kept "Re-vectorize" because that is the button's name in the lorebook panel. Slices 3 and 4, 1 finding: picking **No semantic search** snapped the picker back to the default. Fixed in `a4592ea52` and verified in the browser. GitHub CodeRabbit, 2 findings, both fixed in `58f36dbc7` and answered in their threads: a chat's embedding override now comes before the default when there is no usable connection or the random pool is empty, and saving a default refuses a connection with no embedding source of its own. A second round had 2 minor findings, fixed in `ba8424288` and answered in their threads: an explicit **No semantic search** is now remembered across visits (verified in the browser after a reload), and the help text and guide now name the Embedding Connection override before the default. Checked in a browser against the worktree server (dark theme, 1400px wide): saving the default through the row (and the server returns 400 for an unknown id; the "no embedding model" refusal is covered by code review only); the count line; the lorebook picker preselecting the default; a remembered choice winning over it; and picking **No semantic search** staying put. Not verified: light theme, mobile width, the local sidecar option (no sidecar model on the test machine), and a real embedding request through the default. ### Manual verification notes - Manually verify that a connection with no embedding model uses the default for Memory Recall and lorebook semantic matching. - Manually verify that a connection with its own embedding model or Embedding Connection ignores the default. - Manually verify that deleting the default connection clears the Embeddings row. - Manually verify that changing the default with the Long-term memory package installed reports a refresh. - Manually verify the Embeddings row in light mode and at mobile width. - Manually verify that a lorebook vectorized with the default matches entries in a chat whose connection has no embedding model. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) Screenshots of the Embeddings row and the preselected lorebook picker exist locally and are not uploaded. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added an app-wide default embedding source setting in the Connections panel, with options for eligible connections or the built-in local model. - Memory Recall and semantic search now use the shared default when no more specific embedding source is configured. Connection-specific settings take precedence. - Lorebook vectorization selects the shared default automatically when available, unless a source has been manually chosen. - **Documentation** - Updated Memory Recall and semantic search guidance to explain embedding-source precedence and fallbacks. <!-- 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-24 04:08:05 +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#7844
No description provided.