[PR #5768] [CLOSED] fix: prevent large lorebook embedding timeouts #6924

Closed
opened 2026-10-23 04:14:56 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5768
Author: @mikemikimike
Created: 9/2/2026
Status: ❌ Closed

Base: staging ← Head: contrib/5717-lorebook-timeout


📝 Commits (6)

  • d054d57 chore: start #5717 implementation
  • 9b31230 chore: sync #5717 branch with staging
  • 4b7d781 fix: reduce large lorebook embedding batches
  • 9866d2a chore: align #5717 branch with staging
  • 07f01f2 fix: address review feedback
  • 7b063ff Merge branch 'staging' into contrib/5717-lorebook-timeout

📊 Changes

4 files changed (+75 additions, -7 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 packages/server/src/routes/lorebooks.routes.ts (+10 -7)
📝 packages/server/src/services/lorebook/embeddings.ts (+22 -0)
➕ scripts/regressions/lorebook-vectorization-batches.regression.ts (+41 -0)

📄 Description

Fixes #5717

Summary

Large lorebooks can fail during embedding vectorization when a llama.cpp embedding server needs more time to complete a large batch request.

Type of Change

  • feat - A new feature
  • fix - A bug fix
  • docs - Documentation only changes
  • style - Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
  • refactor - A code change that neither fixes a bug nor adds a feature
  • perf - A code change that improves performance
  • test - Adding missing tests or correcting existing tests
  • build - Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
  • ci - Changes to our Cl configuration files and scripts (examples: Travis, Circle, BrowserStack, SauceLabs)
  • chore - Other changes that don't modify src or test files
  • revert - Reverts a previous commit
  • security - A security fix or improvement
  • github - Changes to our GitHub configuration files and scripts
  • other (please describe):

Why this change

Large lorebooks can fail during embedding vectorization when a llama.cpp embedding server needs more time to complete a large batch request. Issue #5717 reproduces this with a 72-entry lorebook and reports read ETIMEDOUT failures.

What changed

  • Reduced the lorebook vectorization batch size from 50 to 10 entries.
  • Added a shared batch builder that keeps entries aligned with their embedding texts and rejects mismatched input before any provider request.
  • Kept the existing sequential request and per-batch vector validation/persistence behavior unchanged.
  • Added a regression covering a 72-entry lorebook, the final partial batch, complete persistence coverage, and mismatched input arrays.

Validation

  • corepack pnpm --filter @marinara-engine/server exec tsx ../../scripts/regressions/lorebook-vectorization-batches.regression.ts — passed.
  • corepack pnpm exec prettier --check scripts/regressions/lorebook-vectorization-batches.regression.ts — passed.
  • corepack pnpm check — passed (impeccable context, localization, formatting, lint, TypeScript, e2e types, server build, and client Vite/PWA build).
  • git diff --check — passed.
  • Full regression lane is not fully green in this environment: 181/183 passed. pnpm-runner.regression.mjs timed out waiting for FAKE_PNPM_SERVER_READY on this Windows/Node 22 host, and launcher/format-guard.regression.mjs cannot start /bin/bash because WSL is unavailable.

Compatibility / Known limitations

The change preserves existing embedding-provider interfaces and sends the same sequential requests with smaller input batches. Manual validation against a live llama.cpp embedding server using the reported Qwen3-Embedding model was not available in this environment.

Screenshots / Recordings (if applicable)

N/A — no UI changes are planned.

Checklist

  • I have read the CONTRIBUTING.md
  • I have added/updated tests where applicable
  • I have updated documentation where necessary
## Summary by CodeRabbit
  • Bug Fixes
  • Improved lorebook vectorization reliability by processing embeddings in smaller batches.
  • Large lorebooks are more likely to finish successfully on slower local embedding servers.
  • Added validation to prevent incomplete processing when lorebook entries and embedding text do not match.
  • Tests
  • Added regression coverage for batching, persistence, and mismatched input handling.

🔄 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/5768 **Author:** [@mikemikimike](https://github.com/mikemikimike) **Created:** 9/2/2026 **Status:** ❌ Closed **Base:** `staging` ← **Head:** `contrib/5717-lorebook-timeout` --- ### 📝 Commits (6) - [`d054d57`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d054d5717a80d1701542d85f038e54c108a2c5d1) chore: start #5717 implementation - [`9b31230`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9b31230f9c2468d679969109b1213dc77ab0ab72) chore: sync #5717 branch with staging - [`4b7d781`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4b7d78109830e8071c49fbf93c7c9b89d3af3c43) fix: reduce large lorebook embedding batches - [`9866d2a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9866d2aabc390b10625b50417e64d11f526eab76) chore: align #5717 branch with staging - [`07f01f2`](https://github.com/Pasta-Devs/Marinara-Engine/commit/07f01f23758bf17049bc9bb219fdd3a69281ee32) fix: address review feedback - [`7b063ff`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7b063ff645e911d541cd90a326c0807797a6a979) Merge branch 'staging' into contrib/5717-lorebook-timeout ### 📊 Changes **4 files changed** (+75 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `packages/server/src/routes/lorebooks.routes.ts` (+10 -7) 📝 `packages/server/src/services/lorebook/embeddings.ts` (+22 -0) ➕ `scripts/regressions/lorebook-vectorization-batches.regression.ts` (+41 -0) </details> ### 📄 Description Fixes #5717 ## Summary Large lorebooks can fail during embedding vectorization when a llama.cpp embedding server needs more time to complete a large batch request. ## Type of Change - [ ] feat - A new feature - [x] fix - A bug fix - [ ] docs - Documentation only changes - [ ] style - Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc) - [ ] refactor - A code change that neither fixes a bug nor adds a feature - [ ] perf - A code change that improves performance - [ ] test - Adding missing tests or correcting existing tests - [ ] build - Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm) - [ ] ci - Changes to our Cl configuration files and scripts (examples: Travis, Circle, BrowserStack, SauceLabs) - [ ] chore - Other changes that don't modify src or test files - [ ] revert - Reverts a previous commit - [ ] security - A security fix or improvement - [ ] github - Changes to our GitHub configuration files and scripts - [ ] other (please describe): ## Why this change Large lorebooks can fail during embedding vectorization when a llama.cpp embedding server needs more time to complete a large batch request. Issue #5717 reproduces this with a 72-entry lorebook and reports `read ETIMEDOUT` failures. ## What changed - Reduced the lorebook vectorization batch size from 50 to 10 entries. - Added a shared batch builder that keeps entries aligned with their embedding texts and rejects mismatched input before any provider request. - Kept the existing sequential request and per-batch vector validation/persistence behavior unchanged. - Added a regression covering a 72-entry lorebook, the final partial batch, complete persistence coverage, and mismatched input arrays. ## Validation - [x] `corepack pnpm --filter @marinara-engine/server exec tsx ../../scripts/regressions/lorebook-vectorization-batches.regression.ts` — passed. - [x] `corepack pnpm exec prettier --check scripts/regressions/lorebook-vectorization-batches.regression.ts` — passed. - [x] `corepack pnpm check` — passed (impeccable context, localization, formatting, lint, TypeScript, e2e types, server build, and client Vite/PWA build). - [x] `git diff --check` — passed. - [ ] Full regression lane is not fully green in this environment: 181/183 passed. `pnpm-runner.regression.mjs` timed out waiting for `FAKE_PNPM_SERVER_READY` on this Windows/Node 22 host, and `launcher/format-guard.regression.mjs` cannot start `/bin/bash` because WSL is unavailable. ## Compatibility / Known limitations The change preserves existing embedding-provider interfaces and sends the same sequential requests with smaller input batches. Manual validation against a live llama.cpp embedding server using the reported Qwen3-Embedding model was not available in this environment. ## Screenshots / Recordings (if applicable) N/A — no UI changes are planned. ## Checklist - [ ] I have read the [CONTRIBUTING.md](../blob/staging/CONTRIBUTING.md) - [ ] I have added/updated tests where applicable - [ ] I have updated documentation where necessary <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Improved lorebook vectorization reliability by processing embeddings in smaller batches. - Large lorebooks are more likely to finish successfully on slower local embedding servers. - Added validation to prevent incomplete processing when lorebook entries and embedding text do not match. - **Tests** - Added regression coverage for batching, persistence, and mismatched input handling. <!-- 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-23 04:14:56 +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#6924
No description provided.