[PR #1957] [MERGED] Fix Lorebook Keeper focused fact extraction #5358

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1957
Author: @cha1latte
Created: 6/2/2026
Status: ✅ Merged
Merged: 6/2/2026
Merged by: @cha1latte

Base: refactor ← Head: fix/issue-1946-lorebook-focused-facts


📝 Commits (1)

  • 6b9dcb0 Fix Lorebook Keeper focused fact prompt

📊 Changes

2 files changed (+26 additions, -8 deletions)

View changed files

➕ src/engine/contracts/constants/agent-prompts.test.ts (+15 -0)
📝 src/engine/contracts/constants/agent-prompts.ts (+11 -8)

📄 Description

Linked issue

Closes #1946

Why this change

  • Lorebook Keeper's default prompt told the model to create "full lore content" but did not clearly say that the generated <assistant_response> is source material, not content to save wholesale. Some models responded by proposing whole-message lorebook bodies instead of focused durable facts.

What changed

  • Tightened the built-in Lorebook Keeper prompt so it explicitly extracts from <assistant_response>.
  • Added guardrails that forbid whole-message transcript/recap entries and define content as concise neutral extracted lore.
  • Added a focused prompt-contract regression test for the default Lorebook Keeper prompt.

Refactor impact

Primary owner:

  • engine generation

Impact areas reviewed:

  • Built-in agent prompt contract.
  • Lorebook Keeper output shape consumed by pending lorebook update handling.

Boundary notes:

  • Engine-only prompt/default-contract change. No React UI, shared API, storage, Rust, remote-runtime, schema, dependency, or version files changed.

Pressure points touched:

  • None.

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

  • Codex repro before fix: pnpm exec vitest run src/engine/contracts/constants/agent-prompts.test.ts failed because the default Lorebook Keeper prompt did not mention <assistant_response> or whole-message-copy guardrails.
  • Codex verification after fix: pnpm exec vitest run src/engine/contracts/constants/agent-prompts.test.ts passed.
  • Codex validation: pnpm typecheck passed.
  • Codex validation: pnpm check passed after rerun with a longer timeout. The first 120s run timed out before completion.
  • Codex proof gate: node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json passed.
  • No manual UI validation needed; this is a default prompt-contract fix with no visible UI surface.

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 to an existing built-in agent prompt; no new discoverable product surface.

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

N/A. This is a default prompt-contract fix with command-based verification rather than a visible UI change.

Summary by CodeRabbit

  • Tests

    • Added validation tests for the lorebook-keeper prompt to ensure proper formatting and extraction behavior.
  • Chores

    • Enhanced lorebook-keeper prompt with improved content extraction rules and deduplication handling to ensure more accurate and consistent information processing.

🔄 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/1957 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 6/2/2026 **Status:** ✅ Merged **Merged:** 6/2/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `refactor` ← **Head:** `fix/issue-1946-lorebook-focused-facts` --- ### 📝 Commits (1) - [`6b9dcb0`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6b9dcb0c41a64ed5a4aab96b4e15d1b30ccdeb0b) Fix Lorebook Keeper focused fact prompt ### 📊 Changes **2 files changed** (+26 additions, -8 deletions) <details> <summary>View changed files</summary> ➕ `src/engine/contracts/constants/agent-prompts.test.ts` (+15 -0) 📝 `src/engine/contracts/constants/agent-prompts.ts` (+11 -8) </details> ### 📄 Description <!-- Target branch: `refactor`. Change the base to `refactor` before submitting unless a maintainer explicitly asked for another base. --> <!-- Keep all checkboxes unchecked until a human has actually verified them. --> ## Linked issue Closes #1946 ## Why this change - Lorebook Keeper's default prompt told the model to create "full lore content" but did not clearly say that the generated `<assistant_response>` is source material, not content to save wholesale. Some models responded by proposing whole-message lorebook bodies instead of focused durable facts. ## What changed - Tightened the built-in Lorebook Keeper prompt so it explicitly extracts from `<assistant_response>`. - Added guardrails that forbid whole-message transcript/recap entries and define `content` as concise neutral extracted lore. - Added a focused prompt-contract regression test for the default Lorebook Keeper prompt. ## Refactor impact Primary owner: - engine generation Impact areas reviewed: - Built-in agent prompt contract. - Lorebook Keeper output shape consumed by pending lorebook update handling. Boundary notes: - Engine-only prompt/default-contract change. No React UI, shared API, storage, Rust, remote-runtime, schema, dependency, or version files changed. Pressure points touched: - None. ## Validation <!-- Check only what you personally ran or manually verified. Treat unchecked items as explicit TODOs. --> <!-- Do not submit *.test.ts or *.test.tsx files as PR proof; cite existing checks, command output, app/browser/Tauri verification, or manual notes instead. --> - [ ] 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 - Codex repro before fix: `pnpm exec vitest run src/engine/contracts/constants/agent-prompts.test.ts` failed because the default Lorebook Keeper prompt did not mention `<assistant_response>` or whole-message-copy guardrails. - Codex verification after fix: `pnpm exec vitest run src/engine/contracts/constants/agent-prompts.test.ts` passed. - Codex validation: `pnpm typecheck` passed. - Codex validation: `pnpm check` passed after rerun with a longer timeout. The first 120s run timed out before completion. - Codex proof gate: `node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json` passed. - No manual UI validation needed; this is a default prompt-contract fix with no visible UI surface. ## 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 to an existing built-in agent prompt; no new discoverable product surface. ## 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 N/A. This is a default prompt-contract fix with command-based verification rather than a visible UI change. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Added validation tests for the lorebook-keeper prompt to ensure proper formatting and extraction behavior. * **Chores** * Enhanced lorebook-keeper prompt with improved content extraction rules and deduplication handling to ensure more accurate and consistent information processing. <!-- 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-22 04:15:33 +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#5358
No description provided.