[PR #8165] [MERGED] fix(game): stop the 400 after a roll_dice call, name who rolls, play a persona-less party as the player, keep narrated harm on the sheet #8136

Closed
opened 2026-10-24 04:10:41 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8165
Author: @kolacheee
Created: 10/23/2026
Status: ✅ Merged
Merged: 10/23/2026
Merged by: @kolacheee

Base: staging ← Head: claude/project-thread-nibhp6


📝 Commits (7)

  • 070c20c fix(game): name rollers, play a persona-less party as the player, keep narrated harm on the sheet
  • 08e551b fix(client): localize the roller label on dice and check cards
  • 7d86372 Merge remote-tracking branch 'origin/staging' into claude/project-thread-nibhp6
  • 0762cd4 fix(game): stop the 400 on the tool round after a roll_dice call
  • 6010368 fix(game): keep the roller on continued turns, pool spends and the post-roll summary
  • 33d424d fix(llm): log a refused request's provider body only in debug mode
  • c83545c fix(llm): sanitize the debug copy of a refused request's body and log its length at warn

📊 Changes

15 files changed (+363 additions, -31 deletions)

View changed files

📝 packages/client/src/components/dice/AnimatedDiceRoll.tsx (+3 -0)
📝 packages/client/src/components/dice/AnimatedSkillCheckResult.tsx (+2 -0)
📝 packages/client/src/components/game/game-narration-format.ts (+11 -4)
📝 packages/client/src/hooks/use-generate.ts (+3 -0)
📝 packages/client/src/localization/locales/en.json (+1 -0)
📝 packages/server/src/routes/generate.routes.ts (+22 -5)
📝 packages/server/src/services/game/dice.service.ts (+38 -9)
📝 packages/server/src/services/game/gm-prompts.ts (+44 -8)
📝 packages/server/src/services/generation/game-gm-prompt-runtime.ts (+3 -0)
📝 packages/server/src/services/llm/providers/openai.provider.ts (+46 -0)
📝 packages/shared/src/types/game.ts (+3 -0)
➕ scripts/regressions/game-gm-turn-roller-party.regression.ts (+172 -0)
📝 scripts/regressions/game-text-dice.regression.ts (+5 -3)
📝 scripts/regressions/one-request-dice-pool.regression.ts (+8 -0)
📝 scripts/regressions/one-request-dice-prompt.regression.ts (+2 -2)

📄 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 #8164

Why this change

A full playtest with a real Game Master (ruleset game, four party characters, no persona, Claude through an OpenAI-compatible endpoint with thinking on) found that every turn where the GM called roll_dice failed with a 400, that rolls never said who rolled, the GM played "you" as one party member, it narrated a sneak and a search as successes with no check, and a fall and a burn never reached HP.

What changed

  • The 400: the tool round after a roll_dice call replayed the assistant tool-call turn with Claude's thinking as plain reasoning_content and no signature. The endpoint turned that into an unsigned thinking block and refused the request. For Claude models, only signed reasoning is replayed now (this also covers saved replies on later turns). A 400 from a Chat Completions endpoint now logs the provider's body and the request's shape (roles and the fields each message carried, no text), since the body alone was just "invalid request".
  • A failed game turn no longer saves what streamed before the failure as a stub reply. That stub showed up as stray GM text in the story and left two assistant replies in a row.
  • Dice and check cards and the inline narration badges now show who rolled. [dice:] requests accept who="Name", kept on the saved record; a roll_dice tool roll's reason becomes the card's label, and the GM is asked to start that reason with the roller's name.
  • With no persona, the GM is told the player has no character of their own and directs the whole party: "you" is the party, never one member, and in a ruleset game every check must name its roller with who= (a check without one was rolled off a blank sheet).
  • The GM is told never to skip a check an uncertain attempt calls for, for each character who attempts it.
  • In a ruleset game the GM is told that narration alone changes no sheet: every harm, healing or spent resource it narrates needs its sheet command in the same reply. The rewrite after engine rolls now also asks for those commands with the rolled totals.
  • The rewrite after engine rolls no longer sends the draft as a second assistant turn after an assistant prefill, and keeps any planning in a leading think block.

Validation

  • Server and client typecheck, lint, format, localization and e2e type checks
  • Full regression suite: 1037/1038 pass; launcher-browser-ready fails only because this container has no IPv6 (EAFNOSUPPORT on ::1)
  • New scripts/regressions/game-gm-turn-roller-party.regression.ts (rollers, persona-less party, sheet and check lines, unsigned Claude reasoning not replayed); one-request-dice-prompt updated for the reworded [dice:] and roll_dice lines
  • 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

  • The playtest pinned the 400 with prompt logging on the real endpoint: a skill check alone went through, while a die roll returned a native roll_dice call and the next tool round (ending on the assistant tool-call turn and its tool result) was refused in about a second.
  • Drove game turns through the real generate route against a mock OpenAI-compatible endpoint and checked every request body. The playtest will re-test the whole set against the real connection.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) 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)

UI evidence (if applicable)

The dice card header reads Hessa · 1d8+4, a check card Brannoc · Stealth check, and an inline badge 🎲 Hessa: 1d8+4 → 9.


🔄 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/8165 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 10/23/2026 **Status:** ✅ Merged **Merged:** 10/23/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `claude/project-thread-nibhp6` --- ### 📝 Commits (7) - [`070c20c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/070c20c8f0a026cbc0bbce7917f90421cd74acf6) fix(game): name rollers, play a persona-less party as the player, keep narrated harm on the sheet - [`08e551b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/08e551bb998d349fca0a0fc64fab78e579384e58) fix(client): localize the roller label on dice and check cards - [`7d86372`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7d863725cc6b7de3e0c59385460499c7384d4093) Merge remote-tracking branch 'origin/staging' into claude/project-thread-nibhp6 - [`0762cd4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0762cd4bdf58f3f1a2007b93c812734f4ba4cc4b) fix(game): stop the 400 on the tool round after a roll_dice call - [`6010368`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6010368166ac6b5b9bc34f7cac4e65ccabc75fdb) fix(game): keep the roller on continued turns, pool spends and the post-roll summary - [`33d424d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/33d424da8789ecc02b246f5d44da2b6228db8762) fix(llm): log a refused request's provider body only in debug mode - [`c83545c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c83545c2967e414d5f8927982a22f3b80f6263e7) fix(llm): sanitize the debug copy of a refused request's body and log its length at warn ### 📊 Changes **15 files changed** (+363 additions, -31 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/dice/AnimatedDiceRoll.tsx` (+3 -0) 📝 `packages/client/src/components/dice/AnimatedSkillCheckResult.tsx` (+2 -0) 📝 `packages/client/src/components/game/game-narration-format.ts` (+11 -4) 📝 `packages/client/src/hooks/use-generate.ts` (+3 -0) 📝 `packages/client/src/localization/locales/en.json` (+1 -0) 📝 `packages/server/src/routes/generate.routes.ts` (+22 -5) 📝 `packages/server/src/services/game/dice.service.ts` (+38 -9) 📝 `packages/server/src/services/game/gm-prompts.ts` (+44 -8) 📝 `packages/server/src/services/generation/game-gm-prompt-runtime.ts` (+3 -0) 📝 `packages/server/src/services/llm/providers/openai.provider.ts` (+46 -0) 📝 `packages/shared/src/types/game.ts` (+3 -0) ➕ `scripts/regressions/game-gm-turn-roller-party.regression.ts` (+172 -0) 📝 `scripts/regressions/game-text-dice.regression.ts` (+5 -3) 📝 `scripts/regressions/one-request-dice-pool.regression.ts` (+8 -0) 📝 `scripts/regressions/one-request-dice-prompt.regression.ts` (+2 -2) </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 #8164 ## Why this change A full playtest with a real Game Master (ruleset game, four party characters, no persona, Claude through an OpenAI-compatible endpoint with thinking on) found that every turn where the GM called `roll_dice` failed with a 400, that rolls never said who rolled, the GM played "you" as one party member, it narrated a sneak and a search as successes with no check, and a fall and a burn never reached HP. ## What changed - **The 400:** the tool round after a `roll_dice` call replayed the assistant tool-call turn with Claude's thinking as plain `reasoning_content` and no signature. The endpoint turned that into an unsigned thinking block and refused the request. For Claude models, only signed reasoning is replayed now (this also covers saved replies on later turns). A 400 from a Chat Completions endpoint now logs the provider's body and the request's shape (roles and the fields each message carried, no text), since the body alone was just "invalid request". - A failed game turn no longer saves what streamed before the failure as a stub reply. That stub showed up as stray GM text in the story and left two assistant replies in a row. - Dice and check cards and the inline narration badges now show who rolled. `[dice:]` requests accept `who="Name"`, kept on the saved record; a `roll_dice` tool roll's reason becomes the card's label, and the GM is asked to start that reason with the roller's name. - With no persona, the GM is told the player has no character of their own and directs the whole party: "you" is the party, never one member, and in a ruleset game every check must name its roller with `who=` (a check without one was rolled off a blank sheet). - The GM is told never to skip a check an uncertain attempt calls for, for each character who attempts it. - In a ruleset game the GM is told that narration alone changes no sheet: every harm, healing or spent resource it narrates needs its sheet command in the same reply. The rewrite after engine rolls now also asks for those commands with the rolled totals. - The rewrite after engine rolls no longer sends the draft as a second assistant turn after an assistant prefill, and keeps any planning in a leading think block. ## Validation - [x] Server and client typecheck, lint, format, localization and e2e type checks - [x] Full regression suite: 1037/1038 pass; `launcher-browser-ready` fails only because this container has no IPv6 (`EAFNOSUPPORT` on `::1`) - [x] New `scripts/regressions/game-gm-turn-roller-party.regression.ts` (rollers, persona-less party, sheet and check lines, unsigned Claude reasoning not replayed); `one-request-dice-prompt` updated for the reworded `[dice:]` and `roll_dice` lines - [ ] `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) - [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes - The playtest pinned the 400 with prompt logging on the real endpoint: a skill check alone went through, while a die roll returned a native `roll_dice` call and the next tool round (ending on the assistant tool-call turn and its tool result) was refused in about a second. - Drove game turns through the real generate route against a mock OpenAI-compatible endpoint and checked every request body. The playtest will re-test the whole set against the real connection. ## Docs and release impact - [x] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README) 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) ## UI evidence (if applicable) The dice card header reads `Hessa · 1d8+4`, a check card `Brannoc · Stealth check`, and an inline badge `🎲 Hessa: 1d8+4 → 9`. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-24 04:10:41 +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#8136
No description provided.