[GH-ISSUE #6121] Adding the lorebook search tool by hand to a Game chat does nothing, and the panel still claims it is available #3398

Closed
opened 2026-10-21 06:02:40 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @kolacheee on GitHub (Sep 13, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6121

Originally assigned to: @SpicyMarinara on GitHub.

In a Game chat, the function picker still offers search_lorebook and lets you add it to the chat's tool list, and the panel still says all enabled tools are available - but the server strips that tool out of every Game turn unless "Let the GM search lore" is on. The tool sits in the list looking live and never runs, with nothing saying it was withheld.

How to reproduce (try it yourself)

  1. Open a Game chat whose connection supports tool calls (otherwise both tool switches render disabled and you cannot start). Chat Settings (gear icon) -> Function Calling.
  2. Turn Enable Tool Use ON and leave Let the GM search lore OFF (its default). With the function list empty, the panel reads "All globally enabled tools are available to this chat."
  3. Click Add Functions, type search in the picker. search_lorebook is offered with no "unavailable here" marker. Tick it and add it - it now sits in the chat's active function list styled like any working tool.
  4. With search_lorebook as the only entry in that list, also turn on Force to Call Tool, then send any message.

What you'll see: the turn cannot use search_lorebook - the server resolved this chat's tool set down to roll_dice alone and dropped the tool you explicitly picked. No message, badge, or tooltip says it was removed. (Compare update_about_me, the other mode-restricted built-in: the picker correctly hides it outside Conversation.)

What should happen: if a tool cannot run in this mode, the picker should not offer it and the list should not show it as active - or, if it is offered, an explicit choice should be honoured or visibly refused. And the "All globally enabled tools are available to this chat" line should not be shown in a state where it is false.

Where it is

At staging 52799569c:

  • packages/server/src/services/generation/tool-resolution-runtime.ts:768-770 - the Game filter: if (toolDefs && agentContext.chatMode === "game" && !booleanText(chatMetadata.gameLorebookSearch)) { toolDefs = toolDefs.filter((toolDef) => toolDef.function.name !== "search_lorebook"); }
  • packages/server/src/services/generation/tool-resolution-runtime.ts:751-760 - the per-chat activeToolIds selection is applied in loadToolDefinitions before that filter, so an explicit pick is discarded afterwards.
  • packages/client/src/components/chat/ChatSettingsDrawer.tsx:2349-2353 - availableTools skips only update_about_me when not in Conversation.
  • packages/client/src/features/chat-settings/sections/FunctionCallingSection.tsx:179-182 - renders "All globally enabled tools are available to this chat" whenever the chat's tool list is empty.

What's happening

The mode restriction is enforced on the server only. The client already has the right pattern for this situation - it hides update_about_me outside Conversation, with a comment saying it should not look available where it cannot run - but search_lorebook was never added to that filter. And because the user's per-chat selection is resolved before the Game filter runs, picking the tool by hand does not override the restriction; it just disappears.

Suggested fix

Extend the existing client-side mode filter so search_lorebook is hidden (or shown disabled with a reason) in Game chats while "Let the GM search lore" is off, and suppress or qualify the "all globally enabled tools are available" line in that state. Separately, decide what an explicit selection means: either honour a hand-picked search_lorebook as equivalent to turning the switch on, or surface why it was dropped - silently discarding a choice the user made by hand is the worst of the three options. Server-side enforcement should stay as the backstop.

If the fix is instead to restore the old default, note that scripts/regressions/game-tool-controls.regression.ts:306-311 asserts the current behaviour, so that route means rewriting a maintainer-written assertion - worth a deliberate decision rather than a green-lane edit.

Context

Introduced by merged PR #5982 (commit 5e41bf8ff, 2026-09-09), implementing issue #5955 and also closing #5957/#5958. Unreleased on staging - the latest release tag is v2.4.4, whose tool resolution file has no Game filter at all. The gate itself is intended; this is about the client advertising a tool the server will not run and about the discarded explicit selection. One more thing belongs with this change rather than in its own issue: the withdrawal is undisclosed. CHANGELOG.md:104 describes the new switch as a pure addition and the [Unreleased] "### Changed" block (CHANGELOG.md:147) has no line saying Game chats now need "Let the GM search lore" for lorebook lookups even with Tool Use on, so anyone upgrading from v2.4.4 (where the tool was available in Game chats) sees the Game Master quietly stop looking things up. One "Changed" line in the same shape as the existing "Existing non-English users reselect their language once after upgrading" entry, and the same sentence on the Game getting-started page and the custom-tools page, would close that gap.

Found by an AI-assisted sweep of merged PR #5982 against issue #5955, then re-verified against staging 52799569c on 2026-09-13. Please verify before fixing.

Originally created by @kolacheee on GitHub (Sep 13, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6121 Originally assigned to: @SpicyMarinara on GitHub. In a Game chat, the function picker still offers `search_lorebook` and lets you add it to the chat's tool list, and the panel still says all enabled tools are available - but the server strips that tool out of every Game turn unless "Let the GM search lore" is on. The tool sits in the list looking live and never runs, with nothing saying it was withheld. ## How to reproduce (try it yourself) 1. Open a Game chat whose connection supports tool calls (otherwise both tool switches render disabled and you cannot start). Chat Settings (gear icon) -> Function Calling. 2. Turn **Enable Tool Use** ON and leave **Let the GM search lore** OFF (its default). With the function list empty, the panel reads "All globally enabled tools are available to this chat." 3. Click **Add Functions**, type `search` in the picker. `search_lorebook` is offered with no "unavailable here" marker. Tick it and add it - it now sits in the chat's active function list styled like any working tool. 4. With `search_lorebook` as the only entry in that list, also turn on **Force to Call Tool**, then send any message. **What you'll see:** the turn cannot use `search_lorebook` - the server resolved this chat's tool set down to `roll_dice` alone and dropped the tool you explicitly picked. No message, badge, or tooltip says it was removed. (Compare `update_about_me`, the other mode-restricted built-in: the picker correctly hides it outside Conversation.) **What should happen:** if a tool cannot run in this mode, the picker should not offer it and the list should not show it as active - or, if it is offered, an explicit choice should be honoured or visibly refused. And the "All globally enabled tools are available to this chat" line should not be shown in a state where it is false. ## Where it is At staging 52799569c: - `packages/server/src/services/generation/tool-resolution-runtime.ts:768-770` - the Game filter: `if (toolDefs && agentContext.chatMode === "game" && !booleanText(chatMetadata.gameLorebookSearch)) { toolDefs = toolDefs.filter((toolDef) => toolDef.function.name !== "search_lorebook"); }` - `packages/server/src/services/generation/tool-resolution-runtime.ts:751-760` - the per-chat `activeToolIds` selection is applied in `loadToolDefinitions` *before* that filter, so an explicit pick is discarded afterwards. - `packages/client/src/components/chat/ChatSettingsDrawer.tsx:2349-2353` - `availableTools` skips only `update_about_me` when not in Conversation. - `packages/client/src/features/chat-settings/sections/FunctionCallingSection.tsx:179-182` - renders "All globally enabled tools are available to this chat" whenever the chat's tool list is empty. ## What's happening The mode restriction is enforced on the server only. The client already has the right pattern for this situation - it hides `update_about_me` outside Conversation, with a comment saying it should not look available where it cannot run - but `search_lorebook` was never added to that filter. And because the user's per-chat selection is resolved before the Game filter runs, picking the tool by hand does not override the restriction; it just disappears. ## Suggested fix Extend the existing client-side mode filter so `search_lorebook` is hidden (or shown disabled with a reason) in Game chats while "Let the GM search lore" is off, and suppress or qualify the "all globally enabled tools are available" line in that state. Separately, decide what an explicit selection means: either honour a hand-picked `search_lorebook` as equivalent to turning the switch on, or surface why it was dropped - silently discarding a choice the user made by hand is the worst of the three options. Server-side enforcement should stay as the backstop. If the fix is instead to restore the old default, note that `scripts/regressions/game-tool-controls.regression.ts:306-311` asserts the current behaviour, so that route means rewriting a maintainer-written assertion - worth a deliberate decision rather than a green-lane edit. ## Context Introduced by merged PR #5982 (commit 5e41bf8ff, 2026-09-09), implementing issue #5955 and also closing #5957/#5958. Unreleased on staging - the latest release tag is v2.4.4, whose tool resolution file has no Game filter at all. The gate itself is intended; this is about the client advertising a tool the server will not run and about the discarded explicit selection. One more thing belongs with this change rather than in its own issue: the withdrawal is undisclosed. `CHANGELOG.md:104` describes the new switch as a pure addition and the `[Unreleased]` "### Changed" block (`CHANGELOG.md:147`) has no line saying Game chats now need "Let the GM search lore" for lorebook lookups even with Tool Use on, so anyone upgrading from v2.4.4 (where the tool was available in Game chats) sees the Game Master quietly stop looking things up. One "Changed" line in the same shape as the existing "Existing non-English users reselect their language once after upgrading" entry, and the same sentence on the Game getting-started page and the custom-tools page, would close that gap. Found by an AI-assisted sweep of merged PR #5982 against issue #5955, then re-verified against staging 52799569c on 2026-09-13. Please verify before fixing.
bsakaguchi 2026-10-21 06:02:40 +07:00
Author
Owner

@SpicyMarinara commented on GitHub (Sep 13, 2026):

@SpicyMarinara is taking this report through the issue sweep in draft PR #6137, with Codex assisting. The affected current-code path has been checked; implementation and focused regression verification are in progress.

<!-- gh-comment-id:5651923081 --> @SpicyMarinara commented on GitHub (Sep 13, 2026): @SpicyMarinara is taking this report through the issue sweep in draft PR #6137, with Codex assisting. The affected current-code path has been checked; implementation and focused regression verification are in progress.
Author
Owner

@SpicyMarinara commented on GitHub (Sep 13, 2026):

Fixed in #6137, now merged to staging (e044997a2). Game tool controls now reflect the actual lore-search permission and explain when it is unavailable.

<!-- gh-comment-id:5652782925 --> @SpicyMarinara commented on GitHub (Sep 13, 2026): Fixed in #6137, now merged to staging (`e044997a2`). Game tool controls now reflect the actual lore-search permission and explain when it is unavailable.
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#3398
No description provided.