[PR #5982] [MERGED] feat: give Game chats explicit tool and lore-search controls #7014

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5982
Author: @SpicyMarinara
Created: 9/9/2026
Status: ✅ Merged
Merged: 9/9/2026
Merged by: @SpicyMarinara

Base: staging ← Head: feat/game-tool-controls-5955-5957-5958


📝 Commits (10+)

  • 67f7646 chore: reserve Game tool controls issue sweep
  • 5e41bf8 feat: add independent Game tool planning and semantic lore search
  • 5fc8d8d Merge remote-tracking branch 'origin/staging' into feat/game-tool-controls-5955-5957-5958
  • f200c93 fix: preserve Agent lore search fallback and regression coverage
  • 6614ed9 fix: clarify Game tool controls and reuse connection flags
  • 0385f6c Merge branch 'fix/game-dice-results-5956-5961' into feat/game-tool-controls-5955-5957-5958
  • 49e42f7 Merge remote-tracking branch 'origin/staging' into feat/game-tool-controls-5955-5957-5958
  • 9e650df fix: keep stacked dice history readable and translation-safe
  • 5eb670a Merge branch 'fix/game-tool-outcomes-5898-5901' into feat/game-tool-controls-5955-5957-5958
  • b8fd87a test: cover deferred state writes from a separate Game planner

📊 Changes

18 files changed (+931 additions, -104 deletions)

View changed files

📝 CHANGELOG.md (+3 -1)
📝 docs/extending/custom-tools.md (+4 -0)
📝 docs/game/getting-started.md (+21 -13)
📝 e2e/game-native-dice.e2e.ts (+35 -0)
➕ e2e/game-tool-controls.e2e.ts (+130 -0)
📝 packages/client/src/components/chat/ChatSettingsDrawer.tsx (+20 -0)
📝 packages/client/src/components/game/GameNarration.tsx (+25 -15)
📝 packages/client/src/features/chat-settings/sections/FunctionCallingSection.tsx (+76 -2)
📝 packages/client/src/localization/locales/en.json (+10 -2)
📝 packages/server/src/routes/generate.routes.ts (+126 -58)
➕ packages/server/src/services/generation/game-tool-planning.ts (+62 -0)
📝 packages/server/src/services/generation/tool-resolution-runtime.ts (+60 -6)
📝 packages/shared/src/constants/providers.ts (+5 -0)
📝 packages/shared/src/features/function-calls/tools/search-lorebook/manifest.ts (+6 -2)
📝 packages/shared/src/types/chat.ts (+4 -0)
➕ scripts/regressions/game-tool-controls.regression.ts (+341 -0)
📝 scripts/regressions/maintenance-lifecycle.regression.ts (+2 -4)
📝 scripts/regressions/roleplay-streaming.regression.ts (+1 -1)

📄 Description

Linked issue

Closes #5955. Closes #5957. Closes #5958. Completes the stacked dice-history review follow-up from #5979 (#5956).

Why this change

Game players could only obtain lore searches by enabling the whole optional tool set, and the search matched literal text. There was no cheaper connection for tool planning. Claude and Grok subscription connections also accepted the tool toggle while ignoring the native tool schema.

What changed

  • Add per-chat Game tool connection and lore-search controls using the existing settings components. Unsupported subscription transports and missing overrides have explicit availability guidance.
  • A selected separate connection makes one bounded planning request. Existing allowlists and handlers execute its calls, then only text results reach the narrator. Provider signatures, encrypted reasoning, planning prose, and usage stay separate. Without an override, the native tool loop remains unchanged. Failed or invalid planning connections report an error before narration.
  • Route lore searches through the calibrated semantic shortlist with the active embedding source. Preserve scope, disabled folders/entries, and per-chat entry flags. Game Master search requires existing vectors and never vectorizes automatically; existing Agent tools and other chat modes retain text fallback when semantic search is unavailable.
  • Preserve the planner's results when real text dice trigger an outcome rewrite. Complete the stacked-view counterpart of #5979: narration controls stay on prose, translated display preserves numeric roll summaries, and light-theme system rows use the existing readable colors.
  • Describe the extra request and the tradeoff: the planning model chooses tools and cannot chain dependent lookups. Planner usage is saved separately from narrator usage in message extras.

Validation

Completed automated proof:

  • pnpm check (localization, formatting, TypeScript, ESLint, build, browser-test types) and pnpm regression:prompt.

  • game-tool-controls.regression.ts uses real Fastify/file storage with only model/embedding transports replaced. It covers Claude, Grok, and Gemini narration; separate budgets and usage; real dice; denied calls; no-call plans; missing/failed connections; subscription bypass; semantic ranking; disabled entries; vector prerequisites; and independent tool resolution. The isolation assertion caught a shared-array mutation leaking tool history; a copied loop array made it pass.

  • The combined planner-and-text-dice regression reproduced a lost-context fallback and now verifies the complete rewrite retains planner results. The stacked-history browser assertion reproduced the misplaced translation controls. After integrating #5984, a separate-planner state-write case verifies the pending receipt, saved narration snapshot, and untouched earlier state. All nine dice/history browser cases pass, including both log views and translated display.

  • Existing game-mode-dice-tool.regression.ts, manual Agent retry/tool parity, maintenance lifecycle and Roleplay streaming regressions passed. The retry proof caught an unintended vector requirement on Agent tools; their existing text fallback is preserved.

  • The complete Linux Node regression suite passed in CI. The full local macOS run passed 236/238, with failures in the unmodified Mari store-link and writer-lease platform fixtures; neither those regressions nor their implementation files differ from staging.

  • Six browser cases passed across desktop Chromium, mobile Chromium, and mobile WebKit in light and dark themes. They verify unavailable subscription controls, the connection choice, independent lore-search persistence, reloads, and a deleted override. An added imported-connection regression reproduced an image default masking the subscription narrator's availability; the lookup now reuses the existing filtered chat-connection list. The mobile screenshot was inspected.

  • 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

Manual verification notes

Manually verify tool selection quality, latency, and actual billing with a live paid tool connection and subscription narrator. Check the controls on a physical mobile device and try a long personal campaign. Automated transport fixtures verify routing and isolation, not live model quality.

Docs and release impact

Added an Unreleased entry and canonical English UI keys. Updated docs/game/getting-started.md and docs/extending/custom-tools.md; translation follow-up #5983 tracks every language pack on docs-i18n. No version bump or new dependency.

UI evidence (if applicable)

e2e/game-tool-controls.e2e.ts produces light/dark viewport captures. Existing settings switch, select, and section styles are reused.

Summary by CodeRabbit

  • New Features

    • Game chats can use a separate connection for tool planning.
    • Game Masters can enable semantic lorebook searches independently from other tools.
    • Chat settings indicate native tool availability and preserve tool connection choices.
  • Bug Fixes

    • Game history retains dice-roll details, with improved translated narration and message actions.
    • System-log styling is more consistent across game views.
  • Documentation

    • Updated setup and custom-tool guides with connection requirements, lorebook search behavior, and game configuration options.

🔄 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/5982 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 9/9/2026 **Status:** ✅ Merged **Merged:** 9/9/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `feat/game-tool-controls-5955-5957-5958` --- ### 📝 Commits (10+) - [`67f7646`](https://github.com/Pasta-Devs/Marinara-Engine/commit/67f764616bc6cf5d932c72247c292ab0cf420c1c) chore: reserve Game tool controls issue sweep - [`5e41bf8`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5e41bf8ff967c6fcf6f5e0c0ce9d4ed1ee7bd3b6) feat: add independent Game tool planning and semantic lore search - [`5fc8d8d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5fc8d8dd9e039d53c64f37b6db43f2ec885e6ba2) Merge remote-tracking branch 'origin/staging' into feat/game-tool-controls-5955-5957-5958 - [`f200c93`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f200c939e6a19cc18ce188927d59e57ea0e5233d) fix: preserve Agent lore search fallback and regression coverage - [`6614ed9`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6614ed937941f9baa797ddee84a3e2f73b7b864c) fix: clarify Game tool controls and reuse connection flags - [`0385f6c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0385f6c31d988b1476fa6bb3ef1298af26ff6e00) Merge branch 'fix/game-dice-results-5956-5961' into feat/game-tool-controls-5955-5957-5958 - [`49e42f7`](https://github.com/Pasta-Devs/Marinara-Engine/commit/49e42f7a53c32637e55efad3b26c8cf47b6c4262) Merge remote-tracking branch 'origin/staging' into feat/game-tool-controls-5955-5957-5958 - [`9e650df`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9e650df924fa36141168533d8e6de2fa273265dc) fix: keep stacked dice history readable and translation-safe - [`5eb670a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5eb670a92acb926ef06d4fae286ed907a9f5a6a1) Merge branch 'fix/game-tool-outcomes-5898-5901' into feat/game-tool-controls-5955-5957-5958 - [`b8fd87a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b8fd87a747d9f669f2515ef543b4fb601caf5d70) test: cover deferred state writes from a separate Game planner ### 📊 Changes **18 files changed** (+931 additions, -104 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+3 -1) 📝 `docs/extending/custom-tools.md` (+4 -0) 📝 `docs/game/getting-started.md` (+21 -13) 📝 `e2e/game-native-dice.e2e.ts` (+35 -0) ➕ `e2e/game-tool-controls.e2e.ts` (+130 -0) 📝 `packages/client/src/components/chat/ChatSettingsDrawer.tsx` (+20 -0) 📝 `packages/client/src/components/game/GameNarration.tsx` (+25 -15) 📝 `packages/client/src/features/chat-settings/sections/FunctionCallingSection.tsx` (+76 -2) 📝 `packages/client/src/localization/locales/en.json` (+10 -2) 📝 `packages/server/src/routes/generate.routes.ts` (+126 -58) ➕ `packages/server/src/services/generation/game-tool-planning.ts` (+62 -0) 📝 `packages/server/src/services/generation/tool-resolution-runtime.ts` (+60 -6) 📝 `packages/shared/src/constants/providers.ts` (+5 -0) 📝 `packages/shared/src/features/function-calls/tools/search-lorebook/manifest.ts` (+6 -2) 📝 `packages/shared/src/types/chat.ts` (+4 -0) ➕ `scripts/regressions/game-tool-controls.regression.ts` (+341 -0) 📝 `scripts/regressions/maintenance-lifecycle.regression.ts` (+2 -4) 📝 `scripts/regressions/roleplay-streaming.regression.ts` (+1 -1) </details> ### 📄 Description ## Linked issue Closes #5955. Closes #5957. Closes #5958. Completes the stacked dice-history review follow-up from #5979 (#5956). ## Why this change Game players could only obtain lore searches by enabling the whole optional tool set, and the search matched literal text. There was no cheaper connection for tool planning. Claude and Grok subscription connections also accepted the tool toggle while ignoring the native tool schema. ## What changed - Add per-chat Game tool connection and lore-search controls using the existing settings components. Unsupported subscription transports and missing overrides have explicit availability guidance. - A selected separate connection makes one bounded planning request. Existing allowlists and handlers execute its calls, then only text results reach the narrator. Provider signatures, encrypted reasoning, planning prose, and usage stay separate. Without an override, the native tool loop remains unchanged. Failed or invalid planning connections report an error before narration. - Route lore searches through the calibrated semantic shortlist with the active embedding source. Preserve scope, disabled folders/entries, and per-chat entry flags. Game Master search requires existing vectors and never vectorizes automatically; existing Agent tools and other chat modes retain text fallback when semantic search is unavailable. - Preserve the planner's results when real text dice trigger an outcome rewrite. Complete the stacked-view counterpart of #5979: narration controls stay on prose, translated display preserves numeric roll summaries, and light-theme system rows use the existing readable colors. - Describe the extra request and the tradeoff: the planning model chooses tools and cannot chain dependent lookups. Planner usage is saved separately from narrator usage in message extras. ## Validation Completed automated proof: - `pnpm check` (localization, formatting, TypeScript, ESLint, build, browser-test types) and `pnpm regression:prompt`. - `game-tool-controls.regression.ts` uses real Fastify/file storage with only model/embedding transports replaced. It covers Claude, Grok, and Gemini narration; separate budgets and usage; real dice; denied calls; no-call plans; missing/failed connections; subscription bypass; semantic ranking; disabled entries; vector prerequisites; and independent tool resolution. The isolation assertion caught a shared-array mutation leaking tool history; a copied loop array made it pass. - The combined planner-and-text-dice regression reproduced a lost-context fallback and now verifies the complete rewrite retains planner results. The stacked-history browser assertion reproduced the misplaced translation controls. After integrating #5984, a separate-planner state-write case verifies the pending receipt, saved narration snapshot, and untouched earlier state. All nine dice/history browser cases pass, including both log views and translated display. - Existing `game-mode-dice-tool.regression.ts`, manual Agent retry/tool parity, maintenance lifecycle and Roleplay streaming regressions passed. The retry proof caught an unintended vector requirement on Agent tools; their existing text fallback is preserved. - The complete Linux Node regression suite passed in CI. The full local macOS run passed 236/238, with failures in the unmodified Mari store-link and writer-lease platform fixtures; neither those regressions nor their implementation files differ from staging. - Six browser cases passed across desktop Chromium, mobile Chromium, and mobile WebKit in light and dark themes. They verify unavailable subscription controls, the connection choice, independent lore-search persistence, reloads, and a deleted override. An added imported-connection regression reproduced an image default masking the subscription narrator's availability; the lookup now reuses the existing filtered chat-connection list. The mobile screenshot was inspected. - [ ] `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` ### Manual verification notes Manually verify tool selection quality, latency, and actual billing with a live paid tool connection and subscription narrator. Check the controls on a physical mobile device and try a long personal campaign. Automated transport fixtures verify routing and isolation, not live model quality. ## Docs and release impact Added an Unreleased entry and canonical English UI keys. Updated `docs/game/getting-started.md` and `docs/extending/custom-tools.md`; translation follow-up #5983 tracks every language pack on `docs-i18n`. No version bump or new dependency. ## UI evidence (if applicable) `e2e/game-tool-controls.e2e.ts` produces light/dark viewport captures. Existing settings switch, select, and section styles are reused. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Game chats can use a separate connection for tool planning. * Game Masters can enable semantic lorebook searches independently from other tools. * Chat settings indicate native tool availability and preserve tool connection choices. * **Bug Fixes** * Game history retains dice-roll details, with improved translated narration and message actions. * System-log styling is more consistent across game views. * **Documentation** * Updated setup and custom-tool guides with connection requirements, lorebook search behavior, and game configuration options. <!-- 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:15:44 +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#7014
No description provided.