[PR #2212] [MERGED] Fix lorebook tool key search #5475

Closed
opened 2026-10-22 04:16:38 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/2212
Author: @Promansis
Created: 6/4/2026
Status: ✅ Merged
Merged: 6/4/2026
Merged by: @Promansis

Base: refactor ← Head: fix/lorebook-key-search


📝 Commits (2)

  • 3b0b971 Fix lorebook tool key search
  • 35df743 Merge lorebook search duplicate metadata

📊 Changes

3 files changed (+64 additions, -17 deletions)

View changed files

📝 src/engine/contracts/types/agent.ts (+9 -1)
📝 src/engine/generation/agent-runner.ts (+9 -1)
📝 src/engine/generation/tools-runtime.ts (+46 -15)

📄 Description

Linked issue

Closes #2197

Why this change

  • search_lorebook could miss scoped lorebook entries when the query matched only entry trigger keys. Legacy searched entry keys, so agents and tool-enabled generation lost a parity path for key-only lorebook lookups.

What changed

  • Includes activated matched keys and stored primary/secondary keys in the search_lorebook scoring haystack.
  • Returns primary and secondary key context with search results so agents can see why a lorebook entry matched.
  • Widens the agent/tool runtime activated lorebook entry contract to preserve optional key fields already available from prompt assembly.

Refactor impact

Primary owner:

  • Engine generation / built-in tool runtime.

Impact areas reviewed:

  • Catalog lorebook entries loaded through scoped active lorebook search.
  • Chat, roleplay, and game tool-enabled generation paths that share search_lorebook.

Boundary notes:

  • Kept behavior in src/engine; no React, Tauri, shared API, or remote runtime boundary changes.

Pressure points touched:

  • Built-in tool result contract for search_lorebook now includes key context in addition to existing id/name/tag/source/score/content fields.

Validation

  • Matching validation command passes locally (for example pnpm typecheck, pnpm build, pnpm check:architecture, pnpm check:docs, or full pnpm check when warranted)
  • Full pnpm check passes before PR push/handoff
  • Human/manual validation completed by contributor or reviewer

Manual verification notes

  • pnpm typecheck passed locally.
  • pnpm check passed locally.

Feature Discoverability

Check exactly one:

  • Updated src/features/shell/discovery/ because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool.
  • N/A because this PR is only a bugfix, refactor, test, docs, internal wiring, visual polish, copy edit, or compatibility fix and does not add a new thing users need to find.

Reason:

  • Bugfix only; no new discoverable user workflow or setting.

Docs and release impact

  • No docs changes needed
  • Updated README.md
  • Updated CONTRIBUTING.md
  • Updated docs/developer/
  • Updated repo skills or AGENTS.md
  • Confirmed this PR does not restore old staging/package-workspace/release claims

UI evidence

  • Not applicable; engine-only behavior fix with no visible UI change.

🔄 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/2212 **Author:** [@Promansis](https://github.com/Promansis) **Created:** 6/4/2026 **Status:** ✅ Merged **Merged:** 6/4/2026 **Merged by:** [@Promansis](https://github.com/Promansis) **Base:** `refactor` ← **Head:** `fix/lorebook-key-search` --- ### 📝 Commits (2) - [`3b0b971`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3b0b97108a80cf219f994d66db3e52dadddb6fe8) Fix lorebook tool key search - [`35df743`](https://github.com/Pasta-Devs/Marinara-Engine/commit/35df7438bc7de4daab5a6fbb2be2350eac601ce7) Merge lorebook search duplicate metadata ### 📊 Changes **3 files changed** (+64 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `src/engine/contracts/types/agent.ts` (+9 -1) 📝 `src/engine/generation/agent-runner.ts` (+9 -1) 📝 `src/engine/generation/tools-runtime.ts` (+46 -15) </details> ### 📄 Description ## Linked issue Closes #2197 ## Why this change - `search_lorebook` could miss scoped lorebook entries when the query matched only entry trigger keys. Legacy searched entry keys, so agents and tool-enabled generation lost a parity path for key-only lorebook lookups. ## What changed - Includes activated matched keys and stored primary/secondary keys in the `search_lorebook` scoring haystack. - Returns primary and secondary key context with search results so agents can see why a lorebook entry matched. - Widens the agent/tool runtime activated lorebook entry contract to preserve optional key fields already available from prompt assembly. ## Refactor impact Primary owner: - Engine generation / built-in tool runtime. Impact areas reviewed: - Catalog lorebook entries loaded through scoped active lorebook search. - Chat, roleplay, and game tool-enabled generation paths that share `search_lorebook`. Boundary notes: - Kept behavior in `src/engine`; no React, Tauri, shared API, or remote runtime boundary changes. Pressure points touched: - Built-in tool result contract for `search_lorebook` now includes key context in addition to existing id/name/tag/source/score/content fields. ## Validation - [ ] Matching validation command passes locally (for example `pnpm typecheck`, `pnpm build`, `pnpm check:architecture`, `pnpm check:docs`, or full `pnpm check` when warranted) - [ ] Full `pnpm check` passes before PR push/handoff - [ ] Human/manual validation completed by contributor or reviewer ### Manual verification notes - `pnpm typecheck` passed locally. - `pnpm check` passed locally. ## Feature Discoverability Check exactly one: - [ ] Updated `src/features/shell/discovery/` because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool. - [ ] N/A because this PR is only a bugfix, refactor, test, docs, internal wiring, visual polish, copy edit, or compatibility fix and does not add a new thing users need to find. Reason: - Bugfix only; no new discoverable user workflow or setting. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated `README.md` - [ ] Updated `CONTRIBUTING.md` - [ ] Updated `docs/developer/` - [ ] Updated repo skills or `AGENTS.md` - [ ] Confirmed this PR does not restore old staging/package-workspace/release claims ## UI evidence - Not applicable; engine-only behavior fix with no visible UI change. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:16:38 +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#5475
No description provided.