[PR #6950] [MERGED] fix(roleplay): honor Function Calling's roll_dice without the Rolls command #7397

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

📋 Pull Request Information

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

Base: staging ← Head: fix/roleplay-function-calling


📝 Commits (2)

  • e27c225 fix(roleplay): honor Function Calling's roll_dice without the Rolls command
  • aa4ee65 test(roleplay): surface fake provider errors in the function calling regression

📊 Changes

3 files changed (+176 additions, -1 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 packages/server/src/routes/generate.routes.ts (+5 -1)
➕ scripts/regressions/roleplay-function-calling.regression.ts (+169 -0)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #6945

Why this change

In Roleplay, adding roll_dice under Function Calling did nothing: the model never saw the tool, and even a forced <tool_call> was saved as plain text. It only worked through Agents → Commands → Rolls.

The settings were saved fine. On the server, Roleplay offered roll_dice only while the Rolls command was on. That gate came in with narrator-only rolls (#5990), and it threw away the copy Function Calling had already attached.

What changed

  • generate.routes.ts: while Rolls is on, it still decides who may roll, including its narrator-only choice. When it's off, a roll_dice that the chat's Function Calling attached is offered and runs through the same Roleplay roll code: modifiers, dice card and the saved roll.
  • New regression roleplay-function-calling.regression.ts. It runs the real generate route against a fake KoboldCPP-style endpoint that answers with the reporter's exact <tool_call> text.
  • CHANGELOG entry.

Not changed: with streaming on and a model that writes tool calls as text, the raw <tool_call> text can stay at the start of the saved reply. That happens with the Rolls command too, so it's a separate bug.

Validation

  • 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

What I ran (not a replacement for the checklist):

  • Builds and prompt checks: pnpm check and pnpm regression:prompt pass.
  • New regression: fails without the fix, because the request carried no tools and the raw <tool_call> was saved as the reply. It passes with the fix: the tools list is ["roll_dice"], the roll runs and is saved, and the dice card shows.
  • Edge cases covered by the new regression: Function Calling with only search_lorebook doesn't offer roll_dice. Rolls set to "Narrator" still keeps other speakers from rolling.
  • Existing tests: 42 tool, dice, Roleplay and provider regressions pass, and the Roleplay commands e2e (desktop Chromium) passes.
  • Local CodeRabbit: 1 finding, fixed. The fake provider in the new test now reports its own errors instead of letting the test time out.

To check by hand:

  • In a Roleplay chat with Commands off, turn on Enable Tool Use, add roll_dice, and ask a character to roll. Confirm a dice card appears.
  • Turn Rolls on with "Who can roll dice: Narrator" and confirm other characters still can't roll.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

CHANGELOG only. docs/extending/custom-tools.md already describes this behavior.

UI evidence (if applicable)

Server-side fix; no UI changes.

Summary by CodeRabbit

  • New Features
    • Roleplay conversations can now roll dice through function calling when roll_dice is selected, returning the result to the model.
    • When the Rolls command is enabled, its Who can roll dice setting continues to determine who may roll. When it is disabled, selecting roll_dice in the chat tools allows the roll.

🔄 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/6950 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/1/2026 **Status:** ✅ Merged **Merged:** 10/1/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/roleplay-function-calling` --- ### 📝 Commits (2) - [`e27c225`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e27c225b33d4ed190b0ca1220d13c7b8c51a3d67) fix(roleplay): honor Function Calling's roll_dice without the Rolls command - [`aa4ee65`](https://github.com/Pasta-Devs/Marinara-Engine/commit/aa4ee65dcce66714076d941ec23017f50d1b8360) test(roleplay): surface fake provider errors in the function calling regression ### 📊 Changes **3 files changed** (+176 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `packages/server/src/routes/generate.routes.ts` (+5 -1) ➕ `scripts/regressions/roleplay-function-calling.regression.ts` (+169 -0) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. ## Linked issue Closes #6945 ## Why this change In Roleplay, adding `roll_dice` under **Function Calling** did nothing: the model never saw the tool, and even a forced `<tool_call>` was saved as plain text. It only worked through **Agents → Commands → Rolls**. The settings were saved fine. On the server, Roleplay offered `roll_dice` only while the Rolls command was on. That gate came in with narrator-only rolls (#5990), and it threw away the copy Function Calling had already attached. ## What changed - `generate.routes.ts`: while **Rolls** is on, it still decides who may roll, including its narrator-only choice. When it's off, a `roll_dice` that the chat's Function Calling attached is offered and runs through the same Roleplay roll code: modifiers, dice card and the saved roll. - New regression `roleplay-function-calling.regression.ts`. It runs the real generate route against a fake KoboldCPP-style endpoint that answers with the reporter's exact `<tool_call>` text. - CHANGELOG entry. Not changed: with streaming on and a model that writes tool calls as text, the raw `<tool_call>` text can stay at the start of the saved reply. That happens with the Rolls command too, so it's a separate bug. ## Validation - [ ] `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 What I ran (not a replacement for the checklist): - **Builds and prompt checks:** `pnpm check` and `pnpm regression:prompt` pass. - **New regression:** fails without the fix, because the request carried no tools and the raw `<tool_call>` was saved as the reply. It passes with the fix: the tools list is `["roll_dice"]`, the roll runs and is saved, and the dice card shows. - **Edge cases covered by the new regression:** Function Calling with only `search_lorebook` doesn't offer `roll_dice`. Rolls set to "Narrator" still keeps other speakers from rolling. - **Existing tests:** 42 tool, dice, Roleplay and provider regressions pass, and the Roleplay commands e2e (desktop Chromium) passes. - **Local CodeRabbit:** 1 finding, fixed. The fake provider in the new test now reports its own errors instead of letting the test time out. To check by hand: - In a Roleplay chat with Commands off, turn on Enable Tool Use, add `roll_dice`, and ask a character to roll. Confirm a dice card appears. - Turn Rolls on with "Who can roll dice: Narrator" and confirm other characters still can't roll. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) CHANGELOG only. `docs/extending/custom-tools.md` already describes this behavior. ## UI evidence (if applicable) Server-side fix; no UI changes. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Roleplay conversations can now roll dice through function calling when `roll_dice` is selected, returning the result to the model. * When the Rolls command is enabled, its **Who can roll dice** setting continues to determine who may roll. When it is disabled, selecting `roll_dice` in the chat tools allows the roll. <!-- 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:19:22 +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#7397
No description provided.