[PR #7630] [MERGED] fix(lorebooks): vectorize through the connection's Embedding Connection #7845

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/7630
Author: @ylli-selmani
Created: 10/14/2026
Status: ✅ Merged
Merged: 10/14/2026
Merged by: @ylli-selmani

Base: staging ← Head: fix/lorebook-vectorize-embedding-connection


📝 Commits (3)

  • 0c083cc fix(lorebooks): vectorize through the connection's Embedding Connection
  • b49a178 fix(lorebooks): list Embedding Connection borrowers in the Vectorize picker
  • 01ca1fd fix(lorebooks): clearer error when no embedding source resolves

📊 Changes

3 files changed (+110 additions, -46 deletions)

View changed files

📝 packages/client/src/components/lorebooks/LorebookEditor.tsx (+11 -4)
📝 packages/server/src/routes/lorebooks.routes.ts (+32 -41)
📝 scripts/regressions/lorebook-vectorization.regression.ts (+67 -1)

📄 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 #7628

Why this change

  • Before: Vectorize embedded lorebook entries through the picked connection's own base URL and API key, with whatever model the client sent. If that connection had an Embedding Connection set, Vectorize ignored it, while chat-time semantic matching used it. Entries and queries then came from different endpoints, got different embedding space ids, and the entries were skipped in semantic matching without any error.
  • After: Vectorize resolves its embedding source with resolveMemoryRecallEmbeddingSource, the same resolver chat-time matching uses, so the override's key, base URL and (when it has one) embedding model are used, and the stored space id matches the one queries are checked against.

What changed

  • POST /lorebooks/:id/vectorize (packages/server/src/routes/lorebooks.routes.ts) builds its remote source with resolveMemoryRecallEmbeddingSource instead of its own createLLMProvider call. The embeddingSpaceId and the input-profile formatting now come from that source. The Local Model (sidecar) path is unchanged.
  • The server resolves the embedding model itself. A model sent by the client is still accepted (the current client sends one) but ignored. A connection with no embedding model on itself or its Embedding Connection now gets a 400 with a message saying where to set one, instead of embedding with the client-sent model.
  • Because the shared source logs and swallows provider errors, a failed batch now returns 502 with "Embedding request through failed. Check the server log for details." rather than the raw provider message.
  • The Vectorize picker (LorebookEditor.tsx) also lists connections that have an Embedding Connection but no embedding model of their own, shows the model in the option label only when the connection has one, and no longer sends model.
  • scripts/regressions/lorebook-vectorization.regression.ts gains a second fake provider standing in for an Embedding Connection. It asserts Vectorize sends the request there and not to the chat connection's endpoint, that the stored space id equals the one resolveMemoryRecallEmbeddingSource gives for chat-time queries, and that a connection with no embedding model is refused. Before the fix, the override assertion failed (the request went to the chat connection's endpoint).

How this relates to #7627: that PR adds an app-wide default embedding source inside resolveMemoryRecallEmbeddingSource. Since Vectorize now goes through that resolver, the default will apply to vectorizing too, with no extra change here. This PR does not touch memory-recall-embedding.ts. Both PRs edit the Vectorize picker in LorebookEditor.tsx: this one changes the list filter and option label, #7627 changes the initial selection, so expect at most a small textual overlap.

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

Agent-run results (boxes above left for the contributor): pnpm check exit 0. In a dev build, a "Borrower" connection with no embedding model and an Embedding Connection pointing at a local fake embedding server (its own base URL pointing at nothing) now appears in the picker, and vectorizing with it embedded both entries through the override (/v1/embeddings, model test-embed). Regressions passing: lorebook-vectorization, memory-recall-revectorize, capability-embedding-input-type, entity-embedding-store.

Local CodeRabbit: 1 minor finding, dismissed. It asked for body-size and batch limits on the regression's second fake embedding server. That server binds to 127.0.0.1 on an ephemeral port for the life of one regression run, mirrors the existing fake server in the same file, and only receives requests from the route under test, so the limits would add code without protecting anything.

Manual verification notes

  • Manually verify that vectorizing with a connection whose Embedding Connection points at another endpoint sends the embedding requests to that endpoint, and that semantic matching then finds those entries in chat.
  • Manually verify that vectorizing with a plain connection that has its own embedding model still works as before.
  • Manually verify that a connection with only an Embedding Connection set appears in the Vectorize picker.
  • Manually verify that the Local Model (sidecar) option still vectorizes.

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)

docs/lorebooks/semantic-search.md is being rewritten in #7627's docs slice, which is the natural place to describe the Embedding Connection behavior.

UI evidence (if applicable)

Picker now lists the borrower connection; screenshot shared in the project thread.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Lorebook vectorization now determines the embedding source automatically, so requests no longer need to provide a model name.
    • Vectorization supports an Embedding Connection override and uses the same embedding space as memory-recall queries.
  • Bug Fixes
    • Connections without an available embedding space now receive an error instead of proceeding with vectorization.

🔄 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/7630 **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:** `fix/lorebook-vectorize-embedding-connection` --- ### 📝 Commits (3) - [`0c083cc`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0c083cc5d52520a50bb48cbd0d7d95cc938dcbff) fix(lorebooks): vectorize through the connection's Embedding Connection - [`b49a178`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b49a178533b2ed0ac589f2d39f7ecb722616aa75) fix(lorebooks): list Embedding Connection borrowers in the Vectorize picker - [`01ca1fd`](https://github.com/Pasta-Devs/Marinara-Engine/commit/01ca1fd3f3326d7926e6aa521697d08fd4a407f3) fix(lorebooks): clearer error when no embedding source resolves ### 📊 Changes **3 files changed** (+110 additions, -46 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/lorebooks/LorebookEditor.tsx` (+11 -4) 📝 `packages/server/src/routes/lorebooks.routes.ts` (+32 -41) 📝 `scripts/regressions/lorebook-vectorization.regression.ts` (+67 -1) </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 #7628 ## Why this change - Before: **Vectorize** embedded lorebook entries through the picked connection's own base URL and API key, with whatever model the client sent. If that connection had an **Embedding Connection** set, Vectorize ignored it, while chat-time semantic matching used it. Entries and queries then came from different endpoints, got different embedding space ids, and the entries were skipped in semantic matching without any error. - After: Vectorize resolves its embedding source with `resolveMemoryRecallEmbeddingSource`, the same resolver chat-time matching uses, so the override's key, base URL and (when it has one) embedding model are used, and the stored space id matches the one queries are checked against. ## What changed - `POST /lorebooks/:id/vectorize` (`packages/server/src/routes/lorebooks.routes.ts`) builds its remote source with `resolveMemoryRecallEmbeddingSource` instead of its own `createLLMProvider` call. The `embeddingSpaceId` and the input-profile formatting now come from that source. The Local Model (sidecar) path is unchanged. - The server resolves the embedding model itself. A `model` sent by the client is still accepted (the current client sends one) but ignored. A connection with no embedding model on itself or its Embedding Connection now gets a 400 with a message saying where to set one, instead of embedding with the client-sent model. - Because the shared source logs and swallows provider errors, a failed batch now returns 502 with "Embedding request through <source> failed. Check the server log for details." rather than the raw provider message. - The Vectorize picker (`LorebookEditor.tsx`) also lists connections that have an Embedding Connection but no embedding model of their own, shows the model in the option label only when the connection has one, and no longer sends `model`. - `scripts/regressions/lorebook-vectorization.regression.ts` gains a second fake provider standing in for an Embedding Connection. It asserts Vectorize sends the request there and not to the chat connection's endpoint, that the stored space id equals the one `resolveMemoryRecallEmbeddingSource` gives for chat-time queries, and that a connection with no embedding model is refused. Before the fix, the override assertion failed (the request went to the chat connection's endpoint). How this relates to #7627: that PR adds an app-wide default embedding source inside `resolveMemoryRecallEmbeddingSource`. Since Vectorize now goes through that resolver, the default will apply to vectorizing too, with no extra change here. This PR does not touch `memory-recall-embedding.ts`. Both PRs edit the Vectorize picker in `LorebookEditor.tsx`: this one changes the list filter and option label, #7627 changes the initial selection, so expect at most a small textual overlap. ## 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` Agent-run results (boxes above left for the contributor): `pnpm check` exit 0. In a dev build, a "Borrower" connection with no embedding model and an Embedding Connection pointing at a local fake embedding server (its own base URL pointing at nothing) now appears in the picker, and vectorizing with it embedded both entries through the override (`/v1/embeddings`, model `test-embed`). Regressions passing: `lorebook-vectorization`, `memory-recall-revectorize`, `capability-embedding-input-type`, `entity-embedding-store`. Local CodeRabbit: 1 minor finding, dismissed. It asked for body-size and batch limits on the regression's second fake embedding server. That server binds to 127.0.0.1 on an ephemeral port for the life of one regression run, mirrors the existing fake server in the same file, and only receives requests from the route under test, so the limits would add code without protecting anything. ### Manual verification notes - Manually verify that vectorizing with a connection whose Embedding Connection points at another endpoint sends the embedding requests to that endpoint, and that semantic matching then finds those entries in chat. - Manually verify that vectorizing with a plain connection that has its own embedding model still works as before. - Manually verify that a connection with only an Embedding Connection set appears in the Vectorize picker. - Manually verify that the Local Model (sidecar) option still vectorizes. ## Docs and release impact - [x] 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) `docs/lorebooks/semantic-search.md` is being rewritten in #7627's docs slice, which is the natural place to describe the Embedding Connection behavior. ## UI evidence (if applicable) Picker now lists the borrower connection; screenshot shared in the project thread. 🤖 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** * Lorebook vectorization now determines the embedding source automatically, so requests no longer need to provide a model name. * Vectorization supports an Embedding Connection override and uses the same embedding space as memory-recall queries. * **Bug Fixes** * Connections without an available embedding space now receive an error instead of proceeding with vectorization. <!-- 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#7845
No description provided.