[GH-ISSUE #2285] [Issue]: Lorebook vectorization makes one serial embedding request per entry instead of batching #1123

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

Originally created by @Romuromylus on GitHub (Jun 5, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2285

Originally assigned to: @Romuromylus on GitHub.

Summary

The refactor's "vectorize lorebook" action issues one embedding HTTP request per entry in a serial loop. The web app batched entry texts (50 per request), so a large lorebook now takes N round-trips instead of ceil(N/50).

Expected behavior

Vectorizing a lorebook should batch entry texts into embedding requests (as main does with BATCH_SIZE 50), keeping this user-triggered action fast and reducing rate-limit exposure.

Actual behavior

vectorize_lorebook loops per entry and awaits a single-string embedding POST each, so a 200-entry lorebook makes ~200 sequential API calls where the web app made ~4 batched calls. Embeddings are functionally equivalent, so this is a wall-clock/rate-limit regression, not a correctness break.

Steps to reproduce

  1. Configure a remote embedding-capable connection.
  2. Create a lorebook with many entries (e.g. 200).
  3. Trigger "vectorize lorebook" and observe the long serial duration / per-entry request pattern.

Impact area

  • Catalog resources
  • Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime

Regression notes

Worked better on main. Main batches: packages/server/src/routes/lorebooks.routes.ts:809-814 uses BATCH_SIZE 50 and provider.embed(batchTexts, model) sends the whole array (base-provider.ts:615); the warmup path also batches up to 32 (embeddings.ts:90, memory-recall.ts:73). The refactor's vectorize_lorebook loops per entry awaiting embed_text (src-tauri/src/commands/storage/prompts.rs:233-256) and embed_openai_compatible POSTs a single string (prompts.rs:537-547). No batch embedding path exists anywhere in src-tauri (incl. crates/llm); the sidecar path also loops per input (http_server.rs:1055).

Environment

  • Branch or commit: refactor @ 5ddb9840 (compared against main @ b4ab97f)
  • Run mode: Tauri desktop
  • OS + version: Windows 11
  • Node + pnpm versions: not relevant (static source comparison)
  • Rust version, if relevant: not relevant (static source comparison)
  • Remote Runtime URL configured? not relevant
  • Provider, model, or integration, if relevant: see body

Template check

Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Romuromylus on GitHub (Jun 5, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2285 Originally assigned to: @Romuromylus on GitHub. ## Summary The refactor's "vectorize lorebook" action issues one embedding HTTP request per entry in a serial loop. The web app batched entry texts (50 per request), so a large lorebook now takes N round-trips instead of ceil(N/50). ## Expected behavior Vectorizing a lorebook should batch entry texts into embedding requests (as main does with BATCH_SIZE 50), keeping this user-triggered action fast and reducing rate-limit exposure. ## Actual behavior `vectorize_lorebook` loops per entry and awaits a single-string embedding POST each, so a 200-entry lorebook makes ~200 sequential API calls where the web app made ~4 batched calls. Embeddings are functionally equivalent, so this is a wall-clock/rate-limit regression, not a correctness break. ## Steps to reproduce 1. Configure a remote embedding-capable connection. 2. Create a lorebook with many entries (e.g. 200). 3. Trigger "vectorize lorebook" and observe the long serial duration / per-entry request pattern. ## Impact area - [x] Catalog resources - [x] Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime ## Regression notes Worked better on main. Main batches: `packages/server/src/routes/lorebooks.routes.ts:809-814` uses BATCH_SIZE 50 and `provider.embed(batchTexts, model)` sends the whole array (`base-provider.ts:615`); the warmup path also batches up to 32 (`embeddings.ts:90`, `memory-recall.ts:73`). The refactor's `vectorize_lorebook` loops per entry awaiting `embed_text` (`src-tauri/src/commands/storage/prompts.rs:233-256`) and `embed_openai_compatible` POSTs a single string (`prompts.rs:537-547`). No batch embedding path exists anywhere in src-tauri (incl. crates/llm); the sidecar path also loops per input (`http_server.rs:1055`). ## Environment - Branch or commit: refactor @ 5ddb9840 (compared against main @ b4ab97f) - Run mode: Tauri desktop - OS + version: Windows 11 - Node + pnpm versions: not relevant (static source comparison) - Rust version, if relevant: not relevant (static source comparison) - Remote Runtime URL configured? not relevant - Provider, model, or integration, if relevant: see body ## Template check Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:27:23 +07:00
Author
Owner

@Romuromylus commented on GitHub (Jun 6, 2026):

Fixed by #2398, merged into refactor.

<!-- gh-comment-id:4637946640 --> @Romuromylus commented on GitHub (Jun 6, 2026): Fixed by #2398, merged into `refactor`.
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#1123
No description provided.